[76] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: comp.c 765 2007-08-05 20:17:38Z gyoung $
|
---|
| 5 |
|
---|
| 6 | Compare directories
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-02 M. Kimes
|
---|
[574] | 9 | Copyright (c) 2003, 2007 Steven H. Levine
|
---|
[76] | 10 |
|
---|
[145] | 11 | 16 Oct 02 MK Baseline
|
---|
| 12 | 04 Nov 03 SHL Force window refresh after subdir toggle
|
---|
| 13 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 14 | 24 May 05 SHL Rework Win_Error usage
|
---|
[157] | 15 | 24 May 05 SHL Rework for CNRITEM.szSubject
|
---|
| 16 | 25 May 05 SHL Rework with ULONGLONG
|
---|
[199] | 17 | 06 Jun 05 SHL Drop unused
|
---|
[362] | 18 | 12 Jul 06 SHL Renames and comments
|
---|
| 19 | 13 Jul 06 SHL Use Runtime_Error
|
---|
[366] | 20 | 26 Jul 06 SHL Drop unreachable CN_... code
|
---|
[406] | 21 | 29 Jul 06 SHL Use xfgets_bstripcr
|
---|
[448] | 22 | 15 Aug 06 SHL Turn off hide not selected on dir change
|
---|
[517] | 23 | 19 Oct 06 SHL Correct . and .. detect
|
---|
[535] | 24 | 03 Nov 06 SHL Count thread usage
|
---|
[574] | 25 | 22 Mar 07 GKY Use QWL_USER
|
---|
[742] | 26 | 29 Jul 07 SHL Use Win_Error to report container errors
|
---|
[748] | 27 | 01 Aug 07 SHL Rework to sync with CNRITEM mods
|
---|
| 28 | 01 Aug 07 SHL Rework to remove vast amount of duplicate code
|
---|
[756] | 29 | 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading)
|
---|
[76] | 30 |
|
---|
| 31 | ***********************************************************************/
|
---|
| 32 |
|
---|
[2] | 33 | #define INCL_DOS
|
---|
| 34 | #define INCL_WIN
|
---|
| 35 | #define INCL_GPI
|
---|
[157] | 36 | #define INCL_LONGLONG
|
---|
| 37 | #include <os2.h>
|
---|
[2] | 38 |
|
---|
| 39 | #include <stdio.h>
|
---|
| 40 | #include <stdlib.h>
|
---|
| 41 | #include <string.h>
|
---|
| 42 | #include <ctype.h>
|
---|
| 43 | #include <share.h>
|
---|
| 44 | #include <io.h>
|
---|
[689] | 45 | #include <process.h> // _beginthread
|
---|
[157] | 46 |
|
---|
[2] | 47 | #include "fm3dll.h"
|
---|
| 48 | #include "fm3dlg.h"
|
---|
| 49 | #include "fm3str.h"
|
---|
| 50 |
|
---|
[316] | 51 | #pragma alloc_text(COMPAREDIR,FillCnrsThread,FillDirList,CompNames)
|
---|
[2] | 52 | #pragma alloc_text(COMPAREDIR1,CompareDlgProc)
|
---|
[316] | 53 | #pragma alloc_text(COMPAREDIR2,SelectCnrsThread,ActionCnrThread)
|
---|
| 54 | #pragma alloc_text(COMPAREFILE,CFileDlgProc,CompareFilesThread)
|
---|
[2] | 55 | #pragma alloc_text(SNAPSHOT,SnapShot,StartSnap)
|
---|
| 56 |
|
---|
[551] | 57 | typedef struct
|
---|
| 58 | {
|
---|
| 59 | CHAR filename[CCHMAXPATH];
|
---|
| 60 | CHAR dirname[CCHMAXPATH];
|
---|
| 61 | BOOL recurse;
|
---|
| 62 | }
|
---|
| 63 | SNAPSTUFF;
|
---|
[2] | 64 |
|
---|
[362] | 65 | static PSZ pszSrcFile = __FILE__;
|
---|
| 66 |
|
---|
[316] | 67 | //=== SnapShot() Write directory tree to file and recurse if requested ===
|
---|
[2] | 68 |
|
---|
[551] | 69 | static VOID SnapShot(char *path, FILE * fp, BOOL recurse)
|
---|
[157] | 70 | {
|
---|
[2] | 71 | FILEFINDBUF4 *fb;
|
---|
[551] | 72 | char *mask, *enddir;
|
---|
| 73 | HDIR hdir = HDIR_CREATE;
|
---|
[763] | 74 | ULONG nm = 1;
|
---|
[2] | 75 |
|
---|
[551] | 76 | fb = xmalloc(sizeof(FILEFINDBUF4), pszSrcFile, __LINE__);
|
---|
| 77 | if (fb) {
|
---|
| 78 | mask = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
|
---|
| 79 | if (mask) {
|
---|
[2] | 80 | sprintf(mask,
|
---|
[551] | 81 | "%s%s*",
|
---|
| 82 | path, (path[strlen(path) - 1] != '\\') ? "\\" : NullStr);
|
---|
| 83 | enddir = strrchr(mask, '\\');
|
---|
[2] | 84 | enddir++;
|
---|
[551] | 85 | if (!DosFindFirst(mask,
|
---|
| 86 | &hdir,
|
---|
| 87 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
| 88 | FILE_ARCHIVED | FILE_READONLY | FILE_HIDDEN |
|
---|
| 89 | FILE_SYSTEM,
|
---|
| 90 | fb, sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE)) {
|
---|
| 91 | do {
|
---|
| 92 | strcpy(enddir, fb->achName);
|
---|
| 93 | if (!(fb->attrFile & FILE_DIRECTORY))
|
---|
| 94 | fprintf(fp,
|
---|
| 95 | "\"%s\",%u,%lu,%04u/%02u/%02u,%02u:%02u:%02u,%lu,%lu,N\n",
|
---|
| 96 | mask,
|
---|
| 97 | enddir - mask,
|
---|
| 98 | fb->cbFile,
|
---|
| 99 | (fb->fdateLastWrite.year + 1980),
|
---|
| 100 | fb->fdateLastWrite.month,
|
---|
| 101 | fb->fdateLastWrite.day,
|
---|
| 102 | fb->ftimeLastWrite.hours,
|
---|
| 103 | fb->ftimeLastWrite.minutes,
|
---|
| 104 | fb->ftimeLastWrite.twosecs,
|
---|
[763] | 105 | fb->attrFile, (fb->cbList > 4) ? (fb->cbList / 2) : 0);
|
---|
[517] | 106 | // Skip . and ..
|
---|
[551] | 107 | else if (recurse &&
|
---|
[517] | 108 | (fb->achName[0] != '.' ||
|
---|
| 109 | (fb->achName[1] &&
|
---|
| 110 | (fb->achName[1] != '.' || fb->achName[2])))) {
|
---|
[551] | 111 | SnapShot(mask, fp, recurse);
|
---|
| 112 | }
|
---|
[763] | 113 | nm = 1;
|
---|
[551] | 114 | } while (!DosFindNext(hdir, fb, sizeof(FILEFINDBUF4), &nm));
|
---|
| 115 | DosFindClose(hdir);
|
---|
[2] | 116 | }
|
---|
| 117 | free(mask);
|
---|
| 118 | }
|
---|
| 119 | free(fb);
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 |
|
---|
[316] | 123 | //=== StartSnap() Write directory tree to snapshot file ===
|
---|
[2] | 124 |
|
---|
[551] | 125 | static VOID StartSnap(VOID * dummy)
|
---|
[316] | 126 | {
|
---|
[551] | 127 | SNAPSTUFF *sf = (SNAPSTUFF *) dummy;
|
---|
| 128 | FILE *fp;
|
---|
| 129 | CHAR *p;
|
---|
[2] | 130 |
|
---|
[551] | 131 | if (sf) {
|
---|
| 132 | if (*sf->dirname && *sf->filename) {
|
---|
[2] | 133 | priority_normal();
|
---|
| 134 | p = sf->dirname;
|
---|
[551] | 135 | while (*p) {
|
---|
| 136 | if (*p == '/')
|
---|
| 137 | *p = '\\';
|
---|
| 138 | p++;
|
---|
[2] | 139 | }
|
---|
[551] | 140 | if (*(p - 1) != '\\') {
|
---|
| 141 | *p = '\\';
|
---|
| 142 | p++;
|
---|
[2] | 143 | }
|
---|
[551] | 144 | fp = xfopen(sf->filename, "w", pszSrcFile, __LINE__);
|
---|
[362] | 145 | if (fp) {
|
---|
[551] | 146 | fprintf(fp, "\"%s\"\n", sf->dirname);
|
---|
| 147 | SnapShot(sf->dirname, fp, sf->recurse);
|
---|
| 148 | fclose(fp);
|
---|
[2] | 149 | }
|
---|
| 150 | }
|
---|
| 151 | free(sf);
|
---|
| 152 | }
|
---|
| 153 | }
|
---|
| 154 |
|
---|
[316] | 155 | //=== CompareFilesThread() Compare files and update container select flags ===
|
---|
[2] | 156 |
|
---|
[551] | 157 | static VOID CompareFilesThread(VOID * args)
|
---|
[316] | 158 | {
|
---|
[2] | 159 | FCOMPARE fc;
|
---|
[551] | 160 | HAB hab2;
|
---|
| 161 | HMQ hmq2;
|
---|
| 162 | FILE *fp1, *fp2;
|
---|
| 163 | ULONG len1, len2, offset = 0L;
|
---|
| 164 | LONG numread1, numread2;
|
---|
| 165 | CHAR s[1024], ss[1024], *p1, *p2;
|
---|
[2] | 166 |
|
---|
[551] | 167 | if (args) {
|
---|
| 168 | fc = *(FCOMPARE *) args;
|
---|
[2] | 169 | hab2 = WinInitialize(0);
|
---|
[551] | 170 | if (hab2) {
|
---|
| 171 | hmq2 = WinCreateMsgQueue(hab2, 0);
|
---|
| 172 | if (hmq2) {
|
---|
| 173 | WinCancelShutdown(hmq2, TRUE);
|
---|
[535] | 174 | IncrThreadUsage();
|
---|
[551] | 175 | if (!IsFile(fc.file1) || IsRoot(fc.file1)) {
|
---|
| 176 | p1 = strrchr(fc.file2, '\\');
|
---|
| 177 | if (p1) {
|
---|
| 178 | if (fc.file1[strlen(fc.file1) - 1] == '\\')
|
---|
| 179 | p1++;
|
---|
| 180 | strcat(fc.file1, p1);
|
---|
| 181 | }
|
---|
[362] | 182 | }
|
---|
[551] | 183 | else if (!IsFile(fc.file2) || IsRoot(fc.file2)) {
|
---|
| 184 | p1 = strrchr(fc.file1, '\\');
|
---|
| 185 | if (p1) {
|
---|
| 186 | if (fc.file2[strlen(fc.file2) - 1] == '\\')
|
---|
| 187 | p1++;
|
---|
| 188 | strcat(fc.file2, p1);
|
---|
| 189 | }
|
---|
| 190 | }
|
---|
| 191 | sprintf(s, GetPString(IDS_COMPCOMPARETEXT), fc.file1);
|
---|
| 192 | AddToListboxBottom(fc.hwndList, s);
|
---|
| 193 | sprintf(s, GetPString(IDS_COMPTOTEXT), fc.file2);
|
---|
| 194 | AddToListboxBottom(fc.hwndList, s);
|
---|
| 195 | fp1 = _fsopen(fc.file1, "rb", SH_DENYNO);
|
---|
| 196 | if (!fp1) {
|
---|
| 197 | sprintf(s, GetPString(IDS_COMPCANTOPENTEXT), fc.file1);
|
---|
| 198 | AddToListboxBottom(fc.hwndList, s);
|
---|
| 199 | WinSetWindowText(fc.hwndHelp, GetPString(IDS_ERRORTEXT));
|
---|
| 200 | }
|
---|
[362] | 201 | else {
|
---|
[551] | 202 | fp2 = _fsopen(fc.file2, "rb", SH_DENYNO);
|
---|
| 203 | if (!fp2) {
|
---|
| 204 | sprintf(s, GetPString(IDS_COMPCANTOPENTEXT), fc.file2);
|
---|
| 205 | AddToListboxBottom(fc.hwndList, s);
|
---|
| 206 | WinSetWindowText(fc.hwndHelp, GetPString(IDS_ERRORTEXT));
|
---|
[362] | 207 | }
|
---|
| 208 | else {
|
---|
[551] | 209 | len1 = filelength(fileno(fp1));
|
---|
| 210 | len2 = filelength(fileno(fp2));
|
---|
| 211 | if (len1 != len2) {
|
---|
| 212 | strcpy(s, GetPString(IDS_COMPDIFSIZESTEXT));
|
---|
| 213 | AddToListboxBottom(fc.hwndList, s);
|
---|
| 214 | sprintf(s, GetPString(IDS_COMPVSBYTESTEXT), len1, len2);
|
---|
| 215 | AddToListboxBottom(fc.hwndList, s);
|
---|
| 216 | WinSetWindowText(fc.hwndHelp,
|
---|
| 217 | GetPString(IDS_COMPDONTMATCHTEXT));
|
---|
| 218 | }
|
---|
| 219 | else {
|
---|
| 220 | WinSetWindowText(fc.hwndHelp,
|
---|
| 221 | GetPString(IDS_COMPCOMPARINGTEXT));
|
---|
| 222 | while (WinIsWindow(hab2, fc.hwndList)) {
|
---|
| 223 | numread1 = fread(s, 1, 1024, fp1);
|
---|
| 224 | numread2 = fread(ss, 1, 1024, fp2);
|
---|
| 225 | if (numread1 != numread2 || feof(fp1) != feof(fp2)) {
|
---|
| 226 | sprintf(s, GetPString(IDS_COMPREADERRORTEXT),
|
---|
| 227 | offset, offset);
|
---|
| 228 | AddToListboxBottom(fc.hwndList, s);
|
---|
| 229 | WinSetWindowText(fc.hwndHelp, GetPString(IDS_ERRORTEXT));
|
---|
| 230 | break;
|
---|
| 231 | }
|
---|
| 232 | else if (!numread1 && feof(fp1) && feof(fp2)) {
|
---|
| 233 | AddToListboxBottom(fc.hwndList,
|
---|
| 234 | GetPString(IDS_COMPFILESMATCHTEXT));
|
---|
| 235 | if (!stricmp(fc.file1, fc.file2))
|
---|
| 236 | AddToListboxBottom(fc.hwndList,
|
---|
| 237 | GetPString(IDS_COMPWONDERWHYTEXT));
|
---|
| 238 | WinSetWindowText(fc.hwndHelp,
|
---|
| 239 | GetPString(IDS_COMPCOMPLETETEXT));
|
---|
| 240 | break;
|
---|
| 241 | }
|
---|
| 242 | else if (numread1 <= 0 || numread2 <= 0) {
|
---|
| 243 | if (offset == len1)
|
---|
| 244 | break;
|
---|
| 245 | else {
|
---|
| 246 | sprintf(s, GetPString(IDS_COMPMATCHREADERRORTEXT),
|
---|
| 247 | offset, offset);
|
---|
| 248 | WinSetWindowText(fc.hwndHelp,
|
---|
| 249 | GetPString(IDS_COMPODDERRORTEXT));
|
---|
| 250 | AddToListboxBottom(fc.hwndList, s);
|
---|
| 251 | break;
|
---|
| 252 | }
|
---|
| 253 | }
|
---|
| 254 | else if (memcmp(s, ss, numread1)) {
|
---|
| 255 | p1 = s;
|
---|
| 256 | p2 = ss;
|
---|
| 257 | while (p1 < s + numread1) {
|
---|
| 258 | if (*p1 != *p2) {
|
---|
| 259 | sprintf(s, GetPString(IDS_COMPMISMATCHERRORTEXT),
|
---|
| 260 | offset + (p1 - s), offset + (p1 - s));
|
---|
| 261 | AddToListboxBottom(fc.hwndList, s);
|
---|
| 262 | WinSetWindowText(fc.hwndHelp,
|
---|
| 263 | GetPString(IDS_COMPDONTMATCHTEXT));
|
---|
| 264 | break;
|
---|
| 265 | }
|
---|
| 266 | p1++;
|
---|
| 267 | p2++;
|
---|
| 268 | }
|
---|
| 269 | break;
|
---|
| 270 | }
|
---|
| 271 | offset += numread1;
|
---|
| 272 | }
|
---|
| 273 | }
|
---|
| 274 | fclose(fp2);
|
---|
| 275 | }
|
---|
| 276 | fclose(fp1);
|
---|
| 277 | }
|
---|
[535] | 278 | DecrThreadUsage();
|
---|
[551] | 279 | WinDestroyMsgQueue(hmq2);
|
---|
[2] | 280 | }
|
---|
| 281 | WinTerminate(hab2);
|
---|
| 282 | }
|
---|
| 283 | }
|
---|
| 284 | }
|
---|
| 285 |
|
---|
[316] | 286 | //=== CFileDlgProc() Select directories to compare dialog procedure ===
|
---|
[2] | 287 |
|
---|
[551] | 288 | MRESULT EXPENTRY CFileDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[316] | 289 | {
|
---|
[2] | 290 | FCOMPARE *fc;
|
---|
| 291 |
|
---|
[551] | 292 | switch (msg) {
|
---|
| 293 | case WM_INITDLG:
|
---|
| 294 | if (!mp2)
|
---|
| 295 | WinDismissDlg(hwnd, 0);
|
---|
| 296 | else {
|
---|
[574] | 297 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
[551] | 298 | fc = (FCOMPARE *) mp2;
|
---|
| 299 | fc->hwndReport = hwnd;
|
---|
| 300 | fc->hwndList = WinWindowFromID(hwnd, FCMP_LISTBOX);
|
---|
| 301 | fc->hwndHelp = WinWindowFromID(hwnd, FCMP_HELP);
|
---|
| 302 | if (!*fc->file1 || !fc->file2) {
|
---|
| 303 | WinDismissDlg(hwnd, 0);
|
---|
| 304 | break;
|
---|
[2] | 305 | }
|
---|
[551] | 306 | MakeFullName(fc->file1);
|
---|
| 307 | MakeFullName(fc->file2);
|
---|
| 308 | if (!stricmp(fc->file1, fc->file2)) {
|
---|
| 309 | saymsg(MB_CANCEL, hwnd,
|
---|
| 310 | GetPString(IDS_COMPSILLYALERTTEXT),
|
---|
| 311 | GetPString(IDS_COMPTOITSELFTEXT));
|
---|
| 312 | WinDismissDlg(hwnd, 0);
|
---|
| 313 | break;
|
---|
| 314 | }
|
---|
| 315 | if (_beginthread(CompareFilesThread, NULL, 65536, (PVOID) fc) == -1) {
|
---|
| 316 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 317 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
| 318 | WinDismissDlg(hwnd, 0);
|
---|
| 319 | }
|
---|
| 320 | }
|
---|
| 321 | break;
|
---|
[2] | 322 |
|
---|
[551] | 323 | case WM_ADJUSTWINDOWPOS:
|
---|
| 324 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 325 | break;
|
---|
[2] | 326 |
|
---|
[551] | 327 | case UM_SETDIR:
|
---|
| 328 | PaintRecessedWindow(WinWindowFromID(hwnd, FCMP_HELP),
|
---|
| 329 | (HPS) 0, FALSE, TRUE);
|
---|
| 330 | return 0;
|
---|
[2] | 331 |
|
---|
[551] | 332 | case WM_COMMAND:
|
---|
| 333 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 334 | case DID_OK:
|
---|
| 335 | WinDismissDlg(hwnd, 0);
|
---|
| 336 | break;
|
---|
| 337 | case DID_CANCEL:
|
---|
| 338 | WinDismissDlg(hwnd, 1);
|
---|
| 339 | break;
|
---|
| 340 | }
|
---|
| 341 | return 0;
|
---|
[2] | 342 |
|
---|
[551] | 343 | case WM_DESTROY:
|
---|
[741] | 344 | DosSleep(100);
|
---|
[551] | 345 | break;
|
---|
[2] | 346 | }
|
---|
[551] | 347 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 348 | }
|
---|
| 349 |
|
---|
[316] | 350 | //=== ActionCnrThread() Do requested action on container contents ===
|
---|
[2] | 351 |
|
---|
[731] | 352 | static VOID ActionCnrThread(VOID *args)
|
---|
[316] | 353 | {
|
---|
[731] | 354 | COMPARE *cmp = (COMPARE *)args;
|
---|
[551] | 355 | HAB hab;
|
---|
| 356 | HMQ hmq;
|
---|
| 357 | HWND hwndCnrS, hwndCnrD;
|
---|
[748] | 358 | PCNRITEM pci, pciD, pciNextS, pciNextD;
|
---|
[551] | 359 | CHAR newname[CCHMAXPATH], dirname[CCHMAXPATH], *p;
|
---|
[763] | 360 | PSZ pszNewName = newname;
|
---|
[551] | 361 | APIRET rc;
|
---|
[2] | 362 |
|
---|
[748] | 363 | if (!cmp) {
|
---|
| 364 | Runtime_Error(pszSrcFile, __LINE__, "no data");
|
---|
[2] | 365 | return;
|
---|
[748] | 366 | }
|
---|
[2] | 367 |
|
---|
| 368 | DosError(FERR_DISABLEHARDERR);
|
---|
| 369 |
|
---|
| 370 | hab = WinInitialize(0);
|
---|
[551] | 371 | if (hab) {
|
---|
| 372 | hmq = WinCreateMsgQueue(hab, 0);
|
---|
| 373 | if (hmq) {
|
---|
| 374 | WinCancelShutdown(hmq, TRUE);
|
---|
[535] | 375 | IncrThreadUsage();
|
---|
[2] | 376 | priority_normal();
|
---|
[551] | 377 | switch (cmp->action) {
|
---|
| 378 | case COMP_DELETELEFT:
|
---|
| 379 | hwndCnrS = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
|
---|
| 380 | hwndCnrD = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
|
---|
| 381 | cmp->action = IDM_DELETE;
|
---|
| 382 | break;
|
---|
| 383 | case COMP_DELETERIGHT:
|
---|
| 384 | hwndCnrS = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
|
---|
| 385 | hwndCnrD = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
|
---|
| 386 | cmp->action = IDM_DELETE;
|
---|
| 387 | break;
|
---|
| 388 | case COMP_MOVELEFT:
|
---|
| 389 | cmp->action = IDM_MOVE;
|
---|
| 390 | hwndCnrS = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
|
---|
| 391 | hwndCnrD = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
|
---|
| 392 | break;
|
---|
| 393 | case COMP_MOVERIGHT:
|
---|
| 394 | cmp->action = IDM_MOVE;
|
---|
| 395 | hwndCnrS = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
|
---|
| 396 | hwndCnrD = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
|
---|
| 397 | break;
|
---|
| 398 | case COMP_COPYLEFT:
|
---|
| 399 | cmp->action = IDM_COPY;
|
---|
| 400 | hwndCnrS = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
|
---|
| 401 | hwndCnrD = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
|
---|
| 402 | break;
|
---|
| 403 | case COMP_COPYRIGHT:
|
---|
| 404 | cmp->action = IDM_COPY;
|
---|
| 405 | hwndCnrS = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
|
---|
| 406 | hwndCnrD = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
|
---|
| 407 | break;
|
---|
| 408 | default:
|
---|
| 409 | Runtime_Error(pszSrcFile, __LINE__, "bad case %u", cmp->action);
|
---|
| 410 | goto Abort;
|
---|
[2] | 411 | }
|
---|
| 412 |
|
---|
[551] | 413 | pci = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID,
|
---|
| 414 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
[748] | 415 | pciD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID,
|
---|
[551] | 416 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
[316] | 417 |
|
---|
[748] | 418 | while (pci && (INT)pci != -1 && pciD && (INT)pciD != -1) {
|
---|
| 419 |
|
---|
| 420 | pciNextS = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPFROMP(pci),
|
---|
[551] | 421 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
[748] | 422 | pciNextD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPFROMP(pciD),
|
---|
[551] | 423 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
[748] | 424 |
|
---|
| 425 | if (*pci->pszFileName && pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
| 426 |
|
---|
| 427 | // Source name not blank
|
---|
[551] | 428 | switch (cmp->action) {
|
---|
| 429 | case IDM_DELETE:
|
---|
[730] | 430 | if (!unlinkf("%s", pci->pszFileName)) {
|
---|
[551] | 431 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
| 432 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
[748] | 433 |
|
---|
| 434 | if (!*pciD->pszFileName) {
|
---|
[751] | 435 | // Other side is blank - remove from both sides
|
---|
| 436 | RemoveCnrItems(hwndCnrS, pci, 1, CMA_FREE | CMA_INVALIDATE);
|
---|
[748] | 437 | if (pciD->rc.flRecordAttr & CRA_SELECTED)
|
---|
| 438 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
|
---|
[551] | 439 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
[751] | 440 | RemoveCnrItems(hwndCnrD, pciD, 1, CMA_FREE | CMA_INVALIDATE);
|
---|
[551] | 441 | }
|
---|
[742] | 442 | else {
|
---|
[751] | 443 | // Other side is not blank - update just this side
|
---|
[748] | 444 | FreeCnrItemData(pci);
|
---|
[751] | 445 | pci->pszDisplayName = pci->pszFileName;
|
---|
| 446 | pci->rc.pszIcon = pci->pszFileName;
|
---|
[551] | 447 | pci->flags = 0;
|
---|
| 448 | WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci),
|
---|
| 449 | MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
|
---|
| 450 | }
|
---|
| 451 | if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR))
|
---|
| 452 | cmp->cmp->totalleft--;
|
---|
| 453 | else
|
---|
| 454 | cmp->cmp->totalright--;
|
---|
[748] | 455 | DosSleep(1);
|
---|
[551] | 456 | }
|
---|
| 457 | break;
|
---|
[2] | 458 |
|
---|
[551] | 459 | case IDM_MOVE:
|
---|
| 460 | if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
|
---|
[763] | 461 | // 02 Aug 07 SHL fixme to replace this kind of stuff with _makepath or equivalent
|
---|
| 462 | BldFullPathName(pszNewName, cmp->leftdir, pci->pszDisplayName);
|
---|
| 463 | //sprintf(newname, "%s%s%s",
|
---|
| 464 | // cmp->leftdir,
|
---|
| 465 | // cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\' ?
|
---|
| 466 | // NullStr : "\\",
|
---|
| 467 | // pci->pszDisplayName);
|
---|
| 468 | else
|
---|
| 469 | BldFullPathName(pszNewName, cmp->rightdir, pci->pszDisplayName);
|
---|
| 470 | //sprintf(newname, "%s%s%s",
|
---|
| 471 | // cmp->rightdir,
|
---|
[765] | 472 | // cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\' ?
|
---|
| 473 | // NullStr : "\\",
|
---|
| 474 | // pci->pszDisplayName);
|
---|
[748] | 475 | // Make directory if required
|
---|
[551] | 476 | strcpy(dirname, newname);
|
---|
| 477 | p = strrchr(dirname, '\\');
|
---|
| 478 | if (p) {
|
---|
| 479 | if (p > dirname + 2)
|
---|
| 480 | p++;
|
---|
| 481 | *p = 0;
|
---|
| 482 | if (IsFile(dirname) == -1)
|
---|
| 483 | MassMkdir(hwndMain, dirname);
|
---|
| 484 | }
|
---|
[730] | 485 | rc = docopyf(MOVE, pci->pszFileName, "%s", newname);
|
---|
| 486 | if (!rc && stricmp(pci->pszFileName, newname)) {
|
---|
[551] | 487 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
| 488 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
[748] | 489 | if (pciD->rc.flRecordAttr & CRA_SELECTED)
|
---|
| 490 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
|
---|
[551] | 491 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
[748] | 492 | FreeCnrItemData(pciD);
|
---|
| 493 | pciD->pszFileName = xstrdup(newname, pszSrcFile, __LINE__);
|
---|
[551] | 494 | if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
|
---|
[748] | 495 | pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir);
|
---|
[551] | 496 | if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
|
---|
[751] | 497 | pciD->pszDisplayName++;
|
---|
[551] | 498 | }
|
---|
| 499 | else {
|
---|
[748] | 500 | pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->rightdir);
|
---|
[551] | 501 | if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
|
---|
[751] | 502 | pciD->pszDisplayName++;
|
---|
[742] | 503 | }
|
---|
[751] | 504 | // 02 Aug 07 SHL fixme to know Longname transfer is correct?
|
---|
[762] | 505 | pciD->pszLongName = pci->pszLongName;
|
---|
[751] | 506 | if (pciD->pszSubject != NullStr) {
|
---|
| 507 | xfree(pciD->pszSubject);
|
---|
| 508 | pciD->pszSubject = NullStr;
|
---|
| 509 | }
|
---|
[748] | 510 | pciD->attrFile = pci->attrFile;
|
---|
[751] | 511 | pciD->pszDispAttr = pci->pszDispAttr;
|
---|
[762] | 512 | pciD->flags = CNRITEM_EXISTS; // 04 Aug 07 SHL
|
---|
[748] | 513 | pciD->date = pci->date;
|
---|
| 514 | pciD->time = pci->time;
|
---|
| 515 | pciD->ladate = pci->ladate;
|
---|
| 516 | pciD->latime = pci->latime;
|
---|
| 517 | pciD->crdate = pci->crdate;
|
---|
| 518 | pciD->crtime = pci->crtime;
|
---|
| 519 | pciD->cbFile = pci->cbFile;
|
---|
| 520 | pciD->easize = pci->easize;
|
---|
[751] | 521 |
|
---|
| 522 | if (pci->pszFileName != NullStr) {
|
---|
| 523 | xfree(pci->pszFileName);
|
---|
| 524 | pci->pszFileName = NullStr;
|
---|
| 525 | pci->pszDisplayName = pci->pszFileName;
|
---|
| 526 | pci->rc.pszIcon = pci->pszFileName;
|
---|
| 527 | }
|
---|
| 528 | if (pci->pszSubject != NullStr) {
|
---|
| 529 | xfree(pci->pszSubject);
|
---|
| 530 | pci->pszSubject = NullStr;
|
---|
| 531 | }
|
---|
[551] | 532 | pci->flags = 0;
|
---|
[751] | 533 |
|
---|
[551] | 534 | WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci),
|
---|
| 535 | MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
|
---|
[748] | 536 | WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
|
---|
[551] | 537 | MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
|
---|
| 538 | }
|
---|
| 539 | else if (rc) {
|
---|
| 540 | rc = Dos_Error(MB_ENTERCANCEL,
|
---|
| 541 | rc,
|
---|
| 542 | HWND_DESKTOP,
|
---|
| 543 | pszSrcFile,
|
---|
| 544 | __LINE__,
|
---|
| 545 | GetPString(IDS_COMPMOVEFAILEDTEXT),
|
---|
[730] | 546 | pci->pszFileName, newname);
|
---|
[748] | 547 | if (rc == MBID_CANCEL) // Cause loop to break
|
---|
| 548 | pciNextS = NULL;
|
---|
[551] | 549 | }
|
---|
| 550 | break;
|
---|
[2] | 551 |
|
---|
[551] | 552 | case IDM_COPY:
|
---|
[763] | 553 | if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
|
---|
| 554 | BldFullPathName(pszNewName, cmp->leftdir, pci->pszDisplayName);
|
---|
| 555 | //sprintf(newname, "%s%s%s",
|
---|
| 556 | // cmp->leftdir,
|
---|
| 557 | // cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\' ?
|
---|
| 558 | // NullStr : "\\",
|
---|
[765] | 559 | // pci->pszDisplayName);
|
---|
[763] | 560 | else
|
---|
| 561 | BldFullPathName(pszNewName, cmp->rightdir, pci->pszDisplayName);
|
---|
| 562 | //sprintf(newname, "%s%s%s",
|
---|
| 563 | // cmp->rightdir,
|
---|
| 564 | // cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\' ?
|
---|
| 565 | // NullStr : "\\",
|
---|
| 566 | // pci->pszDisplayName);
|
---|
[748] | 567 | // Make directory if required
|
---|
[551] | 568 | strcpy(dirname, newname);
|
---|
| 569 | p = strrchr(dirname, '\\');
|
---|
| 570 | if (p) {
|
---|
| 571 | if (p > dirname + 2)
|
---|
| 572 | p++;
|
---|
| 573 | *p = 0;
|
---|
| 574 | if (IsFile(dirname) == -1)
|
---|
| 575 | MassMkdir(hwndMain, dirname);
|
---|
| 576 | }
|
---|
[730] | 577 | rc = docopyf(COPY, pci->pszFileName, "%s", newname);
|
---|
[551] | 578 | if (rc) {
|
---|
| 579 | rc = Dos_Error(MB_ENTERCANCEL,
|
---|
| 580 | rc,
|
---|
| 581 | HWND_DESKTOP,
|
---|
| 582 | pszSrcFile,
|
---|
| 583 | __LINE__,
|
---|
| 584 | GetPString(IDS_COMPCOPYFAILEDTEXT),
|
---|
[730] | 585 | pci->pszFileName, newname);
|
---|
[551] | 586 | if (rc == MBID_CANCEL)
|
---|
[748] | 587 | pciNextS = NULL; // Cause loop to break
|
---|
[551] | 588 | }
|
---|
| 589 | else {
|
---|
| 590 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
| 591 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
[748] | 592 | if (pciD->rc.flRecordAttr & CRA_SELECTED)
|
---|
| 593 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
|
---|
[551] | 594 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
[748] | 595 | FreeCnrItemData(pciD);
|
---|
| 596 | pciD->pszFileName = xstrdup(newname, pszSrcFile, __LINE__);
|
---|
[551] | 597 | if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
|
---|
[748] | 598 | pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir);
|
---|
[551] | 599 | if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
|
---|
[751] | 600 | pciD->pszDisplayName++;
|
---|
[362] | 601 | }
|
---|
| 602 | else {
|
---|
[748] | 603 | pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->rightdir);
|
---|
[551] | 604 | if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
|
---|
[751] | 605 | pciD->pszDisplayName++;
|
---|
[742] | 606 | }
|
---|
[748] | 607 | pciD->attrFile = pci->attrFile;
|
---|
[751] | 608 | pciD->pszDispAttr = pci->pszDispAttr;
|
---|
[748] | 609 | pciD->flags = CNRITEM_EXISTS;
|
---|
| 610 | pciD->date = pci->date;
|
---|
| 611 | pciD->time = pci->time;
|
---|
| 612 | pciD->ladate = pci->ladate;
|
---|
| 613 | pciD->latime = pci->latime;
|
---|
| 614 | pciD->crdate = pci->crdate;
|
---|
| 615 | pciD->crtime = pci->crtime;
|
---|
| 616 | pciD->cbFile = pci->cbFile;
|
---|
| 617 | pciD->easize = pci->easize;
|
---|
[751] | 618 |
|
---|
| 619 | // 02 Aug 07 SHL fixme to know why subject cleared?
|
---|
| 620 | if (pci->pszSubject != NullStr) {
|
---|
| 621 | xfree(pci->pszSubject);
|
---|
| 622 | pci->pszSubject = NullStr;
|
---|
| 623 | }
|
---|
| 624 | // 02 Aug 07 SHL fixme to know why - should already be set?
|
---|
[762] | 625 | // pci->flags = CNRITEM_EXISTS;
|
---|
[751] | 626 |
|
---|
[551] | 627 | WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci),
|
---|
| 628 | MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
|
---|
[748] | 629 | WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
|
---|
[551] | 630 | MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
|
---|
| 631 | }
|
---|
| 632 | break;
|
---|
[2] | 633 |
|
---|
[551] | 634 | default:
|
---|
| 635 | break;
|
---|
[748] | 636 | } // switch
|
---|
| 637 |
|
---|
| 638 | } // if have name
|
---|
| 639 |
|
---|
| 640 | pci = pciNextS;
|
---|
| 641 | pciD = pciNextD;
|
---|
| 642 |
|
---|
| 643 | } // while
|
---|
[551] | 644 | Abort:
|
---|
[2] | 645 | WinDestroyMsgQueue(hmq);
|
---|
| 646 | }
|
---|
[535] | 647 | DecrThreadUsage();
|
---|
[2] | 648 | WinTerminate(hab);
|
---|
| 649 | }
|
---|
[551] | 650 | PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPFROMLONG(1L), MPVOID);
|
---|
| 651 | PostMsg(cmp->hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DESELECTALL, 0), MPVOID);
|
---|
[2] | 652 | free(cmp);
|
---|
| 653 | }
|
---|
| 654 |
|
---|
[316] | 655 | //=== SelectCnrsThread() Update container selection flags thread ===
|
---|
[2] | 656 |
|
---|
[551] | 657 | static VOID SelectCnrsThread(VOID * args)
|
---|
[316] | 658 | {
|
---|
[551] | 659 | COMPARE *cmp = (COMPARE *) args;
|
---|
| 660 | HAB hab;
|
---|
| 661 | HMQ hmq;
|
---|
[2] | 662 |
|
---|
[551] | 663 | if (!cmp)
|
---|
[2] | 664 | return;
|
---|
| 665 |
|
---|
| 666 | DosError(FERR_DISABLEHARDERR);
|
---|
| 667 |
|
---|
| 668 | hab = WinInitialize(0);
|
---|
[551] | 669 | if (hab) {
|
---|
| 670 | hmq = WinCreateMsgQueue(hab, 0);
|
---|
| 671 | if (hmq) {
|
---|
| 672 | WinCancelShutdown(hmq, TRUE);
|
---|
[535] | 673 | IncrThreadUsage();
|
---|
[2] | 674 | priority_normal();
|
---|
[551] | 675 | switch (cmp->action) {
|
---|
| 676 | case IDM_INVERT:
|
---|
| 677 | InvertAll(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR));
|
---|
| 678 | InvertAll(WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR));
|
---|
| 679 | break;
|
---|
[2] | 680 |
|
---|
[551] | 681 | case IDM_DESELECTALL:
|
---|
| 682 | Deselect(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR));
|
---|
| 683 | Deselect(WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR));
|
---|
| 684 | break;
|
---|
[2] | 685 |
|
---|
[551] | 686 | default:
|
---|
| 687 | SpecialSelect(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR),
|
---|
| 688 | WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR),
|
---|
| 689 | cmp->action, cmp->reset);
|
---|
| 690 | break;
|
---|
[2] | 691 | }
|
---|
[551] | 692 | if (!PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPFROMLONG(1L), MPVOID))
|
---|
| 693 | WinSendMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPFROMLONG(1L), MPVOID);
|
---|
[2] | 694 | WinDestroyMsgQueue(hmq);
|
---|
| 695 | }
|
---|
[535] | 696 | DecrThreadUsage();
|
---|
[2] | 697 | WinTerminate(hab);
|
---|
| 698 | }
|
---|
| 699 | free(cmp);
|
---|
| 700 | }
|
---|
| 701 |
|
---|
[748] | 702 | /**
|
---|
| 703 | * Build FILELIST given pathname
|
---|
| 704 | */
|
---|
| 705 |
|
---|
| 706 | static VOID FillDirList(CHAR *str, INT skiplen, BOOL recurse,
|
---|
| 707 | FILELIST ***list, INT *numfiles, INT *numalloc)
|
---|
[551] | 708 | {
|
---|
[2] | 709 |
|
---|
[748] | 710 | BYTE *fb;
|
---|
| 711 | CHAR *enddir;
|
---|
| 712 | ULONG x;
|
---|
[551] | 713 | CHAR *maskstr;
|
---|
| 714 | FILEFINDBUF4 *ffb4, *pffb;
|
---|
| 715 | HDIR hDir;
|
---|
[763] | 716 | ULONG nm, fl = 0, ulM = FilesToGet;
|
---|
[551] | 717 | APIRET rc;
|
---|
[2] | 718 |
|
---|
[748] | 719 | if (!str || !*str) {
|
---|
| 720 | Runtime_Error(pszSrcFile, __LINE__, "no data");
|
---|
[2] | 721 | return;
|
---|
[748] | 722 | }
|
---|
| 723 |
|
---|
[763] | 724 | //if (!recurse)
|
---|
| 725 | // ulM = FilesToGet;
|
---|
[551] | 726 | maskstr = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
|
---|
| 727 | if (!maskstr)
|
---|
[2] | 728 | return;
|
---|
[551] | 729 | ffb4 = xmalloc(sizeof(FILEFINDBUF4) * ulM, pszSrcFile, __LINE__);
|
---|
| 730 | if (!ffb4) {
|
---|
[2] | 731 | free(maskstr);
|
---|
| 732 | return;
|
---|
| 733 | }
|
---|
| 734 | x = strlen(str);
|
---|
[551] | 735 | memcpy(maskstr, str, x + 1);
|
---|
[2] | 736 | enddir = maskstr + x;
|
---|
[551] | 737 | if (*(enddir - 1) != '\\') {
|
---|
[2] | 738 | *enddir = '\\';
|
---|
| 739 | enddir++;
|
---|
| 740 | *enddir = 0;
|
---|
| 741 | }
|
---|
| 742 | *enddir = '*';
|
---|
| 743 | *(enddir + 1) = 0;
|
---|
| 744 | hDir = HDIR_CREATE;
|
---|
| 745 | nm = ulM;
|
---|
[551] | 746 | if (recurse)
|
---|
[2] | 747 | fl = FILE_DIRECTORY;
|
---|
| 748 | DosError(FERR_DISABLEHARDERR);
|
---|
| 749 | rc = DosFindFirst(maskstr, &hDir,
|
---|
[551] | 750 | (FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
|
---|
| 751 | FILE_SYSTEM | FILE_HIDDEN) | fl,
|
---|
| 752 | ffb4, sizeof(FILEFINDBUF4) * nm, &nm, FIL_QUERYEASIZE);
|
---|
| 753 | if (!rc) {
|
---|
| 754 | while (!rc) {
|
---|
| 755 | fb = (BYTE *) ffb4;
|
---|
[2] | 756 | x = 0;
|
---|
[551] | 757 | while (x < nm) {
|
---|
| 758 | pffb = (FILEFINDBUF4 *) fb;
|
---|
| 759 | if (pffb->attrFile & FILE_DIRECTORY) {
|
---|
[517] | 760 | // Skip . and ..
|
---|
[551] | 761 | if (recurse &&
|
---|
[517] | 762 | (pffb->achName[0] != '.' ||
|
---|
| 763 | (pffb->achName[1] &&
|
---|
[551] | 764 | (pffb->achName[1] != '.' || pffb->achName[2])))) {
|
---|
| 765 | if (fForceUpper)
|
---|
| 766 | strupr(pffb->achName);
|
---|
| 767 | else if (fForceLower)
|
---|
| 768 | strlwr(pffb->achName);
|
---|
| 769 | memcpy(enddir, pffb->achName, pffb->cchName + 1);
|
---|
| 770 | FillDirList(maskstr, skiplen, recurse, list, numfiles, numalloc);
|
---|
| 771 | }
|
---|
| 772 | }
|
---|
| 773 | else {
|
---|
| 774 | if (fForceUpper)
|
---|
| 775 | strupr(pffb->achName);
|
---|
| 776 | else if (fForceLower)
|
---|
| 777 | strlwr(pffb->achName);
|
---|
| 778 | memcpy(enddir, pffb->achName, pffb->cchName + 1);
|
---|
| 779 | if (AddToFileList
|
---|
| 780 | (maskstr + skiplen, pffb, list, numfiles, numalloc))
|
---|
| 781 | goto Abort;
|
---|
| 782 | }
|
---|
| 783 | fb += pffb->oNextEntryOffset;
|
---|
| 784 | x++;
|
---|
[2] | 785 | }
|
---|
| 786 | nm = ulM;
|
---|
| 787 | DosError(FERR_DISABLEHARDERR);
|
---|
[551] | 788 | rc = DosFindNext(hDir, ffb4, sizeof(FILEFINDBUF4) * nm, &nm);
|
---|
[2] | 789 | }
|
---|
[551] | 790 | Abort:
|
---|
[2] | 791 | DosFindClose(hDir);
|
---|
[748] | 792 | DosSleep(1);
|
---|
[2] | 793 | }
|
---|
| 794 | free(maskstr);
|
---|
| 795 | free(ffb4);
|
---|
| 796 | }
|
---|
| 797 |
|
---|
[316] | 798 | //=== CompNames() Compare names for qsort ===
|
---|
[2] | 799 |
|
---|
[551] | 800 | static int CompNames(const void *n1, const void *n2)
|
---|
[316] | 801 | {
|
---|
[551] | 802 | FILELIST *fl1 = *(FILELIST **) n1;
|
---|
| 803 | FILELIST *fl2 = *(FILELIST **) n2;
|
---|
[2] | 804 |
|
---|
[551] | 805 | return stricmp(fl1->fname, fl2->fname);
|
---|
[2] | 806 | }
|
---|
| 807 |
|
---|
[316] | 808 | //=== FillCnrsThread() Fill left and right containers ===
|
---|
[2] | 809 |
|
---|
[751] | 810 | static VOID FillCnrsThread(VOID *args)
|
---|
[316] | 811 | {
|
---|
[551] | 812 | COMPARE *cmp = (COMPARE *) args;
|
---|
| 813 | HAB hab;
|
---|
| 814 | HMQ hmq;
|
---|
| 815 | BOOL notified = FALSE;
|
---|
[751] | 816 |
|
---|
[551] | 817 | HWND hwndLeft, hwndRight;
|
---|
[748] | 818 | CHAR szBuf[CCHMAXPATH];
|
---|
[763] | 819 | PSZ pszBuf = szBuf;
|
---|
[748] | 820 | CNRINFO cnri;
|
---|
[2] | 821 |
|
---|
[765] | 822 |
|
---|
[748] | 823 | if (!cmp) {
|
---|
| 824 | Runtime_Error(pszSrcFile, __LINE__, "no data");
|
---|
[2] | 825 | _endthread();
|
---|
[748] | 826 | }
|
---|
[2] | 827 |
|
---|
| 828 | DosError(FERR_DISABLEHARDERR);
|
---|
| 829 |
|
---|
| 830 | hab = WinInitialize(0);
|
---|
[551] | 831 | if (!hab)
|
---|
| 832 | Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__, "WinInitialize");
|
---|
[362] | 833 | else {
|
---|
[551] | 834 | hmq = WinCreateMsgQueue(hab, 0);
|
---|
| 835 | if (!hmq)
|
---|
| 836 | Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
|
---|
| 837 | "WinCreateMsgQueue");
|
---|
[362] | 838 | else {
|
---|
[551] | 839 | INT x;
|
---|
| 840 | INT l;
|
---|
| 841 | INT r;
|
---|
| 842 | ULONG cntr;
|
---|
| 843 | FILELIST **filesl = NULL;
|
---|
| 844 | FILELIST **filesr = NULL;
|
---|
| 845 | INT numfilesl = 0;
|
---|
| 846 | INT numfilesr = 0;
|
---|
| 847 | INT numallocl = 0;
|
---|
| 848 | INT numallocr = 0;
|
---|
[748] | 849 | INT lenl; // Directory prefix length
|
---|
[551] | 850 | INT lenr;
|
---|
[748] | 851 | UINT recsNeeded;
|
---|
[551] | 852 | PCNRITEM pcilFirst;
|
---|
| 853 | PCNRITEM pcirFirst;
|
---|
| 854 | PCNRITEM pcil;
|
---|
| 855 | PCNRITEM pcir;
|
---|
| 856 | RECORDINSERT ri;
|
---|
| 857 | CHAR *pch;
|
---|
[2] | 858 |
|
---|
[551] | 859 | WinCancelShutdown(hmq, TRUE);
|
---|
[535] | 860 | IncrThreadUsage();
|
---|
[551] | 861 | hwndLeft = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
|
---|
| 862 | hwndRight = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
|
---|
[2] | 863 | lenl = strlen(cmp->leftdir);
|
---|
[551] | 864 | if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
|
---|
| 865 | lenl++;
|
---|
[2] | 866 | lenr = strlen(cmp->rightdir);
|
---|
[551] | 867 | if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
|
---|
| 868 | lenr++;
|
---|
[2] | 869 | priority_normal();
|
---|
[748] | 870 | // Clear containers
|
---|
[751] | 871 | RemoveCnrItems(hwndRight, NULL, 0, CMA_FREE | CMA_INVALIDATE);
|
---|
| 872 | RemoveCnrItems(hwndLeft, NULL, 0, CMA_FREE | CMA_INVALIDATE);
|
---|
[2] | 873 | cmp->cmp->totalleft = cmp->cmp->totalright = 0;
|
---|
| 874 |
|
---|
[748] | 875 | // Build list of all files in left directory
|
---|
[551] | 876 | if (fForceLower)
|
---|
| 877 | strlwr(cmp->leftdir);
|
---|
| 878 | else if (fForceUpper)
|
---|
| 879 | strupr(cmp->leftdir);
|
---|
| 880 | FillDirList(cmp->leftdir, lenl, cmp->includesubdirs,
|
---|
| 881 | &filesl, &numfilesl, &numallocl);
|
---|
[2] | 882 |
|
---|
[551] | 883 | if (filesl)
|
---|
| 884 | qsort(filesl, numfilesl, sizeof(CHAR *), CompNames);
|
---|
[748] | 885 |
|
---|
| 886 | // Build list of all files in right directory
|
---|
[551] | 887 | if (!*cmp->rightlist) {
|
---|
| 888 | if (fForceLower)
|
---|
| 889 | strlwr(cmp->rightdir);
|
---|
| 890 | else if (fForceUpper)
|
---|
| 891 | strupr(cmp->rightdir);
|
---|
| 892 | FillDirList(cmp->rightdir, lenr, cmp->includesubdirs,
|
---|
| 893 | &filesr, &numfilesr, &numallocr);
|
---|
[2] | 894 | }
|
---|
[551] | 895 | else {
|
---|
[748] | 896 | // Use snapshot file
|
---|
[551] | 897 | FILE *fp;
|
---|
| 898 | FILEFINDBUF4 fb4;
|
---|
| 899 | CHAR str[CCHMAXPATH * 2], *p;
|
---|
[2] | 900 |
|
---|
[551] | 901 | memset(&fb4, 0, sizeof(fb4));
|
---|
| 902 | fp = fopen(cmp->rightlist, "r");
|
---|
| 903 | if (!fp)
|
---|
| 904 | Runtime_Error(pszSrcFile, __LINE__, "can not open %s (%d)",
|
---|
| 905 | cmp->rightlist, errno);
|
---|
[362] | 906 | else {
|
---|
[551] | 907 | while (!feof(fp)) {
|
---|
[748] | 908 | // First get name of directory
|
---|
[551] | 909 | if (!xfgets_bstripcr(str, sizeof(str), fp, pszSrcFile, __LINE__))
|
---|
| 910 | break; // EOF
|
---|
| 911 | p = str;
|
---|
| 912 | if (*p == '\"') {
|
---|
[748] | 913 | // Quoted
|
---|
[551] | 914 | p++;
|
---|
| 915 | if (*p && *p != '\"') {
|
---|
| 916 | p = strchr(p, '\"');
|
---|
| 917 | if (p) {
|
---|
| 918 | *p = 0;
|
---|
| 919 | if (*(str + 1)) {
|
---|
| 920 | strcpy(cmp->rightdir, str + 1);
|
---|
| 921 | if (fForceUpper)
|
---|
| 922 | strupr(cmp->rightdir);
|
---|
| 923 | else if (fForceLower)
|
---|
| 924 | strlwr(cmp->rightdir);
|
---|
| 925 | p = cmp->rightdir + (strlen(cmp->rightdir) - 1);
|
---|
| 926 | if (p - cmp->rightdir > 3 && *p == '\\')
|
---|
| 927 | *p = 0; // Chop trailing slash
|
---|
| 928 | break;
|
---|
| 929 | }
|
---|
| 930 | }
|
---|
| 931 | }
|
---|
| 932 | }
|
---|
[748] | 933 | } // while !EOF
|
---|
[2] | 934 |
|
---|
[748] | 935 | memset(&cnri, 0, sizeof(cnri));
|
---|
| 936 | cnri.cb = sizeof(cnri);
|
---|
| 937 | cnri.pszCnrTitle = cmp->rightdir;
|
---|
| 938 | if (!WinSendMsg(hwndRight, CM_SETCNRINFO,
|
---|
| 939 | MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE))) {
|
---|
| 940 | Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_SETCNRINFO");
|
---|
[551] | 941 | }
|
---|
[748] | 942 |
|
---|
[551] | 943 | if (*cmp->rightdir) {
|
---|
| 944 | lenr = strlen(cmp->rightdir) +
|
---|
| 945 | (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\');
|
---|
| 946 | while (!feof(fp)) {
|
---|
| 947 | if (!xfgets_bstripcr
|
---|
| 948 | (str, sizeof(str), fp, pszSrcFile, __LINE__))
|
---|
| 949 | break;
|
---|
| 950 | p = str;
|
---|
| 951 | if (*p == '\"') {
|
---|
| 952 | p++;
|
---|
| 953 | if (*p && *p != '\"') {
|
---|
| 954 | p = strchr(p, '\"');
|
---|
| 955 | if (p) {
|
---|
| 956 | *p = 0;
|
---|
| 957 | p++;
|
---|
| 958 | if (*p == ',') {
|
---|
| 959 | p++;
|
---|
| 960 | if (!cmp->includesubdirs && atol(p) > lenr)
|
---|
| 961 | continue;
|
---|
| 962 | p = strchr(p, ',');
|
---|
| 963 | if (p) {
|
---|
| 964 | p++;
|
---|
| 965 | fb4.cbFile = atol(p);
|
---|
| 966 | p = strchr(p, ',');
|
---|
| 967 | if (p) {
|
---|
| 968 | p++;
|
---|
| 969 | fb4.fdateLastWrite.year = atol(p) - 1980;
|
---|
| 970 | p = strchr(p, '/');
|
---|
| 971 | if (p) {
|
---|
| 972 | p++;
|
---|
| 973 | fb4.fdateLastWrite.month = atol(p);
|
---|
| 974 | p = strchr(p, '/');
|
---|
| 975 | if (p) {
|
---|
| 976 | p++;
|
---|
| 977 | fb4.fdateLastWrite.day = atol(p);
|
---|
| 978 | p = strchr(p, ',');
|
---|
| 979 | if (p) {
|
---|
| 980 | p++;
|
---|
| 981 | fb4.ftimeLastWrite.hours = atol(p);
|
---|
| 982 | p = strchr(p, ':');
|
---|
| 983 | if (p) {
|
---|
| 984 | p++;
|
---|
| 985 | fb4.ftimeLastWrite.minutes = atol(p);
|
---|
| 986 | p = strchr(p, ':');
|
---|
| 987 | if (p) {
|
---|
| 988 | p++;
|
---|
| 989 | fb4.ftimeLastWrite.twosecs = atol(p);
|
---|
| 990 | p = strchr(p, ',');
|
---|
| 991 | if (p) {
|
---|
| 992 | p++;
|
---|
| 993 | fb4.attrFile = atol(p);
|
---|
| 994 | p = strchr(p, ',');
|
---|
| 995 | if (p) {
|
---|
| 996 | p++;
|
---|
| 997 | fb4.cbList = atol(p) * 2;
|
---|
| 998 | if (fForceUpper)
|
---|
| 999 | strupr(str + 1);
|
---|
| 1000 | else if (fForceLower)
|
---|
| 1001 | strlwr(str + 1);
|
---|
| 1002 | if (AddToFileList((str + 1) + lenr,
|
---|
| 1003 | &fb4,
|
---|
| 1004 | &filesr,
|
---|
| 1005 | &numfilesr,
|
---|
| 1006 | &numallocr))
|
---|
| 1007 | break;
|
---|
| 1008 | }
|
---|
| 1009 | }
|
---|
| 1010 | }
|
---|
| 1011 | }
|
---|
| 1012 | }
|
---|
| 1013 | }
|
---|
| 1014 | }
|
---|
| 1015 | }
|
---|
| 1016 | }
|
---|
| 1017 | }
|
---|
| 1018 | }
|
---|
| 1019 | }
|
---|
| 1020 | }
|
---|
[748] | 1021 | } // while
|
---|
| 1022 | } // if have rightdir
|
---|
[551] | 1023 | fclose(fp);
|
---|
| 1024 | }
|
---|
[748] | 1025 | } // if snapshot file
|
---|
[316] | 1026 |
|
---|
[551] | 1027 | if (filesr)
|
---|
| 1028 | qsort(filesr, numfilesr, sizeof(CHAR *), CompNames);
|
---|
[2] | 1029 |
|
---|
[748] | 1030 | // We now have two lists of files, both sorted.
|
---|
| 1031 | // Count total number of container entries required on each side
|
---|
[2] | 1032 | l = r = 0;
|
---|
[316] | 1033 | recsNeeded = 0;
|
---|
[551] | 1034 | while ((filesl && filesl[l]) || (filesr && filesr[r])) {
|
---|
[748] | 1035 |
|
---|
| 1036 | if (filesl && filesl[l]) {
|
---|
| 1037 | if (filesr && filesr[r])
|
---|
| 1038 | x = stricmp(filesl[l]->fname, filesr[r]->fname);
|
---|
[551] | 1039 | else
|
---|
[748] | 1040 | x = -1; // Left side list longer
|
---|
[551] | 1041 | }
|
---|
[748] | 1042 | else
|
---|
| 1043 | x = +1; // Right side list longer
|
---|
| 1044 |
|
---|
| 1045 | if (x <= 0)
|
---|
| 1046 | l++; // On left side
|
---|
| 1047 | if (x >= 0)
|
---|
| 1048 | r++; // On right side
|
---|
| 1049 |
|
---|
| 1050 | recsNeeded++; // Keep count of how many entries req'd
|
---|
| 1051 |
|
---|
| 1052 | } // while
|
---|
| 1053 |
|
---|
[551] | 1054 | WinSendMsg(cmp->hwnd, UM_CONTAINERHWND, MPVOID, MPVOID);
|
---|
[748] | 1055 |
|
---|
| 1056 | // Now insert records into the containers
|
---|
[2] | 1057 | cntr = 0;
|
---|
| 1058 | l = r = 0;
|
---|
[551] | 1059 | if (recsNeeded) {
|
---|
| 1060 | pcilFirst = WinSendMsg(hwndLeft,
|
---|
| 1061 | CM_ALLOCRECORD,
|
---|
[751] | 1062 | MPFROMLONG(EXTRA_RECORD_BYTES),
|
---|
[551] | 1063 | MPFROMLONG(recsNeeded));
|
---|
| 1064 | if (!pcilFirst) {
|
---|
[742] | 1065 | Win_Error(hwndLeft, cmp->hwnd, pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
|
---|
| 1066 | recsNeeded);
|
---|
[551] | 1067 | recsNeeded = 0;
|
---|
| 1068 | }
|
---|
[316] | 1069 | }
|
---|
[362] | 1070 | if (recsNeeded) {
|
---|
[551] | 1071 | pcirFirst = WinSendMsg(hwndRight, CM_ALLOCRECORD,
|
---|
[751] | 1072 | MPFROMLONG(EXTRA_RECORD_BYTES),
|
---|
[551] | 1073 | MPFROMLONG(recsNeeded));
|
---|
| 1074 | if (!pcirFirst) {
|
---|
[742] | 1075 | Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
|
---|
| 1076 | recsNeeded);
|
---|
[551] | 1077 | recsNeeded = 0;
|
---|
[751] | 1078 | FreeCnrItemList(hwndLeft, pcilFirst);
|
---|
[551] | 1079 | }
|
---|
[2] | 1080 | }
|
---|
[748] | 1081 |
|
---|
[362] | 1082 | if (recsNeeded) {
|
---|
[748] | 1083 |
|
---|
[551] | 1084 | pcil = pcilFirst;
|
---|
| 1085 | pcir = pcirFirst;
|
---|
| 1086 | while ((filesl && filesl[l]) || (filesr && filesr[r])) {
|
---|
| 1087 | pcir->hwndCnr = hwndRight;
|
---|
[748] | 1088 | pcir->rc.hptrIcon = (HPOINTER) 0;
|
---|
[551] | 1089 | pcil->hwndCnr = hwndLeft;
|
---|
| 1090 | pcil->rc.hptrIcon = (HPOINTER) 0;
|
---|
[748] | 1091 |
|
---|
| 1092 | if (filesl && filesl[l]) {
|
---|
| 1093 | if (filesr && filesr[r])
|
---|
| 1094 | x = stricmp(filesl[l]->fname, filesr[r]->fname);
|
---|
| 1095 | else
|
---|
| 1096 | x = -1; // Left side list longer
|
---|
| 1097 | }
|
---|
| 1098 | else
|
---|
| 1099 | x = +1; // Right side list longer
|
---|
| 1100 |
|
---|
| 1101 | if (x <= 0) {
|
---|
[763] | 1102 | // File appears on left side
|
---|
| 1103 | BldFullPathName(pszBuf, cmp->leftdir, filesl[l]->fname);
|
---|
| 1104 | //sprintf(szBuf, "%s%s%s", cmp->leftdir,
|
---|
| 1105 | // (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ?
|
---|
| 1106 | // NullStr : "\\", filesl[l]->fname);
|
---|
[765] | 1107 | pcil->pszFileName = xstrdup(pszBuf, pszSrcFile, __LINE__);
|
---|
[748] | 1108 | pcil->pszDisplayName = pcil->pszFileName + lenl;
|
---|
| 1109 | pcil->attrFile = filesl[l]->attrFile;
|
---|
[751] | 1110 | pcil->pszDispAttr = FileAttrToString(pcil->attrFile);
|
---|
[748] | 1111 | pcil->cbFile = filesl[l]->cbFile;
|
---|
| 1112 | pcil->easize = filesl[l]->easize;
|
---|
| 1113 | pcil->date.day = filesl[l]->date.day;
|
---|
| 1114 | pcil->date.month = filesl[l]->date.month;
|
---|
| 1115 | pcil->date.year = filesl[l]->date.year + 1980;
|
---|
| 1116 | pcil->time.seconds = filesl[l]->time.twosecs * 2;
|
---|
| 1117 | pcil->time.minutes = filesl[l]->time.minutes;
|
---|
| 1118 | pcil->time.hours = filesl[l]->time.hours;
|
---|
| 1119 | pcil->ladate.day = filesl[l]->ladate.day;
|
---|
| 1120 | pcil->ladate.month = filesl[l]->ladate.month;
|
---|
| 1121 | pcil->ladate.year = filesl[l]->ladate.year + 1980;
|
---|
| 1122 | pcil->latime.seconds = filesl[l]->latime.twosecs * 2;
|
---|
| 1123 | pcil->latime.minutes = filesl[l]->latime.minutes;
|
---|
| 1124 | pcil->latime.hours = filesl[l]->latime.hours;
|
---|
| 1125 | pcil->crdate.day = filesl[l]->crdate.day;
|
---|
| 1126 | pcil->crdate.month = filesl[l]->crdate.month;
|
---|
| 1127 | pcil->crdate.year = filesl[l]->crdate.year + 1980;
|
---|
| 1128 | pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2;
|
---|
| 1129 | pcil->crtime.minutes = filesl[l]->crtime.minutes;
|
---|
| 1130 | pcil->crtime.hours = filesl[l]->crtime.hours;
|
---|
| 1131 | if (*cmp->dcd.mask.szMask) {
|
---|
| 1132 | if (!Filter((PMINIRECORDCORE) pcil, (PVOID)&cmp->dcd.mask)) {
|
---|
| 1133 | pcil->rc.flRecordAttr |= CRA_FILTERED;
|
---|
| 1134 | pcir->rc.flRecordAttr |= CRA_FILTERED;
|
---|
| 1135 | }
|
---|
| 1136 | }
|
---|
| 1137 | pcil->flags |= CNRITEM_EXISTS;
|
---|
| 1138 | } // if on left
|
---|
| 1139 |
|
---|
| 1140 | if (x >= 0) {
|
---|
[763] | 1141 | // File appears on right side
|
---|
[765] | 1142 | //BldFullPathName(pszBuf, cmp->rightdir, filesl[r]->fname);
|
---|
| 1143 | sprintf(szBuf, "%s%s%s", cmp->rightdir,
|
---|
| 1144 | (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ?
|
---|
| 1145 | NullStr : "\\", filesr[r]->fname);
|
---|
| 1146 | pcir->pszFileName = xstrdup(pszBuf, pszSrcFile, __LINE__); // 31 Jul 07 SHL
|
---|
[748] | 1147 | pcir->pszDisplayName = pcir->pszFileName + lenr;
|
---|
| 1148 | pcir->attrFile = filesr[r]->attrFile;
|
---|
| 1149 | // pcir->rc.hptrIcon = hptrFile;
|
---|
[751] | 1150 | pcir->pszDispAttr = FileAttrToString(pcir->attrFile);
|
---|
[748] | 1151 | pcir->cbFile = filesr[r]->cbFile;
|
---|
| 1152 | pcir->easize = filesr[r]->easize;
|
---|
| 1153 | pcir->date.day = filesr[r]->date.day;
|
---|
| 1154 | pcir->date.month = filesr[r]->date.month;
|
---|
| 1155 | pcir->date.year = filesr[r]->date.year + 1980;
|
---|
| 1156 | pcir->time.seconds = filesr[r]->time.twosecs * 2;
|
---|
| 1157 | pcir->time.minutes = filesr[r]->time.minutes;
|
---|
| 1158 | pcir->time.hours = filesr[r]->time.hours;
|
---|
| 1159 | pcir->ladate.day = filesr[r]->ladate.day;
|
---|
| 1160 | pcir->ladate.month = filesr[r]->ladate.month;
|
---|
| 1161 | pcir->ladate.year = filesr[r]->ladate.year + 1980;
|
---|
| 1162 | pcir->latime.seconds = filesr[r]->latime.twosecs * 2;
|
---|
| 1163 | pcir->latime.minutes = filesr[r]->latime.minutes;
|
---|
| 1164 | pcir->latime.hours = filesr[r]->latime.hours;
|
---|
| 1165 | pcir->crdate.day = filesr[r]->crdate.day;
|
---|
| 1166 | pcir->crdate.month = filesr[r]->crdate.month;
|
---|
| 1167 | pcir->crdate.year = filesr[r]->crdate.year + 1980;
|
---|
| 1168 | pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2;
|
---|
| 1169 | pcir->crtime.minutes = filesr[r]->crtime.minutes;
|
---|
| 1170 | pcir->crtime.hours = filesr[r]->crtime.hours;
|
---|
| 1171 | if (~pcil->rc.flRecordAttr & CRA_FILTERED &&
|
---|
| 1172 | *cmp->dcd.mask.szMask) {
|
---|
| 1173 | if (!Filter((PMINIRECORDCORE)pcir, (PVOID)&cmp->dcd.mask)) {
|
---|
| 1174 | pcil->rc.flRecordAttr |= CRA_FILTERED;
|
---|
| 1175 | pcir->rc.flRecordAttr |= CRA_FILTERED;
|
---|
| 1176 | }
|
---|
| 1177 | }
|
---|
| 1178 | pcir->flags |= CNRITEM_EXISTS;
|
---|
| 1179 | } // if on right
|
---|
| 1180 |
|
---|
| 1181 | if (x == 0) {
|
---|
| 1182 | // File appears on both sides
|
---|
[765] | 1183 | pch = pszBuf;
|
---|
[748] | 1184 | // Subject field holds status messages
|
---|
| 1185 | *pch = 0;
|
---|
| 1186 | if (pcil->cbFile + pcil->easize > pcir->cbFile + pcir->easize) {
|
---|
| 1187 | pcil->flags |= CNRITEM_LARGER;
|
---|
| 1188 | pcir->flags |= CNRITEM_SMALLER;
|
---|
| 1189 | strcpy(pch, GetPString(IDS_LARGERTEXT));
|
---|
| 1190 | pch += 6;
|
---|
| 1191 | }
|
---|
| 1192 | else if (pcil->cbFile + pcil->easize <
|
---|
| 1193 | pcir->cbFile + pcir->easize) {
|
---|
| 1194 | pcil->flags |= CNRITEM_SMALLER;
|
---|
| 1195 | pcir->flags |= CNRITEM_LARGER;
|
---|
| 1196 | strcpy(pch, GetPString(IDS_SMALLERTEXT));
|
---|
| 1197 | pch += 7;
|
---|
| 1198 | }
|
---|
| 1199 | if ((pcil->date.year > pcir->date.year) ? TRUE :
|
---|
| 1200 | (pcil->date.year < pcir->date.year) ? FALSE :
|
---|
| 1201 | (pcil->date.month > pcir->date.month) ? TRUE :
|
---|
| 1202 | (pcil->date.month < pcir->date.month) ? FALSE :
|
---|
| 1203 | (pcil->date.day > pcir->date.day) ? TRUE :
|
---|
| 1204 | (pcil->date.day < pcir->date.day) ? FALSE :
|
---|
| 1205 | (pcil->time.hours > pcir->time.hours) ? TRUE :
|
---|
| 1206 | (pcil->time.hours < pcir->time.hours) ? FALSE :
|
---|
| 1207 | (pcil->time.minutes > pcir->time.minutes) ? TRUE :
|
---|
| 1208 | (pcil->time.minutes < pcir->time.minutes) ? FALSE :
|
---|
| 1209 | (pcil->time.seconds > pcir->time.seconds) ? TRUE :
|
---|
| 1210 | (pcil->time.seconds < pcir->time.seconds) ? FALSE : FALSE) {
|
---|
| 1211 | pcil->flags |= CNRITEM_NEWER;
|
---|
| 1212 | pcir->flags |= CNRITEM_OLDER;
|
---|
[765] | 1213 | if (pch != pszBuf) {
|
---|
[748] | 1214 | strcpy(pch, ", ");
|
---|
| 1215 | pch += 2;
|
---|
| 1216 | }
|
---|
| 1217 | strcpy(pch, GetPString(IDS_NEWERTEXT));
|
---|
| 1218 | pch += 5;
|
---|
| 1219 | }
|
---|
| 1220 | else if ((pcil->date.year < pcir->date.year) ? TRUE :
|
---|
| 1221 | (pcil->date.year > pcir->date.year) ? FALSE :
|
---|
| 1222 | (pcil->date.month < pcir->date.month) ? TRUE :
|
---|
| 1223 | (pcil->date.month > pcir->date.month) ? FALSE :
|
---|
| 1224 | (pcil->date.day < pcir->date.day) ? TRUE :
|
---|
| 1225 | (pcil->date.day > pcir->date.day) ? FALSE :
|
---|
| 1226 | (pcil->time.hours < pcir->time.hours) ? TRUE :
|
---|
| 1227 | (pcil->time.hours > pcir->time.hours) ? FALSE :
|
---|
| 1228 | (pcil->time.minutes < pcir->time.minutes) ? TRUE :
|
---|
| 1229 | (pcil->time.minutes > pcir->time.minutes) ? FALSE :
|
---|
| 1230 | (pcil->time.seconds < pcir->time.seconds) ? TRUE :
|
---|
| 1231 | (pcil->time.seconds > pcir->time.seconds) ? FALSE :
|
---|
| 1232 | FALSE) {
|
---|
| 1233 | pcil->flags |= CNRITEM_OLDER;
|
---|
| 1234 | pcir->flags |= CNRITEM_NEWER;
|
---|
[765] | 1235 | if (pch != pszBuf) {
|
---|
[748] | 1236 | strcpy(pch, ", ");
|
---|
| 1237 | pch += 2;
|
---|
| 1238 | }
|
---|
| 1239 | strcpy(pch, GetPString(IDS_OLDERTEXT));
|
---|
| 1240 | pch += 5;
|
---|
| 1241 | }
|
---|
[751] | 1242 | // fixme to know why not displayed - defect?
|
---|
[765] | 1243 | pcil->pszSubject = pszBuf ?
|
---|
| 1244 | xstrdup(pszBuf, pszSrcFile, __LINE__) :
|
---|
[751] | 1245 | NullStr;
|
---|
[748] | 1246 |
|
---|
| 1247 | } // if on both sides
|
---|
| 1248 |
|
---|
| 1249 | if (x <= 0) {
|
---|
| 1250 | free(filesl[l]);
|
---|
| 1251 | l++;
|
---|
| 1252 | }
|
---|
| 1253 |
|
---|
| 1254 | if (x >= 0) {
|
---|
| 1255 | free(filesr[r]);
|
---|
| 1256 | r++;
|
---|
| 1257 | }
|
---|
| 1258 |
|
---|
| 1259 | // Ensure empty buffers point somewhere
|
---|
| 1260 | if (!pcil->pszFileName) {
|
---|
| 1261 | pcil->pszFileName = NullStr;
|
---|
| 1262 | pcil->pszDisplayName = pcil->pszFileName;
|
---|
| 1263 | }
|
---|
| 1264 |
|
---|
| 1265 | if (!pcir->pszFileName) {
|
---|
| 1266 | pcir->pszFileName = NullStr;
|
---|
| 1267 | pcir->pszDisplayName = pcir->pszFileName;
|
---|
| 1268 | }
|
---|
| 1269 |
|
---|
[751] | 1270 | pcil->rc.pszIcon = pcil->pszDisplayName;
|
---|
| 1271 | pcir->rc.pszIcon = pcir->pszDisplayName;
|
---|
[748] | 1272 |
|
---|
[762] | 1273 | pcil->pszLongName = NullStr;
|
---|
| 1274 | pcir->pszLongName = NullStr;
|
---|
[751] | 1275 |
|
---|
[748] | 1276 | if (!pcil->pszSubject)
|
---|
| 1277 | pcil->pszSubject = NullStr;
|
---|
| 1278 | if (!pcir->pszSubject)
|
---|
| 1279 | pcil->pszSubject = NullStr;
|
---|
| 1280 |
|
---|
[751] | 1281 | if (!pcil->pszDispAttr)
|
---|
| 1282 | pcil->pszDispAttr = NullStr;
|
---|
| 1283 | if (!pcir->pszDispAttr)
|
---|
| 1284 | pcil->pszDispAttr = NullStr;
|
---|
| 1285 |
|
---|
[748] | 1286 | // fixme to be time based - every 2 sec should be OK
|
---|
[551] | 1287 | if (!(cntr % 500))
|
---|
[748] | 1288 | DosSleep(1);
|
---|
[551] | 1289 | else if (!(cntr % 50))
|
---|
[748] | 1290 | DosSleep(1);
|
---|
| 1291 |
|
---|
[551] | 1292 | cntr++;
|
---|
[748] | 1293 |
|
---|
[551] | 1294 | pcil = (PCNRITEM) pcil->rc.preccNextRecord;
|
---|
| 1295 | pcir = (PCNRITEM) pcir->rc.preccNextRecord;
|
---|
[748] | 1296 |
|
---|
| 1297 | } // while filling left or right
|
---|
| 1298 |
|
---|
[551] | 1299 | if (filesl)
|
---|
| 1300 | free(filesl); // Free header - have already freed elements
|
---|
| 1301 | filesl = NULL;
|
---|
| 1302 | if (filesr)
|
---|
| 1303 | free(filesr);
|
---|
| 1304 | filesr = NULL;
|
---|
[748] | 1305 | // Insert 'em
|
---|
[551] | 1306 | WinSendMsg(cmp->hwnd, UM_CONTAINERDIR, MPVOID, MPVOID);
|
---|
[748] | 1307 |
|
---|
[551] | 1308 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
| 1309 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 1310 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
| 1311 | ri.pRecordParent = (PRECORDCORE) NULL;
|
---|
| 1312 | ri.zOrder = (ULONG) CMA_TOP;
|
---|
| 1313 | ri.cRecordsInsert = recsNeeded;
|
---|
| 1314 | ri.fInvalidateRecord = FALSE;
|
---|
| 1315 | if (!WinSendMsg(hwndLeft, CM_INSERTRECORD,
|
---|
| 1316 | MPFROMP(pcilFirst), MPFROMP(&ri))) {
|
---|
[742] | 1317 | Win_Error(hwndLeft, cmp->hwnd, pszSrcFile, __LINE__, "CM_INSERTRECORD");
|
---|
[751] | 1318 | FreeCnrItemList(hwndLeft, pcilFirst);
|
---|
[551] | 1319 | numfilesl = 0;
|
---|
| 1320 | }
|
---|
[748] | 1321 |
|
---|
[551] | 1322 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
| 1323 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 1324 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
| 1325 | ri.pRecordParent = (PRECORDCORE) NULL;
|
---|
| 1326 | ri.zOrder = (ULONG) CMA_TOP;
|
---|
| 1327 | ri.cRecordsInsert = recsNeeded;
|
---|
| 1328 | ri.fInvalidateRecord = FALSE;
|
---|
[751] | 1329 |
|
---|
[551] | 1330 | if (!WinSendMsg(hwndRight, CM_INSERTRECORD,
|
---|
| 1331 | MPFROMP(pcirFirst), MPFROMP(&ri))) {
|
---|
[751] | 1332 | Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_INSERTRECORD");
|
---|
| 1333 | RemoveCnrItems(hwndLeft, NULL, 0, CMA_FREE | CMA_INVALIDATE);
|
---|
| 1334 | FreeCnrItemList(hwndRight, pcirFirst);
|
---|
[551] | 1335 | numfilesr = 0;
|
---|
| 1336 | }
|
---|
[748] | 1337 |
|
---|
[551] | 1338 | cmp->cmp->totalleft = numfilesl;
|
---|
| 1339 | cmp->cmp->totalright = numfilesr;
|
---|
[748] | 1340 |
|
---|
| 1341 | } // if recsNeeded
|
---|
| 1342 |
|
---|
[2] | 1343 | Deselect(hwndLeft);
|
---|
| 1344 | Deselect(hwndRight);
|
---|
[748] | 1345 |
|
---|
[551] | 1346 | if (!PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID))
|
---|
| 1347 | WinSendMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
|
---|
[2] | 1348 | notified = TRUE;
|
---|
[748] | 1349 |
|
---|
[362] | 1350 | if (filesl)
|
---|
[748] | 1351 | FreeList((CHAR **)filesl); // Must have failed to create container
|
---|
[362] | 1352 | if (filesr)
|
---|
[748] | 1353 | FreeList((CHAR **)filesr);
|
---|
| 1354 |
|
---|
[2] | 1355 | WinDestroyMsgQueue(hmq);
|
---|
| 1356 | }
|
---|
[535] | 1357 | DecrThreadUsage();
|
---|
[2] | 1358 | WinTerminate(hab);
|
---|
| 1359 | }
|
---|
[362] | 1360 | if (!notified)
|
---|
[551] | 1361 | PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
|
---|
[2] | 1362 | free(cmp);
|
---|
| 1363 | DosPostEventSem(CompactSem);
|
---|
| 1364 | }
|
---|
| 1365 |
|
---|
| 1366 | #define hwndLeft (WinWindowFromID(hwnd,COMP_LEFTDIR))
|
---|
| 1367 | #define hwndRight (WinWindowFromID(hwnd,COMP_RIGHTDIR))
|
---|
| 1368 |
|
---|
[316] | 1369 | //=== CompareDlgProc() Compare directories dialog procedure ===
|
---|
[2] | 1370 |
|
---|
[551] | 1371 | MRESULT EXPENTRY CompareDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[316] | 1372 | {
|
---|
[551] | 1373 | COMPARE *cmp;
|
---|
[362] | 1374 |
|
---|
[551] | 1375 | static HPOINTER hptr = (HPOINTER) 0;
|
---|
[2] | 1376 |
|
---|
[551] | 1377 | switch (msg) {
|
---|
| 1378 | case WM_INITDLG:
|
---|
| 1379 | cmp = (COMPARE *) mp2;
|
---|
| 1380 | if (!cmp) {
|
---|
| 1381 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 1382 | WinDismissDlg(hwnd, 0);
|
---|
| 1383 | }
|
---|
| 1384 | else {
|
---|
| 1385 | if (!hptr)
|
---|
| 1386 | hptr = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, COMPARE_ICON);
|
---|
| 1387 | WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(hptr), MPVOID);
|
---|
| 1388 | cmp->hwnd = hwnd;
|
---|
| 1389 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) cmp);
|
---|
| 1390 | SetCnrCols(hwndLeft, TRUE);
|
---|
| 1391 | SetCnrCols(hwndRight, TRUE);
|
---|
| 1392 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 1393 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 1394 | PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
|
---|
| 1395 | {
|
---|
| 1396 | USHORT ids[] = { COMP_LEFTDIR, COMP_RIGHTDIR, COMP_TOTALLEFT,
|
---|
[751] | 1397 | COMP_TOTALRIGHT, COMP_SELLEFT, COMP_SELRIGHT,
|
---|
| 1398 | 0
|
---|
| 1399 | };
|
---|
| 1400 | INT x;
|
---|
[2] | 1401 |
|
---|
[551] | 1402 | for (x = 0; ids[x]; x++)
|
---|
| 1403 | SetPresParams(WinWindowFromID(hwnd, ids[x]),
|
---|
| 1404 | &RGBGREY,
|
---|
| 1405 | &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVTEXT));
|
---|
[2] | 1406 | }
|
---|
[551] | 1407 | }
|
---|
| 1408 | break;
|
---|
[2] | 1409 |
|
---|
[551] | 1410 | case UM_STRETCH:
|
---|
| 1411 | {
|
---|
| 1412 | SWP swp, swpC;
|
---|
| 1413 | LONG titl, szbx, szby, sz;
|
---|
| 1414 | HWND hwndActive;
|
---|
[2] | 1415 |
|
---|
[551] | 1416 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 1417 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
|
---|
| 1418 | hwndActive = WinQueryFocus(HWND_DESKTOP);
|
---|
| 1419 | szbx = SysVal(SV_CXSIZEBORDER);
|
---|
| 1420 | szby = SysVal(SV_CYSIZEBORDER);
|
---|
| 1421 | titl = SysVal(SV_CYTITLEBAR);
|
---|
| 1422 | titl += 26;
|
---|
| 1423 | swp.cx -= (szbx * 2);
|
---|
| 1424 | sz = (swp.cx / 8);
|
---|
| 1425 | WinQueryWindowPos(WinWindowFromID(hwnd, COMP_LEFTDIR), &swpC);
|
---|
| 1426 | WinSetWindowPos(WinWindowFromID(hwnd, COMP_LEFTDIR), HWND_TOP,
|
---|
| 1427 | szbx + 6,
|
---|
| 1428 | swpC.y,
|
---|
| 1429 | (swp.cx / 2) - (szbx + 6),
|
---|
| 1430 | ((swp.cy - swpC.y) - titl) - szby,
|
---|
| 1431 | SWP_MOVE | SWP_SIZE);
|
---|
| 1432 | WinSetWindowPos(WinWindowFromID(hwnd, COMP_RIGHTDIR), HWND_TOP,
|
---|
| 1433 | (swp.cx / 2) + (szbx + 6),
|
---|
| 1434 | swpC.y,
|
---|
| 1435 | (swp.cx / 2) - (szbx + 6),
|
---|
| 1436 | ((swp.cy - swpC.y) - titl) - szby,
|
---|
| 1437 | SWP_MOVE | SWP_SIZE);
|
---|
| 1438 | WinSetWindowPos(WinWindowFromID(hwnd, COMP_TOTALLEFTHDR), HWND_TOP,
|
---|
| 1439 | szbx + 6,
|
---|
| 1440 | ((swp.cy - titl) - szby) + 4,
|
---|
| 1441 | sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
|
---|
| 1442 | WinSetWindowPos(WinWindowFromID(hwnd, COMP_TOTALLEFT), HWND_TOP,
|
---|
| 1443 | sz + (szbx + 6),
|
---|
| 1444 | ((swp.cy - titl) - szby) + 4,
|
---|
| 1445 | sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
|
---|
| 1446 | WinSetWindowPos(WinWindowFromID(hwnd, COMP_SELLEFTHDR), HWND_TOP,
|
---|
| 1447 | (sz * 2) + (szbx + 6),
|
---|
| 1448 | ((swp.cy - titl) - szby) + 4,
|
---|
| 1449 | sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
|
---|
| 1450 | WinSetWindowPos(WinWindowFromID(hwnd, COMP_SELLEFT), HWND_TOP,
|
---|
| 1451 | (sz * 3) + (szbx + 6),
|
---|
| 1452 | ((swp.cy - titl) - szby) + 4,
|
---|
| 1453 | sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
|
---|
| 1454 | WinSetWindowPos(WinWindowFromID(hwnd, COMP_TOTALRIGHTHDR), HWND_TOP,
|
---|
| 1455 | (sz * 4) + (szbx + 6),
|
---|
| 1456 | ((swp.cy - titl) - szby) + 4,
|
---|
| 1457 | sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
|
---|
| 1458 | WinSetWindowPos(WinWindowFromID(hwnd, COMP_TOTALRIGHT), HWND_TOP,
|
---|
| 1459 | (sz * 5) + (szbx + 6),
|
---|
| 1460 | ((swp.cy - titl) - szby) + 4,
|
---|
| 1461 | sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
|
---|
| 1462 | WinSetWindowPos(WinWindowFromID(hwnd, COMP_SELRIGHTHDR), HWND_TOP,
|
---|
| 1463 | (sz * 6) + (szbx + 6),
|
---|
| 1464 | ((swp.cy - titl) - szby) + 4,
|
---|
| 1465 | sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
|
---|
| 1466 | WinSetWindowPos(WinWindowFromID(hwnd, COMP_SELRIGHT), HWND_TOP,
|
---|
| 1467 | (sz * 7) + (szbx + 6),
|
---|
| 1468 | ((swp.cy - titl) - szby) + 4,
|
---|
| 1469 | sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
|
---|
| 1470 | PaintRecessedWindow(WinWindowFromID(hwnd, COMP_TOTALLEFT),
|
---|
| 1471 | (HPS) 0, FALSE, FALSE);
|
---|
| 1472 | PaintRecessedWindow(WinWindowFromID(hwnd, COMP_SELLEFT),
|
---|
| 1473 | (HPS) 0, FALSE, FALSE);
|
---|
| 1474 | PaintRecessedWindow(WinWindowFromID(hwnd, COMP_TOTALRIGHT),
|
---|
| 1475 | (HPS) 0, FALSE, FALSE);
|
---|
| 1476 | PaintRecessedWindow(WinWindowFromID(hwnd, COMP_SELRIGHT),
|
---|
| 1477 | (HPS) 0, FALSE, FALSE);
|
---|
| 1478 | PaintRecessedWindow(hwndLeft, (HPS) 0,
|
---|
| 1479 | (hwndActive == hwndLeft), TRUE);
|
---|
| 1480 | PaintRecessedWindow(hwndRight, (HPS) 0,
|
---|
| 1481 | (hwndActive == hwndRight), TRUE);
|
---|
[2] | 1482 | }
|
---|
[551] | 1483 | }
|
---|
| 1484 | return 0;
|
---|
[2] | 1485 |
|
---|
[551] | 1486 | case WM_ADJUSTWINDOWPOS:
|
---|
| 1487 | PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
|
---|
| 1488 | break;
|
---|
[2] | 1489 |
|
---|
[551] | 1490 | case UM_SETUP:
|
---|
| 1491 | {
|
---|
| 1492 | CNRINFO cnri;
|
---|
| 1493 | BOOL tempsubj;
|
---|
[2] | 1494 |
|
---|
[551] | 1495 | cmp = INSTDATA(hwnd);
|
---|
| 1496 | if (cmp) {
|
---|
| 1497 | cmp->dcd.size = sizeof(DIRCNRDATA);
|
---|
| 1498 | cmp->dcd.type = DIR_FRAME;
|
---|
| 1499 | cmp->dcd.hwndFrame = hwnd;
|
---|
| 1500 | cmp->dcd.hwndClient = hwnd;
|
---|
| 1501 | cmp->dcd.mask.attrFile = (FILE_DIRECTORY | FILE_ARCHIVED |
|
---|
| 1502 | FILE_READONLY | FILE_SYSTEM | FILE_HIDDEN);
|
---|
| 1503 | LoadDetailsSwitches("DirCmp", &cmp->dcd);
|
---|
| 1504 | cmp->dcd.detailslongname = FALSE;
|
---|
[748] | 1505 | cmp->dcd.detailsicon = FALSE; // TRUE;
|
---|
[2] | 1506 | }
|
---|
[551] | 1507 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
| 1508 | cnri.cb = sizeof(CNRINFO);
|
---|
| 1509 | WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_QUERYCNRINFO,
|
---|
| 1510 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
| 1511 | cnri.flWindowAttr |= (CA_OWNERDRAW | CV_MINI);
|
---|
| 1512 | cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 68;
|
---|
| 1513 | WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
|
---|
| 1514 | MPFROMLONG(CMA_FLWINDOWATTR | CMA_XVERTSPLITBAR));
|
---|
| 1515 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
| 1516 | cnri.cb = sizeof(CNRINFO);
|
---|
| 1517 | WinSendDlgItemMsg(hwnd, COMP_RIGHTDIR, CM_QUERYCNRINFO,
|
---|
| 1518 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
| 1519 | cnri.flWindowAttr |= (CA_OWNERDRAW | CV_MINI);
|
---|
| 1520 | cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 54;
|
---|
| 1521 | WinSendDlgItemMsg(hwnd, COMP_RIGHTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
|
---|
| 1522 | MPFROMLONG(CMA_FLWINDOWATTR | CMA_XVERTSPLITBAR));
|
---|
| 1523 | AdjustCnrColRO(hwndLeft, GetPString(IDS_FILENAMECOLTEXT), TRUE, FALSE);
|
---|
| 1524 | AdjustCnrColRO(hwndLeft, GetPString(IDS_LONGNAMECOLTEXT), TRUE, FALSE);
|
---|
| 1525 | AdjustCnrColRO(hwndRight, GetPString(IDS_FILENAMECOLTEXT), TRUE, FALSE);
|
---|
| 1526 | AdjustCnrColRO(hwndRight, GetPString(IDS_LONGNAMECOLTEXT), TRUE, FALSE);
|
---|
| 1527 | AdjustCnrColsForPref(hwndLeft, cmp->leftdir, &cmp->dcd, TRUE);
|
---|
| 1528 | tempsubj = cmp->dcd.detailssubject;
|
---|
| 1529 | cmp->dcd.detailssubject = FALSE;
|
---|
| 1530 | AdjustCnrColsForPref(hwndRight, cmp->rightdir, &cmp->dcd, TRUE);
|
---|
| 1531 | if (*cmp->rightlist) {
|
---|
| 1532 | AdjustCnrColVis(hwndRight, GetPString(IDS_LADATECOLTEXT), FALSE,
|
---|
| 1533 | FALSE);
|
---|
| 1534 | AdjustCnrColVis(hwndRight, GetPString(IDS_LATIMECOLTEXT), FALSE,
|
---|
| 1535 | FALSE);
|
---|
| 1536 | AdjustCnrColVis(hwndRight, GetPString(IDS_CRDATECOLTEXT), FALSE,
|
---|
| 1537 | FALSE);
|
---|
| 1538 | AdjustCnrColVis(hwndRight, GetPString(IDS_CRTIMECOLTEXT), FALSE,
|
---|
| 1539 | FALSE);
|
---|
| 1540 | }
|
---|
| 1541 | cmp->dcd.detailssubject = tempsubj;
|
---|
| 1542 | }
|
---|
| 1543 | return 0;
|
---|
[2] | 1544 |
|
---|
[551] | 1545 | case WM_DRAWITEM:
|
---|
| 1546 | if (mp2) {
|
---|
[748] | 1547 | POWNERITEM pown = (POWNERITEM)mp2;
|
---|
[551] | 1548 | PCNRDRAWITEMINFO pcown;
|
---|
| 1549 | PCNRITEM pci;
|
---|
[2] | 1550 |
|
---|
[748] | 1551 | pcown = (PCNRDRAWITEMINFO)pown->hItem;
|
---|
[551] | 1552 | if (pcown) {
|
---|
| 1553 | pci = (PCNRITEM) pcown->pRecord;
|
---|
[748] | 1554 | // 01 Aug 07 SHL if field null or blank, we draw
|
---|
| 1555 | // fixme to know why - probably to optimize and bypass draw?
|
---|
| 1556 | if (pci && (INT)pci != -1 && !*pci->pszFileName)
|
---|
[551] | 1557 | return MRFROMLONG(TRUE);
|
---|
[2] | 1558 | }
|
---|
[551] | 1559 | }
|
---|
| 1560 | return 0;
|
---|
[2] | 1561 |
|
---|
[551] | 1562 | case UM_CONTAINERHWND:
|
---|
| 1563 | WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPHOLDBLDLISTTEXT));
|
---|
| 1564 | return 0;
|
---|
[2] | 1565 |
|
---|
[551] | 1566 | case UM_CONTAINERDIR:
|
---|
| 1567 | WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPHOLDFILLCNRTEXT));
|
---|
| 1568 | return 0;
|
---|
[2] | 1569 |
|
---|
[551] | 1570 | case UM_CONTAINER_FILLED:
|
---|
| 1571 | cmp = INSTDATA(hwnd);
|
---|
| 1572 | if (!cmp) {
|
---|
| 1573 | Runtime_Error(pszSrcFile, __LINE__, "pCompare NULL");
|
---|
| 1574 | WinDismissDlg(hwnd, 0);
|
---|
| 1575 | }
|
---|
| 1576 | else {
|
---|
| 1577 | CHAR s[81];
|
---|
| 1578 |
|
---|
| 1579 | cmp->filling = FALSE;
|
---|
| 1580 | WinEnableWindow(hwndLeft, TRUE);
|
---|
| 1581 | WinEnableWindow(hwndRight, TRUE);
|
---|
| 1582 | WinEnableWindowUpdate(hwndLeft, TRUE);
|
---|
| 1583 | WinEnableWindowUpdate(hwndRight, TRUE);
|
---|
| 1584 | sprintf(s, " %d", cmp->totalleft);
|
---|
| 1585 | WinSetDlgItemText(hwnd, COMP_TOTALLEFT, s);
|
---|
| 1586 | sprintf(s, " %d", cmp->totalright);
|
---|
| 1587 | WinSetDlgItemText(hwnd, COMP_TOTALRIGHT, s);
|
---|
| 1588 | sprintf(s, " %d", cmp->selleft);
|
---|
| 1589 | WinSetDlgItemText(hwnd, COMP_SELLEFT, s);
|
---|
| 1590 | sprintf(s, " %d", cmp->selright);
|
---|
| 1591 | WinSetDlgItemText(hwnd, COMP_SELRIGHT, s);
|
---|
| 1592 | WinEnableWindow(WinWindowFromID(hwnd, DID_OK), TRUE);
|
---|
| 1593 | WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), TRUE);
|
---|
| 1594 | WinEnableWindow(WinWindowFromID(hwnd, COMP_COLLECT), TRUE);
|
---|
| 1595 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBOTH), TRUE);
|
---|
| 1596 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), TRUE);
|
---|
| 1597 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), TRUE);
|
---|
| 1598 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), TRUE);
|
---|
| 1599 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), TRUE);
|
---|
| 1600 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSMALLER), TRUE);
|
---|
| 1601 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBOTH), TRUE);
|
---|
| 1602 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), TRUE);
|
---|
| 1603 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), TRUE);
|
---|
| 1604 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), TRUE);
|
---|
| 1605 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), TRUE);
|
---|
| 1606 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTSMALLER), TRUE);
|
---|
| 1607 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTALL), TRUE);
|
---|
| 1608 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAMECONTENT), TRUE);
|
---|
| 1609 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTIDENTICAL), TRUE);
|
---|
| 1610 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAME), TRUE);
|
---|
| 1611 | WinEnableWindow(WinWindowFromID(hwnd, IDM_INVERT), TRUE);
|
---|
| 1612 | WinEnableWindow(WinWindowFromID(hwnd, COMP_SETDIRS), TRUE);
|
---|
| 1613 | WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), TRUE);
|
---|
| 1614 | WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), TRUE);
|
---|
| 1615 | if (!*cmp->rightlist) {
|
---|
| 1616 | WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), TRUE);
|
---|
| 1617 | WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), TRUE);
|
---|
| 1618 | WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETERIGHT), TRUE);
|
---|
| 1619 | WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYRIGHT), TRUE);
|
---|
| 1620 | WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVERIGHT), TRUE);
|
---|
[362] | 1621 | }
|
---|
[551] | 1622 | WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS), TRUE);
|
---|
| 1623 | if (*cmp->dcd.mask.szMask)
|
---|
| 1624 | WinSetDlgItemText(hwnd, COMP_NOTE,
|
---|
| 1625 | GetPString(IDS_COMPREADYFILTEREDTEXT));
|
---|
| 1626 | else
|
---|
| 1627 | WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPREADYTEXT));
|
---|
| 1628 | }
|
---|
| 1629 | break;
|
---|
| 1630 |
|
---|
| 1631 | case WM_INITMENU:
|
---|
| 1632 | cmp = INSTDATA(hwnd);
|
---|
| 1633 | if (cmp) {
|
---|
| 1634 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 1635 | case IDM_COMMANDSMENU:
|
---|
| 1636 | SetupCommandMenu(cmp->dcd.hwndLastMenu, hwnd);
|
---|
| 1637 | break;
|
---|
[2] | 1638 | }
|
---|
[551] | 1639 | }
|
---|
| 1640 | break;
|
---|
[2] | 1641 |
|
---|
[551] | 1642 | case WM_MENUEND:
|
---|
| 1643 | cmp = INSTDATA(hwnd);
|
---|
| 1644 | if (cmp) {
|
---|
| 1645 | if ((HWND) mp2 == cmp->dcd.hwndLastMenu) {
|
---|
| 1646 | MarkAll(hwndLeft, TRUE, FALSE, TRUE);
|
---|
| 1647 | MarkAll(hwndRight, TRUE, FALSE, TRUE);
|
---|
| 1648 | WinDestroyWindow(cmp->dcd.hwndLastMenu);
|
---|
| 1649 | cmp->dcd.hwndLastMenu = (HWND) 0;
|
---|
[2] | 1650 | }
|
---|
[551] | 1651 | }
|
---|
| 1652 | break;
|
---|
[2] | 1653 |
|
---|
[551] | 1654 | case WM_CONTROL:
|
---|
| 1655 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 1656 | case COMP_INCLUDESUBDIRS:
|
---|
| 1657 | switch (SHORT2FROMMP(mp1)) {
|
---|
| 1658 | case BN_CLICKED:
|
---|
| 1659 | cmp = INSTDATA(hwnd);
|
---|
| 1660 | if (cmp)
|
---|
| 1661 | *cmp->rightlist = 0;
|
---|
| 1662 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 1663 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 1664 | break;
|
---|
[2] | 1665 | }
|
---|
| 1666 | break;
|
---|
[551] | 1667 | case COMP_HIDENOTSELECTED:
|
---|
| 1668 | switch (SHORT2FROMMP(mp1)) {
|
---|
| 1669 | case BN_CLICKED:
|
---|
| 1670 | WinSendMsg(hwnd, UM_HIDENOTSELECTED, MPVOID, MPVOID);
|
---|
| 1671 | break;
|
---|
| 1672 | }
|
---|
| 1673 | break;
|
---|
[2] | 1674 |
|
---|
[551] | 1675 | case COMP_LEFTDIR:
|
---|
| 1676 | case COMP_RIGHTDIR:
|
---|
| 1677 | switch (SHORT2FROMMP(mp1)) {
|
---|
| 1678 | case CN_KILLFOCUS:
|
---|
| 1679 | PaintRecessedWindow(WinWindowFromID(hwnd, SHORT1FROMMP(mp1)),
|
---|
| 1680 | (HPS) 0, FALSE, TRUE);
|
---|
| 1681 | break;
|
---|
[2] | 1682 |
|
---|
[551] | 1683 | case CN_SETFOCUS:
|
---|
| 1684 | PaintRecessedWindow(WinWindowFromID(hwnd, SHORT1FROMMP(mp1)),
|
---|
| 1685 | (HPS) 0, TRUE, TRUE);
|
---|
| 1686 | break;
|
---|
[2] | 1687 |
|
---|
[551] | 1688 | case CN_ENTER:
|
---|
| 1689 | if (mp2) {
|
---|
[2] | 1690 |
|
---|
[551] | 1691 | PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
|
---|
| 1692 | HWND hwndCnr = WinWindowFromID(hwnd, SHORT1FROMMP(mp1));
|
---|
[2] | 1693 |
|
---|
[551] | 1694 | SetShiftState();
|
---|
| 1695 | if (pci) {
|
---|
[748] | 1696 | if (pci->rc.flRecordAttr & CRA_INUSE || !pci || !*pci->pszFileName)
|
---|
[551] | 1697 | break;
|
---|
| 1698 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
| 1699 | MPFROM2SHORT(TRUE, CRA_INUSE));
|
---|
| 1700 | if (pci->attrFile & FILE_DIRECTORY) {
|
---|
| 1701 | if ((shiftstate & (KC_CTRL | KC_SHIFT)) == (KC_CTRL | KC_SHIFT))
|
---|
[730] | 1702 | OpenObject(pci->pszFileName, Settings, hwnd);
|
---|
[551] | 1703 | else
|
---|
[730] | 1704 | OpenObject(pci->pszFileName, Default, hwnd);
|
---|
[551] | 1705 | }
|
---|
| 1706 | else
|
---|
| 1707 | DefaultViewKeys(hwnd, hwnd, HWND_DESKTOP, NULL,
|
---|
[730] | 1708 | pci->pszFileName);
|
---|
[551] | 1709 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
| 1710 | MPFROMP(pci),
|
---|
| 1711 | MPFROM2SHORT(FALSE, CRA_INUSE |
|
---|
| 1712 | ((fUnHilite) ? CRA_SELECTED : 0)));
|
---|
| 1713 | }
|
---|
| 1714 | }
|
---|
| 1715 | break;
|
---|
[2] | 1716 |
|
---|
[551] | 1717 | case CN_CONTEXTMENU:
|
---|
| 1718 | cmp = INSTDATA(hwnd);
|
---|
| 1719 | if (cmp) {
|
---|
[2] | 1720 |
|
---|
[551] | 1721 | PCNRITEM pci = (PCNRITEM) mp2;
|
---|
| 1722 | USHORT id = COMP_CNRMENU;
|
---|
[2] | 1723 |
|
---|
[551] | 1724 | if (cmp->dcd.hwndLastMenu)
|
---|
| 1725 | WinDestroyWindow(cmp->dcd.hwndLastMenu);
|
---|
| 1726 | cmp->dcd.hwndLastMenu = (HWND) 0;
|
---|
| 1727 | cmp->hwndCalling = WinWindowFromID(hwnd, SHORT1FROMMP(mp1));
|
---|
| 1728 | if (pci) {
|
---|
[748] | 1729 | if (!pci || !*pci->pszFileName || *cmp->rightlist)
|
---|
[551] | 1730 | break;
|
---|
| 1731 | id = COMP_MENU;
|
---|
| 1732 | WinSendMsg(cmp->hwndCalling, CM_SETRECORDEMPHASIS,
|
---|
| 1733 | MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
|
---|
| 1734 | }
|
---|
| 1735 | cmp->dcd.hwndLastMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
|
---|
| 1736 | if (cmp->dcd.hwndLastMenu) {
|
---|
| 1737 | if (id == COMP_CNRMENU) {
|
---|
| 1738 | if (SHORT1FROMMP(mp1) == COMP_RIGHTDIR)
|
---|
| 1739 | WinSendMsg(cmp->dcd.hwndLastMenu, MM_DELETEITEM,
|
---|
| 1740 | MPFROM2SHORT(IDM_SHOWSUBJECT, FALSE), MPVOID);
|
---|
| 1741 | SetDetailsSwitches(cmp->dcd.hwndLastMenu, &cmp->dcd);
|
---|
| 1742 | if (SHORT1FROMMP(mp1) == COMP_LEFTDIR)
|
---|
| 1743 | WinSendMsg(cmp->dcd.hwndLastMenu, MM_DELETEITEM,
|
---|
| 1744 | MPFROM2SHORT(IDM_LOADLISTFILE, 0), MPVOID);
|
---|
| 1745 | else if (*cmp->rightlist)
|
---|
| 1746 | WinSendMsg(cmp->dcd.hwndLastMenu, MM_DELETEITEM,
|
---|
| 1747 | MPFROM2SHORT(IDM_SAVELISTFILE, 0), MPVOID);
|
---|
| 1748 | }
|
---|
| 1749 | PopupMenu(hwnd, hwnd, cmp->dcd.hwndLastMenu);
|
---|
| 1750 | }
|
---|
| 1751 | }
|
---|
| 1752 | break;
|
---|
[2] | 1753 |
|
---|
[551] | 1754 | case CN_INITDRAG:
|
---|
| 1755 | cmp = INSTDATA(hwnd);
|
---|
| 1756 | if (*cmp->rightlist && SHORT1FROMMP(mp1) == COMP_RIGHTDIR)
|
---|
| 1757 | break;
|
---|
| 1758 | DoFileDrag(WinWindowFromID(hwnd, SHORT1FROMMP(mp1)),
|
---|
| 1759 | (HWND) 0, mp2, NULL, NULL, TRUE);
|
---|
| 1760 | break;
|
---|
[2] | 1761 |
|
---|
[551] | 1762 | case CN_BEGINEDIT:
|
---|
| 1763 | case CN_REALLOCPSZ:
|
---|
| 1764 | // fixme to be gone - field edits not allowed
|
---|
| 1765 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 1766 | "CN_BEGINEDIT/CN_REALLOCPSZ unexpected");
|
---|
| 1767 | break;
|
---|
[2] | 1768 |
|
---|
[551] | 1769 | case CN_EMPHASIS:
|
---|
| 1770 | {
|
---|
| 1771 | PNOTIFYRECORDEMPHASIS pre = mp2;
|
---|
| 1772 | PCNRITEM pci;
|
---|
[2] | 1773 |
|
---|
[551] | 1774 | if (pre->fEmphasisMask & CRA_SELECTED) {
|
---|
| 1775 | pci = (PCNRITEM) pre->pRecord;
|
---|
| 1776 | if (pci) {
|
---|
[748] | 1777 | if (!pci || !*pci->pszFileName) {
|
---|
[551] | 1778 | if (pci->rc.flRecordAttr & CRA_SELECTED)
|
---|
| 1779 | WinSendDlgItemMsg(hwnd, SHORT1FROMMP(mp1),
|
---|
| 1780 | CM_SETRECORDEMPHASIS,
|
---|
| 1781 | MPFROMP(pci),
|
---|
| 1782 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
| 1783 | }
|
---|
| 1784 | else {
|
---|
[2] | 1785 |
|
---|
[551] | 1786 | CHAR s[81];
|
---|
[2] | 1787 |
|
---|
[551] | 1788 | cmp = INSTDATA(hwnd);
|
---|
| 1789 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
| 1790 | if (SHORT1FROMMP(mp1) == COMP_LEFTDIR)
|
---|
| 1791 | cmp->selleft++;
|
---|
| 1792 | else
|
---|
| 1793 | cmp->selright++;
|
---|
| 1794 | }
|
---|
| 1795 | else {
|
---|
| 1796 | if (SHORT1FROMMP(mp1) == COMP_LEFTDIR) {
|
---|
| 1797 | if (cmp->selleft)
|
---|
| 1798 | cmp->selleft--;
|
---|
| 1799 | }
|
---|
| 1800 | else {
|
---|
| 1801 | if (cmp->selright)
|
---|
| 1802 | cmp->selright--;
|
---|
| 1803 | }
|
---|
| 1804 | }
|
---|
| 1805 | if (SHORT1FROMMP(mp1) == COMP_LEFTDIR) {
|
---|
| 1806 | if (WinIsWindowEnabled(hwndLeft) || !(cmp->selleft % 50)) {
|
---|
| 1807 | sprintf(s, " %d", cmp->selleft);
|
---|
| 1808 | WinSetDlgItemText(hwnd, COMP_SELLEFT, s);
|
---|
| 1809 | }
|
---|
| 1810 | }
|
---|
| 1811 | else {
|
---|
| 1812 | if (WinIsWindowEnabled(hwndRight) || !(cmp->selright % 50)) {
|
---|
| 1813 | sprintf(s, " %d", cmp->selright);
|
---|
| 1814 | WinSetDlgItemText(hwnd, COMP_SELRIGHT, s);
|
---|
| 1815 | }
|
---|
| 1816 | }
|
---|
| 1817 | }
|
---|
| 1818 | }
|
---|
| 1819 | }
|
---|
| 1820 | }
|
---|
| 1821 | break;
|
---|
[2] | 1822 |
|
---|
[551] | 1823 | case CN_SCROLL:
|
---|
| 1824 | cmp = INSTDATA(hwnd);
|
---|
| 1825 | if (!cmp->forcescroll) {
|
---|
[2] | 1826 |
|
---|
[551] | 1827 | PNOTIFYSCROLL pns = mp2;
|
---|
[2] | 1828 |
|
---|
[551] | 1829 | if (pns->fScroll & CMA_VERTICAL) {
|
---|
| 1830 | cmp->forcescroll = TRUE;
|
---|
| 1831 | WinSendDlgItemMsg(hwnd, (SHORT1FROMMP(mp1) == COMP_LEFTDIR) ?
|
---|
| 1832 | COMP_RIGHTDIR : COMP_LEFTDIR,
|
---|
| 1833 | CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL),
|
---|
| 1834 | MPFROMLONG(pns->lScrollInc));
|
---|
| 1835 | cmp->forcescroll = FALSE;
|
---|
| 1836 | }
|
---|
| 1837 | }
|
---|
| 1838 | break;
|
---|
[2] | 1839 | }
|
---|
[551] | 1840 | break; // COMP_RIGHTDIR
|
---|
| 1841 | }
|
---|
| 1842 | return 0; // WM_CONTROL
|
---|
[2] | 1843 |
|
---|
[551] | 1844 | case UM_SETDIR:
|
---|
| 1845 | cmp = INSTDATA(hwnd);
|
---|
| 1846 | if (cmp) {
|
---|
[2] | 1847 |
|
---|
[551] | 1848 | COMPARE *forthread;
|
---|
| 1849 | CNRINFO cnri;
|
---|
[2] | 1850 |
|
---|
[551] | 1851 | cmp->includesubdirs = WinQueryButtonCheckstate(hwnd,
|
---|
| 1852 | COMP_INCLUDESUBDIRS);
|
---|
| 1853 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
| 1854 | cnri.cb = sizeof(CNRINFO);
|
---|
| 1855 | cnri.pszCnrTitle = cmp->leftdir;
|
---|
| 1856 | cnri.flWindowAttr = CV_DETAIL | CV_MINI |
|
---|
[751] | 1857 | CA_CONTAINERTITLE | CA_TITLESEPARATOR |
|
---|
| 1858 | CA_DETAILSVIEWTITLES | CA_OWNERDRAW;
|
---|
[551] | 1859 | WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
|
---|
| 1860 | MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
|
---|
| 1861 | cnri.pszCnrTitle = cmp->rightdir;
|
---|
| 1862 | WinSendDlgItemMsg(hwnd, COMP_RIGHTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
|
---|
| 1863 | MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
|
---|
| 1864 | WinCheckButton(hwnd, COMP_HIDENOTSELECTED, 0);
|
---|
| 1865 | cmp->filling = TRUE;
|
---|
| 1866 | forthread = xmalloc(sizeof(COMPARE), pszSrcFile, __LINE__);
|
---|
| 1867 | if (!forthread)
|
---|
| 1868 | WinDismissDlg(hwnd, 0);
|
---|
| 1869 | else {
|
---|
| 1870 | *forthread = *cmp;
|
---|
| 1871 | forthread->cmp = cmp;
|
---|
| 1872 | if (_beginthread(FillCnrsThread, NULL, 122880, (PVOID) forthread) ==
|
---|
| 1873 | -1) {
|
---|
| 1874 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 1875 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
| 1876 | WinDismissDlg(hwnd, 0);
|
---|
| 1877 | free(forthread);
|
---|
| 1878 | }
|
---|
[362] | 1879 | else {
|
---|
[551] | 1880 | WinEnableWindowUpdate(hwndLeft, FALSE);
|
---|
| 1881 | WinEnableWindowUpdate(hwndRight, FALSE);
|
---|
| 1882 | cmp->selleft = cmp->selright = 0;
|
---|
| 1883 | WinSetDlgItemText(hwnd, COMP_SELLEFT, "0");
|
---|
| 1884 | WinSetDlgItemText(hwnd, COMP_SELRIGHT, "0");
|
---|
| 1885 | WinSetDlgItemText(hwnd, COMP_TOTALLEFT, "0");
|
---|
| 1886 | WinSetDlgItemText(hwnd, COMP_TOTALRIGHT, "0");
|
---|
| 1887 | WinSetDlgItemText(hwnd, COMP_NOTE,
|
---|
| 1888 | GetPString(IDS_COMPHOLDREADDISKTEXT));
|
---|
| 1889 | WinEnableWindow(hwndRight, FALSE);
|
---|
| 1890 | WinEnableWindow(hwndLeft, FALSE);
|
---|
| 1891 | WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
|
---|
| 1892 | WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), FALSE);
|
---|
| 1893 | WinEnableWindow(WinWindowFromID(hwnd, COMP_COLLECT), FALSE);
|
---|
| 1894 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBOTH), FALSE);
|
---|
| 1895 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), FALSE);
|
---|
| 1896 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), FALSE);
|
---|
| 1897 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), FALSE);
|
---|
| 1898 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), FALSE);
|
---|
| 1899 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSMALLER), FALSE);
|
---|
| 1900 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBOTH), FALSE);
|
---|
| 1901 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), FALSE);
|
---|
| 1902 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), FALSE);
|
---|
| 1903 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), FALSE);
|
---|
| 1904 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), FALSE);
|
---|
| 1905 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTSMALLER), FALSE);
|
---|
| 1906 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTALL), FALSE);
|
---|
| 1907 | WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS), FALSE);
|
---|
| 1908 | WinEnableWindow(WinWindowFromID(hwnd, COMP_SETDIRS), FALSE);
|
---|
| 1909 | WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), FALSE);
|
---|
| 1910 | WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETERIGHT), FALSE);
|
---|
| 1911 | WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), FALSE);
|
---|
| 1912 | WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), FALSE);
|
---|
| 1913 | WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYRIGHT), FALSE);
|
---|
| 1914 | WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVERIGHT), FALSE);
|
---|
| 1915 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAMECONTENT),
|
---|
| 1916 | FALSE);
|
---|
| 1917 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTIDENTICAL), FALSE);
|
---|
| 1918 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAME), FALSE);
|
---|
| 1919 | WinEnableWindow(WinWindowFromID(hwnd, IDM_INVERT), FALSE);
|
---|
| 1920 | WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), FALSE);
|
---|
| 1921 | }
|
---|
[2] | 1922 | }
|
---|
[551] | 1923 | }
|
---|
| 1924 | return 0;
|
---|
[2] | 1925 |
|
---|
[551] | 1926 | case UM_FILTER:
|
---|
| 1927 | cmp = INSTDATA(hwnd);
|
---|
| 1928 | if (cmp) {
|
---|
| 1929 | if (mp1) {
|
---|
| 1930 | DosEnterCritSec();
|
---|
| 1931 | SetMask((CHAR *) mp1, &cmp->dcd.mask);
|
---|
| 1932 | DosExitCritSec();
|
---|
[2] | 1933 | }
|
---|
[551] | 1934 | cmp->dcd.suspendview = 1;
|
---|
| 1935 | WinSendMsg(hwndLeft, CM_FILTER, MPFROMP(Filter),
|
---|
| 1936 | MPFROMP(&cmp->dcd.mask));
|
---|
| 1937 | WinSendMsg(hwndRight, CM_FILTER, MPFROMP(Filter),
|
---|
| 1938 | MPFROMP(&cmp->dcd.mask));
|
---|
| 1939 | cmp->dcd.suspendview = 0;
|
---|
| 1940 | if (*cmp->dcd.mask.szMask)
|
---|
| 1941 | WinSetDlgItemText(hwnd, COMP_NOTE,
|
---|
| 1942 | GetPString(IDS_COMPREADYFILTEREDTEXT));
|
---|
| 1943 | else
|
---|
| 1944 | WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPREADYTEXT));
|
---|
| 1945 | }
|
---|
| 1946 | return 0;
|
---|
[2] | 1947 |
|
---|
[551] | 1948 | case UM_HIDENOTSELECTED:
|
---|
| 1949 | cmp = INSTDATA(hwnd);
|
---|
| 1950 | if (cmp) {
|
---|
| 1951 | USHORT wantHide = WinQueryButtonCheckstate(hwnd,
|
---|
| 1952 | COMP_HIDENOTSELECTED);
|
---|
[316] | 1953 |
|
---|
[551] | 1954 | cmp->dcd.suspendview = 1;
|
---|
| 1955 | if (wantHide) {
|
---|
| 1956 | BOOL needRefresh = FALSE;
|
---|
| 1957 | HWND hwndl = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
|
---|
| 1958 | HWND hwndr = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
|
---|
| 1959 | PCNRITEM pcil = WinSendMsg(hwndl, CM_QUERYRECORD, MPVOID,
|
---|
| 1960 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
| 1961 | PCNRITEM pcir = WinSendMsg(hwndr, CM_QUERYRECORD, MPVOID,
|
---|
| 1962 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
| 1963 |
|
---|
| 1964 | while (pcil && (INT) pcil != -1 && pcir && (INT) pcir != -1) {
|
---|
| 1965 | if (~pcil->rc.flRecordAttr & CRA_SELECTED &&
|
---|
| 1966 | ~pcir->rc.flRecordAttr & CRA_SELECTED) {
|
---|
| 1967 | pcil->rc.flRecordAttr |= CRA_FILTERED;
|
---|
| 1968 | pcir->rc.flRecordAttr |= CRA_FILTERED;
|
---|
| 1969 | needRefresh = TRUE;
|
---|
[316] | 1970 | }
|
---|
[551] | 1971 | pcil = WinSendMsg(hwndl, CM_QUERYRECORD, MPFROMP(pcil),
|
---|
| 1972 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
| 1973 | pcir = WinSendMsg(hwndr, CM_QUERYRECORD, MPFROMP(pcir),
|
---|
| 1974 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
[748] | 1975 | } // while
|
---|
[551] | 1976 | if (needRefresh) {
|
---|
| 1977 | WinSendMsg(hwndl, CM_INVALIDATERECORD,
|
---|
| 1978 | MPVOID, MPFROM2SHORT(0, CMA_REPOSITION));
|
---|
| 1979 | WinSendMsg(hwndr, CM_INVALIDATERECORD,
|
---|
| 1980 | MPVOID, MPFROM2SHORT(0, CMA_REPOSITION));
|
---|
[316] | 1981 | }
|
---|
| 1982 | }
|
---|
[551] | 1983 | else {
|
---|
| 1984 | WinSendMsg(hwndLeft, CM_FILTER, MPFROMP(Filter),
|
---|
| 1985 | MPFROMP(&cmp->dcd.mask));
|
---|
| 1986 | WinSendMsg(hwndRight, CM_FILTER, MPFROMP(Filter),
|
---|
| 1987 | MPFROMP(&cmp->dcd.mask));
|
---|
| 1988 | }
|
---|
| 1989 | cmp->dcd.suspendview = 0;
|
---|
| 1990 | if (*cmp->dcd.mask.szMask)
|
---|
| 1991 | WinSetDlgItemText(hwnd, COMP_NOTE,
|
---|
| 1992 | GetPString(IDS_COMPREADYFILTEREDTEXT));
|
---|
| 1993 | else
|
---|
| 1994 | WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPREADYTEXT));
|
---|
| 1995 | }
|
---|
| 1996 | return 0;
|
---|
[316] | 1997 |
|
---|
[551] | 1998 | case WM_COMMAND:
|
---|
| 1999 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2000 | case IDM_COMPARE:
|
---|
| 2001 | cmp = INSTDATA(hwnd);
|
---|
| 2002 | if (cmp) {
|
---|
[2] | 2003 |
|
---|
[551] | 2004 | PCNRITEM pci;
|
---|
| 2005 | CHAR ofile[CCHMAXPATH];
|
---|
[2] | 2006 |
|
---|
[551] | 2007 | pci = (PCNRITEM) WinSendMsg(cmp->hwndCalling,
|
---|
| 2008 | CM_QUERYRECORDEMPHASIS,
|
---|
| 2009 | MPFROMLONG(CMA_FIRST),
|
---|
| 2010 | MPFROMSHORT(CRA_CURSORED));
|
---|
[748] | 2011 | // 01 Aug 07 SHL
|
---|
| 2012 | if (pci && *pci->pszFileName) {
|
---|
[551] | 2013 | if (cmp->hwndCalling == hwndLeft)
|
---|
| 2014 | strcpy(ofile, cmp->rightdir);
|
---|
| 2015 | else
|
---|
| 2016 | strcpy(ofile, cmp->leftdir);
|
---|
| 2017 | if (ofile[strlen(ofile) - 1] != '\\')
|
---|
| 2018 | strcat(ofile, "\\");
|
---|
[751] | 2019 | strcat(ofile, pci->pszDisplayName);
|
---|
[551] | 2020 | if (*compare) {
|
---|
| 2021 | CHAR *fakelist[3];
|
---|
[730] | 2022 | fakelist[0] = pci->pszFileName;
|
---|
[551] | 2023 | fakelist[1] = ofile;
|
---|
| 2024 | fakelist[2] = NULL;
|
---|
| 2025 | ExecOnList(hwnd, compare,
|
---|
| 2026 | WINDOWED | SEPARATEKEEP, NULL, fakelist, NULL);
|
---|
| 2027 | }
|
---|
| 2028 | else {
|
---|
| 2029 | FCOMPARE fc;
|
---|
| 2030 | memset(&fc, 0, sizeof(fc));
|
---|
| 2031 | fc.size = sizeof(fc);
|
---|
| 2032 | fc.hwndParent = hwnd;
|
---|
[730] | 2033 | strcpy(fc.file1, pci->pszFileName);
|
---|
[551] | 2034 | strcpy(fc.file2, ofile);
|
---|
| 2035 | WinDlgBox(HWND_DESKTOP, hwnd,
|
---|
| 2036 | CFileDlgProc, FM3ModHandle, FCMP_FRAME, (PVOID) & fc);
|
---|
| 2037 | }
|
---|
| 2038 | }
|
---|
| 2039 | }
|
---|
| 2040 | break;
|
---|
[2] | 2041 |
|
---|
[551] | 2042 | case COMP_FILTER:
|
---|
| 2043 | case IDM_FILTER:
|
---|
| 2044 | cmp = INSTDATA(hwnd);
|
---|
| 2045 | if (cmp) {
|
---|
[2] | 2046 |
|
---|
[551] | 2047 | BOOL empty = FALSE;
|
---|
| 2048 | PCNRITEM pci;
|
---|
| 2049 | CHAR *p;
|
---|
| 2050 | BOOL temp;
|
---|
[2] | 2051 |
|
---|
[551] | 2052 | if (!*cmp->dcd.mask.szMask) {
|
---|
| 2053 | empty = TRUE;
|
---|
| 2054 | temp = fSelectedAlways;
|
---|
| 2055 | fSelectedAlways = TRUE;
|
---|
[748] | 2056 | pci = (PCNRITEM)CurrentRecord(hwnd);
|
---|
[551] | 2057 | fSelectedAlways = temp;
|
---|
[748] | 2058 | // 01 Aug 07 SHL
|
---|
| 2059 | if (pci && ~pci->attrFile & FILE_DIRECTORY) {
|
---|
[730] | 2060 | p = strrchr(pci->pszFileName, '\\');
|
---|
[551] | 2061 | if (p) {
|
---|
| 2062 | p++;
|
---|
| 2063 | strcpy(cmp->dcd.mask.szMask, p);
|
---|
| 2064 | }
|
---|
| 2065 | }
|
---|
| 2066 | }
|
---|
| 2067 | cmp->dcd.mask.fNoAttribs = TRUE;
|
---|
| 2068 | cmp->dcd.mask.attrFile = ALLATTRS;
|
---|
| 2069 | cmp->dcd.mask.antiattr = 0;
|
---|
| 2070 | if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
|
---|
| 2071 | FM3ModHandle, MSK_FRAME, MPFROMP(&cmp->dcd.mask))) {
|
---|
| 2072 | cmp->dcd.mask.attrFile = ALLATTRS;
|
---|
| 2073 | cmp->dcd.mask.antiattr = 0;
|
---|
| 2074 | WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
|
---|
| 2075 | }
|
---|
| 2076 | else if (empty) {
|
---|
| 2077 | *cmp->dcd.mask.szMask = 0;
|
---|
| 2078 | cmp->dcd.mask.attrFile = ALLATTRS;
|
---|
| 2079 | cmp->dcd.mask.antiattr = 0;
|
---|
| 2080 | }
|
---|
| 2081 | }
|
---|
| 2082 | break;
|
---|
[2] | 2083 |
|
---|
[551] | 2084 | case IDM_SHOWSUBJECT:
|
---|
| 2085 | case IDM_SHOWEAS:
|
---|
| 2086 | case IDM_SHOWSIZE:
|
---|
| 2087 | case IDM_SHOWLWDATE:
|
---|
| 2088 | case IDM_SHOWLWTIME:
|
---|
| 2089 | case IDM_SHOWLADATE:
|
---|
| 2090 | case IDM_SHOWLATIME:
|
---|
| 2091 | case IDM_SHOWCRDATE:
|
---|
| 2092 | case IDM_SHOWCRTIME:
|
---|
| 2093 | case IDM_SHOWATTR:
|
---|
| 2094 | cmp = INSTDATA(hwnd);
|
---|
| 2095 | if (cmp) {
|
---|
[2] | 2096 |
|
---|
[551] | 2097 | DIRCNRDATA dcd1;
|
---|
| 2098 | BOOL tempsubj;
|
---|
[2] | 2099 |
|
---|
[551] | 2100 | dcd1 = cmp->dcd;
|
---|
| 2101 | AdjustDetailsSwitches(hwndLeft,
|
---|
| 2102 | (HWND) 0, SHORT1FROMMP(mp1),
|
---|
| 2103 | cmp->leftdir, "DirCmp", &cmp->dcd, TRUE);
|
---|
| 2104 | tempsubj = cmp->dcd.detailssubject;
|
---|
| 2105 | cmp->dcd = dcd1;
|
---|
| 2106 | cmp->dcd.detailssubject = FALSE;
|
---|
| 2107 | AdjustDetailsSwitches(hwndRight,
|
---|
| 2108 | cmp->dcd.hwndLastMenu, SHORT1FROMMP(mp1),
|
---|
| 2109 | cmp->rightdir, "DirCmp", &cmp->dcd, TRUE);
|
---|
| 2110 | cmp->dcd.detailssubject = tempsubj;
|
---|
| 2111 | }
|
---|
| 2112 | break;
|
---|
[2] | 2113 |
|
---|
[551] | 2114 | case IDM_LOADLISTFILE:
|
---|
| 2115 | cmp = INSTDATA(hwnd);
|
---|
| 2116 | if (cmp) {
|
---|
[2] | 2117 |
|
---|
[551] | 2118 | CHAR fullname[CCHMAXPATH];
|
---|
[2] | 2119 |
|
---|
[551] | 2120 | strcpy(fullname, "*.PMD");
|
---|
| 2121 | if (insert_filename(HWND_DESKTOP, fullname, TRUE, FALSE) &&
|
---|
| 2122 | *fullname && !strchr(fullname, '*') && !strchr(fullname, '?')) {
|
---|
| 2123 | strcpy(cmp->rightlist, fullname);
|
---|
| 2124 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 2125 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2126 | }
|
---|
| 2127 | }
|
---|
| 2128 | break;
|
---|
[2] | 2129 |
|
---|
[551] | 2130 | case IDM_SAVELISTFILE:
|
---|
| 2131 | cmp = INSTDATA(hwnd);
|
---|
| 2132 | if (cmp) {
|
---|
[2] | 2133 |
|
---|
[551] | 2134 | SNAPSTUFF *sf;
|
---|
| 2135 | CHAR fullname[CCHMAXPATH];
|
---|
[2] | 2136 |
|
---|
[551] | 2137 | strcpy(fullname, "*.PMD");
|
---|
| 2138 | if (export_filename(HWND_DESKTOP, fullname, 1) && *fullname &&
|
---|
| 2139 | !strchr(fullname, '*') && !strchr(fullname, '?')) {
|
---|
| 2140 | sf = xmallocz(sizeof(SNAPSTUFF), pszSrcFile, __LINE__);
|
---|
| 2141 | if (sf) {
|
---|
| 2142 | strcpy(sf->filename, fullname);
|
---|
| 2143 | if (hwndLeft == cmp->hwndCalling)
|
---|
| 2144 | strcpy(sf->dirname, cmp->leftdir);
|
---|
| 2145 | else
|
---|
| 2146 | strcpy(sf->dirname, cmp->rightdir);
|
---|
| 2147 | sf->recurse = cmp->includesubdirs;
|
---|
| 2148 | if (_beginthread(StartSnap, NULL, 65536, (PVOID) sf) == -1) {
|
---|
| 2149 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 2150 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
| 2151 | free(sf);
|
---|
| 2152 | }
|
---|
| 2153 | }
|
---|
| 2154 | }
|
---|
| 2155 | }
|
---|
| 2156 | break;
|
---|
[2] | 2157 |
|
---|
[551] | 2158 | case COMP_SETDIRS:
|
---|
| 2159 | cmp = INSTDATA(hwnd);
|
---|
| 2160 | if (cmp) {
|
---|
[2] | 2161 |
|
---|
[551] | 2162 | WALK2 wa;
|
---|
[2] | 2163 |
|
---|
[551] | 2164 | memset(&wa, 0, sizeof(wa));
|
---|
| 2165 | wa.size = sizeof(wa);
|
---|
| 2166 | strcpy(wa.szCurrentPath1, cmp->leftdir);
|
---|
| 2167 | strcpy(wa.szCurrentPath2, cmp->rightdir);
|
---|
| 2168 | if (WinDlgBox(HWND_DESKTOP, hwnd, WalkTwoCmpDlgProc,
|
---|
| 2169 | FM3ModHandle, WALK2_FRAME,
|
---|
| 2170 | MPFROMP(&wa)) &&
|
---|
| 2171 | !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
|
---|
| 2172 | strcpy(cmp->leftdir, wa.szCurrentPath1);
|
---|
| 2173 | strcpy(cmp->rightdir, wa.szCurrentPath2);
|
---|
| 2174 | *cmp->rightlist = 0;
|
---|
| 2175 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 2176 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2177 | }
|
---|
| 2178 | }
|
---|
| 2179 | break;
|
---|
[2] | 2180 |
|
---|
[551] | 2181 | case COMP_COPYLEFT:
|
---|
| 2182 | case COMP_MOVELEFT:
|
---|
| 2183 | case COMP_COPYRIGHT:
|
---|
| 2184 | case COMP_MOVERIGHT:
|
---|
| 2185 | case COMP_DELETELEFT:
|
---|
| 2186 | case COMP_DELETERIGHT:
|
---|
| 2187 | cmp = INSTDATA(hwnd);
|
---|
| 2188 | if (cmp) {
|
---|
[2] | 2189 |
|
---|
[551] | 2190 | COMPARE *forthread;
|
---|
[2] | 2191 |
|
---|
[551] | 2192 | cmp->filling = TRUE;
|
---|
| 2193 | forthread = xmalloc(sizeof(COMPARE), pszSrcFile, __LINE__);
|
---|
| 2194 | if (forthread) {
|
---|
| 2195 | *forthread = *cmp;
|
---|
| 2196 | forthread->cmp = cmp;
|
---|
| 2197 | forthread->action = SHORT1FROMMP(mp1);
|
---|
| 2198 | if (_beginthread(ActionCnrThread, NULL, 122880, (PVOID) forthread)
|
---|
| 2199 | == -1) {
|
---|
| 2200 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 2201 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
| 2202 | free(forthread);
|
---|
| 2203 | }
|
---|
| 2204 | else {
|
---|
| 2205 | WinEnableWindowUpdate(hwndLeft, FALSE);
|
---|
| 2206 | WinEnableWindowUpdate(hwndRight, FALSE);
|
---|
| 2207 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2208 | case COMP_DELETELEFT:
|
---|
| 2209 | case COMP_DELETERIGHT:
|
---|
| 2210 | WinSetDlgItemText(hwnd, COMP_NOTE,
|
---|
| 2211 | GetPString(IDS_COMPHOLDDELETINGTEXT));
|
---|
| 2212 | break;
|
---|
| 2213 | case COMP_MOVELEFT:
|
---|
| 2214 | case COMP_MOVERIGHT:
|
---|
| 2215 | WinSetDlgItemText(hwnd, COMP_NOTE,
|
---|
| 2216 | GetPString(IDS_COMPHOLDMOVINGTEXT));
|
---|
| 2217 | break;
|
---|
| 2218 | case COMP_COPYLEFT:
|
---|
| 2219 | case COMP_COPYRIGHT:
|
---|
| 2220 | WinSetDlgItemText(hwnd, COMP_NOTE,
|
---|
| 2221 | GetPString(IDS_COMPHOLDCOPYINGTEXT));
|
---|
| 2222 | break;
|
---|
| 2223 | default:
|
---|
| 2224 | WinSetDlgItemText(hwnd, COMP_NOTE,
|
---|
| 2225 | GetPString(IDS_COMPHOLDDUNNOTEXT));
|
---|
| 2226 | break;
|
---|
| 2227 | }
|
---|
| 2228 | WinEnableWindow(hwndRight, FALSE);
|
---|
| 2229 | WinEnableWindow(hwndLeft, FALSE);
|
---|
| 2230 | WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
|
---|
| 2231 | WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), FALSE);
|
---|
| 2232 | WinEnableWindow(WinWindowFromID(hwnd, COMP_COLLECT), FALSE);
|
---|
| 2233 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBOTH), FALSE);
|
---|
| 2234 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), FALSE);
|
---|
| 2235 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), FALSE);
|
---|
| 2236 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), FALSE);
|
---|
| 2237 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), FALSE);
|
---|
| 2238 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSMALLER), FALSE);
|
---|
| 2239 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBOTH), FALSE);
|
---|
| 2240 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), FALSE);
|
---|
| 2241 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), FALSE);
|
---|
| 2242 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), FALSE);
|
---|
| 2243 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), FALSE);
|
---|
| 2244 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTSMALLER),
|
---|
| 2245 | FALSE);
|
---|
| 2246 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTALL), FALSE);
|
---|
| 2247 | WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS),
|
---|
| 2248 | FALSE);
|
---|
| 2249 | WinEnableWindow(WinWindowFromID(hwnd, COMP_SETDIRS), FALSE);
|
---|
| 2250 | WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), FALSE);
|
---|
| 2251 | WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETERIGHT), FALSE);
|
---|
| 2252 | WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), FALSE);
|
---|
| 2253 | WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), FALSE);
|
---|
| 2254 | WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYRIGHT), FALSE);
|
---|
| 2255 | WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVERIGHT), FALSE);
|
---|
| 2256 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAMECONTENT),
|
---|
| 2257 | FALSE);
|
---|
| 2258 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTIDENTICAL),
|
---|
| 2259 | FALSE);
|
---|
| 2260 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAME), FALSE);
|
---|
| 2261 | WinEnableWindow(WinWindowFromID(hwnd, IDM_INVERT), FALSE);
|
---|
| 2262 | WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), FALSE);
|
---|
| 2263 | }
|
---|
| 2264 | }
|
---|
| 2265 | }
|
---|
| 2266 | break;
|
---|
[2] | 2267 |
|
---|
[551] | 2268 | case DID_OK:
|
---|
| 2269 | WinDismissDlg(hwnd, 0);
|
---|
| 2270 | break;
|
---|
| 2271 | case DID_CANCEL:
|
---|
| 2272 | WinDismissDlg(hwnd, 1);
|
---|
| 2273 | break;
|
---|
[2] | 2274 |
|
---|
[551] | 2275 | case IDM_HELP:
|
---|
| 2276 | if (hwndHelp)
|
---|
| 2277 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
| 2278 | MPFROM2SHORT(HELP_COMPARE, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 2279 | break;
|
---|
[2] | 2280 |
|
---|
[551] | 2281 | case IDM_DESELECTALL:
|
---|
| 2282 | case IDM_SELECTNEWER:
|
---|
| 2283 | case IDM_SELECTOLDER:
|
---|
| 2284 | case IDM_SELECTBIGGER:
|
---|
| 2285 | case IDM_SELECTSMALLER:
|
---|
| 2286 | case IDM_DESELECTNEWER:
|
---|
| 2287 | case IDM_DESELECTOLDER:
|
---|
| 2288 | case IDM_DESELECTBIGGER:
|
---|
| 2289 | case IDM_DESELECTSMALLER:
|
---|
| 2290 | case IDM_DESELECTONE:
|
---|
| 2291 | case IDM_DESELECTBOTH:
|
---|
| 2292 | case IDM_SELECTBOTH:
|
---|
| 2293 | case IDM_SELECTONE:
|
---|
| 2294 | case IDM_SELECTSAMECONTENT:
|
---|
[748] | 2295 | case IDM_SELECTIDENTICAL: // Name, size and time
|
---|
| 2296 | case IDM_SELECTSAME: // Name and size
|
---|
[551] | 2297 | case IDM_INVERT:
|
---|
| 2298 | cmp = INSTDATA(hwnd);
|
---|
| 2299 | if (!cmp)
|
---|
| 2300 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2301 | else {
|
---|
| 2302 | COMPARE *forthread;
|
---|
| 2303 |
|
---|
| 2304 | cmp->filling = TRUE;
|
---|
| 2305 | forthread = xmalloc(sizeof(COMPARE), pszSrcFile, __LINE__);
|
---|
| 2306 | if (forthread) {
|
---|
| 2307 | *forthread = *cmp;
|
---|
| 2308 | forthread->cmp = cmp;
|
---|
| 2309 | forthread->action = SHORT1FROMMP(mp1);
|
---|
| 2310 | if (_beginthread(SelectCnrsThread, NULL, 65536, (PVOID) forthread)
|
---|
| 2311 | == -1) {
|
---|
| 2312 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 2313 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
| 2314 | free(forthread);
|
---|
| 2315 | }
|
---|
[362] | 2316 | else {
|
---|
[551] | 2317 | WinEnableWindowUpdate(hwndLeft, FALSE);
|
---|
| 2318 | WinEnableWindowUpdate(hwndRight, FALSE);
|
---|
| 2319 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2320 | case IDM_DESELECTALL:
|
---|
| 2321 | case IDM_DESELECTNEWER:
|
---|
| 2322 | case IDM_DESELECTOLDER:
|
---|
| 2323 | case IDM_DESELECTBIGGER:
|
---|
| 2324 | case IDM_DESELECTSMALLER:
|
---|
| 2325 | case IDM_DESELECTONE:
|
---|
| 2326 | case IDM_DESELECTBOTH:
|
---|
| 2327 | WinSetDlgItemText(hwnd, COMP_NOTE,
|
---|
| 2328 | GetPString(IDS_COMPHOLDDESELTEXT));
|
---|
| 2329 | break;
|
---|
| 2330 | case IDM_INVERT:
|
---|
| 2331 | WinSetDlgItemText(hwnd, COMP_NOTE,
|
---|
| 2332 | GetPString(IDS_COMPHOLDINVERTTEXT));
|
---|
| 2333 | break;
|
---|
| 2334 | default:
|
---|
| 2335 | WinSetDlgItemText(hwnd, COMP_NOTE,
|
---|
| 2336 | GetPString(IDS_COMPHOLDSELTEXT));
|
---|
| 2337 | break;
|
---|
| 2338 | }
|
---|
| 2339 | WinEnableWindow(hwndRight, FALSE);
|
---|
| 2340 | WinEnableWindow(hwndLeft, FALSE);
|
---|
| 2341 | WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
|
---|
| 2342 | WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), FALSE);
|
---|
| 2343 | WinEnableWindow(WinWindowFromID(hwnd, COMP_COLLECT), FALSE);
|
---|
| 2344 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBOTH), FALSE);
|
---|
| 2345 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), FALSE);
|
---|
| 2346 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), FALSE);
|
---|
| 2347 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), FALSE);
|
---|
| 2348 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), FALSE);
|
---|
| 2349 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSMALLER), FALSE);
|
---|
| 2350 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBOTH), FALSE);
|
---|
| 2351 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), FALSE);
|
---|
| 2352 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), FALSE);
|
---|
| 2353 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), FALSE);
|
---|
| 2354 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), FALSE);
|
---|
| 2355 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTSMALLER),
|
---|
| 2356 | FALSE);
|
---|
| 2357 | WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTALL), FALSE);
|
---|
| 2358 | WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS),
|
---|
| 2359 | FALSE);
|
---|
| 2360 | WinEnableWindow(WinWindowFromID(hwnd, COMP_SETDIRS), FALSE);
|
---|
| 2361 | WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), FALSE);
|
---|
| 2362 | WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETERIGHT), FALSE);
|
---|
| 2363 | WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), FALSE);
|
---|
| 2364 | WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), FALSE);
|
---|
| 2365 | WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYRIGHT), FALSE);
|
---|
| 2366 | WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVERIGHT), FALSE);
|
---|
| 2367 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAMECONTENT),
|
---|
| 2368 | FALSE);
|
---|
| 2369 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTIDENTICAL),
|
---|
| 2370 | FALSE);
|
---|
| 2371 | WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAME), FALSE);
|
---|
| 2372 | WinEnableWindow(WinWindowFromID(hwnd, IDM_INVERT), FALSE);
|
---|
| 2373 | WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), FALSE);
|
---|
| 2374 | }
|
---|
| 2375 | }
|
---|
| 2376 | }
|
---|
| 2377 | break;
|
---|
[2] | 2378 |
|
---|
[551] | 2379 | case COMP_COLLECT:
|
---|
| 2380 | cmp = INSTDATA(hwnd);
|
---|
| 2381 | if (cmp) {
|
---|
[2] | 2382 |
|
---|
[551] | 2383 | CHAR **listl, **listr = NULL;
|
---|
[2] | 2384 |
|
---|
[551] | 2385 | if (!Collector) {
|
---|
[2] | 2386 |
|
---|
[551] | 2387 | SWP swp;
|
---|
| 2388 | HWND hwndC;
|
---|
[2] | 2389 |
|
---|
[551] | 2390 | if (!fAutoTile && !ParentIsDesktop(hwnd, cmp->hwndParent) &&
|
---|
| 2391 | (!fExternalCollector && !strcmp(realappname, FM3Str)))
|
---|
| 2392 | GetNextWindowPos(cmp->hwndParent, &swp, NULL, NULL);
|
---|
| 2393 | hwndC = StartCollector((fExternalCollector ||
|
---|
| 2394 | strcmp(realappname, FM3Str)) ?
|
---|
| 2395 | HWND_DESKTOP : cmp->hwndParent, 4);
|
---|
| 2396 | if (hwndC) {
|
---|
| 2397 | if (!fAutoTile && !ParentIsDesktop(hwnd, cmp->hwndParent) &&
|
---|
| 2398 | (!fExternalCollector && !strcmp(realappname, FM3Str)))
|
---|
| 2399 | WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
|
---|
| 2400 | swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
|
---|
| 2401 | SWP_SHOW | SWP_ZORDER);
|
---|
| 2402 | else if (!ParentIsDesktop(hwnd, cmp->hwndParent) && fAutoTile &&
|
---|
| 2403 | !strcmp(realappname, FM3Str))
|
---|
| 2404 | TileChildren(cmp->hwndParent, TRUE);
|
---|
[748] | 2405 | DosSleep(64);
|
---|
[551] | 2406 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(COMP_COLLECT, 0), MPVOID);
|
---|
| 2407 | break;
|
---|
| 2408 | }
|
---|
| 2409 | }
|
---|
| 2410 | else
|
---|
| 2411 | StartCollector(cmp->hwndParent, 4);
|
---|
| 2412 | {
|
---|
| 2413 | BOOL temp;
|
---|
[2] | 2414 |
|
---|
[551] | 2415 | temp = fSelectedAlways;
|
---|
| 2416 | fSelectedAlways = TRUE;
|
---|
| 2417 | listl = BuildList(hwndLeft);
|
---|
| 2418 | if (!*cmp->rightlist)
|
---|
| 2419 | listr = BuildList(hwndRight);
|
---|
| 2420 | fSelectedAlways = temp;
|
---|
| 2421 | }
|
---|
| 2422 | if (listl || listr) {
|
---|
| 2423 | if (Collector) {
|
---|
| 2424 | if (listl) {
|
---|
| 2425 | if (!PostMsg(Collector, WM_COMMAND,
|
---|
| 2426 | MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(listl)))
|
---|
| 2427 | FreeList(listl);
|
---|
| 2428 | }
|
---|
| 2429 | if (listr) {
|
---|
| 2430 | if (!PostMsg(Collector, WM_COMMAND,
|
---|
| 2431 | MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(listr)))
|
---|
| 2432 | FreeList(listr);
|
---|
| 2433 | }
|
---|
| 2434 | WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
|
---|
| 2435 | QW_PARENT),
|
---|
| 2436 | QW_PARENT), HWND_TOP, 0, 0, 0, 0,
|
---|
| 2437 | SWP_ACTIVATE);
|
---|
| 2438 | }
|
---|
| 2439 | else {
|
---|
| 2440 | FreeList(listl);
|
---|
| 2441 | FreeList(listr);
|
---|
| 2442 | }
|
---|
| 2443 | }
|
---|
[2] | 2444 | }
|
---|
[551] | 2445 | break;
|
---|
| 2446 | }
|
---|
| 2447 | return 0;
|
---|
[2] | 2448 |
|
---|
[551] | 2449 | case WM_CLOSE:
|
---|
| 2450 | WinDismissDlg(hwnd, 0);
|
---|
| 2451 | return 0;
|
---|
[2] | 2452 |
|
---|
[551] | 2453 | case WM_DESTROY:
|
---|
| 2454 | cmp = INSTDATA(hwnd);
|
---|
| 2455 | if (cmp) {
|
---|
| 2456 | if (cmp->dcd.hwndLastMenu)
|
---|
| 2457 | WinDestroyWindow(cmp->dcd.hwndLastMenu);
|
---|
| 2458 | if (cmp->dcd.hwndObject) {
|
---|
[574] | 2459 | WinSetWindowPtr(cmp->dcd.hwndObject, QWL_USER, (PVOID) NULL);
|
---|
[551] | 2460 | if (!PostMsg(cmp->dcd.hwndObject, WM_CLOSE, MPVOID, MPVOID))
|
---|
| 2461 | WinSendMsg(cmp->dcd.hwndObject, WM_CLOSE, MPVOID, MPVOID);
|
---|
[2] | 2462 | }
|
---|
[551] | 2463 | free(cmp);
|
---|
| 2464 | }
|
---|
| 2465 | EmptyCnr(hwndLeft);
|
---|
| 2466 | EmptyCnr(hwndRight);
|
---|
| 2467 | DosPostEventSem(CompactSem);
|
---|
| 2468 | break;
|
---|
[2] | 2469 | }
|
---|
[551] | 2470 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 2471 | }
|
---|