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