source: trunk/dll/comp.c@ 157

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

Rework for CNRITEM.szSubject
Rework with ULONGLONG

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