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