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