source: trunk/dll/comp.c@ 757

Last change on this file since 757 was 756, checked in by Gregg Young, 18 years ago

Cleanup for ticket 138 & 24

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