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