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