source: trunk/dll/comp.c@ 201

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

Drop unused

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