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