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