source: trunk/dll/comp.c@ 145

Last change on this file since 145 was 145, checked in by root, 20 years ago

Rework Win_Error usage

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