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