1 | #define INCL_DOS
|
---|
2 | #define INCL_WIN
|
---|
3 |
|
---|
4 | #include <os2.h>
|
---|
5 | #include <stdlib.h>
|
---|
6 | #include <string.h>
|
---|
7 | #include <ctype.h>
|
---|
8 | #include <stdio.h>
|
---|
9 | #include <share.h>
|
---|
10 | #include "fm3dll.h"
|
---|
11 | #include "fm3str.h"
|
---|
12 | #include "grep.h"
|
---|
13 |
|
---|
14 | #pragma data_seg(DATA2)
|
---|
15 | #pragma alloc_text(GREP,SecsSince1980,match,mmatch,dogrep)
|
---|
16 | #pragma alloc_text(GREP,doallsubdirs,domatchingfiles)
|
---|
17 |
|
---|
18 | /*****************************/
|
---|
19 | /* Function Prototypes */
|
---|
20 | /*****************************/
|
---|
21 |
|
---|
22 | static VOID doallsubdirs (GREP *grep,CHAR *searchPath,BOOL recursing,
|
---|
23 | char **fle,int numfls);
|
---|
24 | static INT domatchingfiles (GREP *grep,CHAR *path,char **fle,int numfls);
|
---|
25 | static BOOL doonefile (GREP *grep,CHAR *fileName,FILEFINDBUF4 *f);
|
---|
26 | static BOOL doinsertion (GREP *grep);
|
---|
27 | static BOOL InsertDupe (GREP *grep,CHAR *dir,FILEFINDBUF4 *f);
|
---|
28 | static VOID FillDupes (GREP *g);
|
---|
29 | static VOID FreeDupes (GREP *g);
|
---|
30 |
|
---|
31 | #define GREPCHARS "*?[] \\"
|
---|
32 |
|
---|
33 | #define isleap(year) ((((year%4)==0) && ((year%100)!=0)) || \
|
---|
34 | ((year%400)==0))
|
---|
35 |
|
---|
36 |
|
---|
37 | static INT monthdays[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
|
---|
38 |
|
---|
39 |
|
---|
40 | ULONG SecsSince1980 (FDATE *date,FTIME *time) {
|
---|
41 |
|
---|
42 | ULONG total = 0L;
|
---|
43 | register int x;
|
---|
44 |
|
---|
45 | for(x = 1980;x < date->year + 1980;x++) {
|
---|
46 | if(isleap(x))
|
---|
47 | total += (366L * (24L * 60L * 60L));
|
---|
48 | else
|
---|
49 | total += (365L * (24L * 60L * 60L));
|
---|
50 | }
|
---|
51 | for(x = 1;x < date->month;x++) {
|
---|
52 | if(x == 2 && isleap(date->year + 1980))
|
---|
53 | total += (29L * (24L * 60L * 60L));
|
---|
54 | else
|
---|
55 | total += ((long)monthdays[x - 1] * (24L * 60L * 60L));
|
---|
56 | }
|
---|
57 | total += (((long)date->day - 1L) * (24L * 60L * 60L));
|
---|
58 | total += ((long)time->hours * (60L * 60L));
|
---|
59 | total += ((long)time->minutes * 60L);
|
---|
60 | total += ((long)time->twosecs * 2L);
|
---|
61 | return total;
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | /*
|
---|
66 | * this function originally from C_ECHO's Snippets -- modified
|
---|
67 | * brute force methodology
|
---|
68 | */
|
---|
69 |
|
---|
70 | static BOOL m_match (CHAR *string, CHAR *pattern, BOOL absolute, BOOL ignore,
|
---|
71 | LONG len) {
|
---|
72 |
|
---|
73 | /* return TRUE if pattern found in string */
|
---|
74 |
|
---|
75 | register CHAR *tn = pattern;
|
---|
76 | register LONG len2 = 0;
|
---|
77 | LONG lastlen = 0;
|
---|
78 | CHAR lo,hi;
|
---|
79 |
|
---|
80 | if(len && string && pattern) {
|
---|
81 | if(absolute) /* no pattern matching */
|
---|
82 | return(findstring(pattern,strlen(pattern),string,len,
|
---|
83 | (ignore == FALSE)) != NULL);
|
---|
84 |
|
---|
85 | while(*tn && len2 < len) {
|
---|
86 | switch(*tn) {
|
---|
87 | case ' ':
|
---|
88 | while(*tn == ' ')
|
---|
89 | tn++;
|
---|
90 | while(len2 < len && isspace(string[len2]))
|
---|
91 | len2++;
|
---|
92 | break;
|
---|
93 |
|
---|
94 | case '*':
|
---|
95 | while(*tn == '*' || *tn == '?')
|
---|
96 | tn++;
|
---|
97 | if(!*tn)
|
---|
98 | return TRUE;
|
---|
99 | if(ignore) {
|
---|
100 | while(len2 < len && string[len2] != *tn)
|
---|
101 | len2++;
|
---|
102 | }
|
---|
103 | else {
|
---|
104 | while(len2 < len && toupper(string[len2] != *tn))
|
---|
105 | len2++;
|
---|
106 | }
|
---|
107 | break;
|
---|
108 |
|
---|
109 | case '[':
|
---|
110 | tn++;
|
---|
111 | if(!*tn)
|
---|
112 | return FALSE;
|
---|
113 | lo = *tn;
|
---|
114 | tn++;
|
---|
115 | if(*tn != '-')
|
---|
116 | return FALSE;
|
---|
117 | tn++;
|
---|
118 | if(!*tn)
|
---|
119 | return FALSE;
|
---|
120 | hi = *tn;
|
---|
121 | tn++;
|
---|
122 | if (*tn != ']')
|
---|
123 | return FALSE;
|
---|
124 | tn++;
|
---|
125 | if(ignore) {
|
---|
126 | if ((toupper(string[len2]) >= toupper(lo)) &&
|
---|
127 | (toupper(string[len2]) <= toupper(hi)))
|
---|
128 | len2++;
|
---|
129 | else {
|
---|
130 | tn = pattern;
|
---|
131 | len2 = lastlen = lastlen + 1;
|
---|
132 | }
|
---|
133 | }
|
---|
134 | else {
|
---|
135 | if ((string[len2] >= lo) && (string[len2] <= hi))
|
---|
136 | len2++;
|
---|
137 | else {
|
---|
138 | tn = pattern;
|
---|
139 | len2 = lastlen = lastlen + 1;
|
---|
140 | }
|
---|
141 | }
|
---|
142 | break;
|
---|
143 |
|
---|
144 | case '?':
|
---|
145 | tn++;
|
---|
146 | len2++;
|
---|
147 | break;
|
---|
148 |
|
---|
149 | case '\\':
|
---|
150 | tn++;
|
---|
151 | if(!*tn)
|
---|
152 | return FALSE;
|
---|
153 | /* else intentional fallthru */
|
---|
154 | default:
|
---|
155 | if(ignore) {
|
---|
156 | if(toupper(*tn) == toupper(string[len2])) {
|
---|
157 | tn++;
|
---|
158 | len2++;
|
---|
159 | }
|
---|
160 | else {
|
---|
161 | tn = pattern;
|
---|
162 | len2 = lastlen = lastlen + 1;
|
---|
163 | }
|
---|
164 | }
|
---|
165 | else {
|
---|
166 | if(*tn == string[len2]) {
|
---|
167 | tn++;
|
---|
168 | len2++;
|
---|
169 | }
|
---|
170 | else {
|
---|
171 | tn = pattern;
|
---|
172 | len2 = lastlen = lastlen + 1;
|
---|
173 | }
|
---|
174 | }
|
---|
175 | break;
|
---|
176 | }
|
---|
177 | }
|
---|
178 | while(*tn == '*')
|
---|
179 | tn++;
|
---|
180 |
|
---|
181 | if (!*tn)
|
---|
182 | return TRUE;
|
---|
183 | }
|
---|
184 | return FALSE;
|
---|
185 | }
|
---|
186 |
|
---|
187 |
|
---|
188 | static BOOL match (CHAR *string,CHAR *patterns,BOOL absolute,BOOL ignore,
|
---|
189 | LONG len,ULONG numlines,CHAR *matched,BOOL matchall) {
|
---|
190 |
|
---|
191 | BOOL ret = FALSE;
|
---|
192 | register CHAR *p;
|
---|
193 | register ULONG x = 0;
|
---|
194 |
|
---|
195 | p = patterns;
|
---|
196 | while(!ret && *p) {
|
---|
197 | ret = m_match(string,p,absolute,ignore,len);
|
---|
198 | if(matchall && ret)
|
---|
199 | break;
|
---|
200 | if(matched && ret && x < numlines)
|
---|
201 | matched[x] = 1;
|
---|
202 | p += strlen(p); /* check each pattern in 0-terminated list */
|
---|
203 | p++;
|
---|
204 | x++;
|
---|
205 | }
|
---|
206 | return ret;
|
---|
207 | }
|
---|
208 |
|
---|
209 |
|
---|
210 | VOID dogrep (VOID *arg) {
|
---|
211 |
|
---|
212 | HAB ghab;
|
---|
213 | HMQ ghmq;
|
---|
214 | GREP grep;
|
---|
215 | register INT x,numfls;
|
---|
216 | static CHAR *fle[512];
|
---|
217 | CHAR *p,*pp,searchPath[CCHMAXPATH * 2];
|
---|
218 |
|
---|
219 | if(!arg)
|
---|
220 | return;
|
---|
221 | grep = *(GREP *)arg;
|
---|
222 | *grep.stopflag = 0; /* reset thread-killing flag */
|
---|
223 | grep.FilesToGet = (grep.dirFlag) ? min(FilesToGet,128) : FilesToGet;
|
---|
224 | DosError(FERR_DISABLEHARDERR);
|
---|
225 | priority_normal();
|
---|
226 |
|
---|
227 | ghab = WinInitialize(0);
|
---|
228 | if(ghab) {
|
---|
229 | grep.ghab = ghab;
|
---|
230 | ghmq = WinCreateMsgQueue(ghab,0);
|
---|
231 | if(ghmq) {
|
---|
232 | WinCancelShutdown(ghmq,TRUE);
|
---|
233 | DosSleep(128L);
|
---|
234 | WinSetWindowText(grep.hwndCurFile,
|
---|
235 | GetPString((grep.finddupes) ?
|
---|
236 | IDS_GREPDUPETEXT : IDS_GREPSCANTEXT));
|
---|
237 |
|
---|
238 | pp = grep.searchPattern;
|
---|
239 | while(*pp) {
|
---|
240 | if(!grep.absFlag) {
|
---|
241 | p = GREPCHARS; /* see if any sense in pattern matching */
|
---|
242 | while(*p) {
|
---|
243 | if(strchr(pp,*p))
|
---|
244 | break;
|
---|
245 | p++;
|
---|
246 | }
|
---|
247 | if(!*p) /* nope, turn it off */
|
---|
248 | grep.absFlag = TRUE;
|
---|
249 | }
|
---|
250 | pp = pp + strlen(pp) + 1;
|
---|
251 | }
|
---|
252 |
|
---|
253 | grep.attrFile &= (~FILE_DIRECTORY);
|
---|
254 | grep.antiattr &= (~FILE_DIRECTORY);
|
---|
255 | if(grep.antiattr & FILE_READONLY)
|
---|
256 | grep.antiattr |= MUST_HAVE_READONLY;
|
---|
257 | if(grep.antiattr & FILE_HIDDEN)
|
---|
258 | grep.antiattr |= MUST_HAVE_HIDDEN;
|
---|
259 | if(grep.antiattr & FILE_SYSTEM)
|
---|
260 | grep.antiattr |= MUST_HAVE_SYSTEM;
|
---|
261 | if(grep.antiattr & FILE_ARCHIVED)
|
---|
262 | grep.antiattr |= MUST_HAVE_ARCHIVED;
|
---|
263 |
|
---|
264 | grep.anyexcludes = FALSE;
|
---|
265 | numfls = x = 0;
|
---|
266 | fle[numfls++] = strtok(grep.tosearch,";");
|
---|
267 | while((fle[numfls] = strtok(NULL,";")) != NULL && numfls < 511) {
|
---|
268 | if(*fle[numfls] == '/')
|
---|
269 | grep.anyexcludes = TRUE;
|
---|
270 | numfls++;
|
---|
271 | }
|
---|
272 |
|
---|
273 | while(x < numfls) { /* loop through search masks */
|
---|
274 |
|
---|
275 | if(*fle[x] == '/') /* is an exclude mask only */
|
---|
276 | goto ExcludeSkip;
|
---|
277 |
|
---|
278 | /* first, separate any path from mask */
|
---|
279 |
|
---|
280 | p = (char *)(fle[x] + (strlen(fle[x]) - 1));
|
---|
281 | while(*p != '\\' && *p != ':' && p != fle[x])
|
---|
282 | --p;
|
---|
283 |
|
---|
284 | if(p == fle[x]) { /* no path */
|
---|
285 | strcpy(searchPath,grep.curdir);
|
---|
286 | strncpy(grep.fileMask,fle[x],CCHMAXPATH);
|
---|
287 | grep.fileMask[CCHMAXPATH - 1] = 0;
|
---|
288 | }
|
---|
289 | else { /* got to deal with a path */
|
---|
290 | if(*p == ':') { /* just a drive, start in root dir */
|
---|
291 | *p = 0;
|
---|
292 | p++;
|
---|
293 | strncpy(searchPath,fle[x],CCHMAXPATH - 2);
|
---|
294 | searchPath[CCHMAXPATH - 3] = 0;
|
---|
295 | strcat(searchPath,":\\");
|
---|
296 | strcpy(grep.fileMask,p);
|
---|
297 | }
|
---|
298 | if(*p == '\\') { /* got a 'full' path */
|
---|
299 |
|
---|
300 | CHAR temp;
|
---|
301 |
|
---|
302 | p++;
|
---|
303 | temp = *p;
|
---|
304 | *p = 0;
|
---|
305 | strncpy(searchPath,fle[x],CCHMAXPATH);
|
---|
306 | searchPath[CCHMAXPATH - 1] = 0;
|
---|
307 | *p = temp;
|
---|
308 | strcpy(grep.fileMask,p);
|
---|
309 | }
|
---|
310 | if(!*grep.fileMask)
|
---|
311 | strcpy(grep.fileMask,"*");
|
---|
312 | }
|
---|
313 | if(*grep.stopflag)
|
---|
314 | break;
|
---|
315 | /* do single directory */
|
---|
316 | domatchingfiles(&grep,searchPath,fle,numfls);
|
---|
317 | if(grep.dirFlag) /* do subdirs */
|
---|
318 | doallsubdirs(&grep,searchPath,FALSE,fle,numfls);
|
---|
319 | ExcludeSkip:
|
---|
320 | if(*grep.stopflag)
|
---|
321 | break;
|
---|
322 | x++ ;
|
---|
323 | if(WinIsWindow(grep.ghab,grep.hwndFiles))
|
---|
324 | doinsertion(&grep); /* insert any remaining objects */
|
---|
325 | }
|
---|
326 |
|
---|
327 | ShutDownThread: /* kill pm connection, end thread */
|
---|
328 |
|
---|
329 | if(WinIsWindow(grep.ghab,grep.hwndFiles))
|
---|
330 | doinsertion(&grep); /* insert any remaining objects */
|
---|
331 |
|
---|
332 | if(WinIsWindow(grep.ghab,grep.hwndFiles) && grep.finddupes &&
|
---|
333 | !*grep.stopflag)
|
---|
334 | FillDupes(&grep);
|
---|
335 |
|
---|
336 | if(!PostMsg(grep.hwndFiles,
|
---|
337 | UM_CONTAINER_FILLED,
|
---|
338 | MPVOID,
|
---|
339 | MPVOID)) /* tell window we're done */
|
---|
340 | WinSendMsg(grep.hwndFiles,
|
---|
341 | UM_CONTAINER_FILLED,
|
---|
342 | MPVOID,
|
---|
343 | MPVOID);
|
---|
344 | WinDestroyMsgQueue(ghmq);
|
---|
345 | }
|
---|
346 | WinTerminate(ghab);
|
---|
347 | }
|
---|
348 | if(!ghmq || !ghab)
|
---|
349 | WinPostMsg(grep.hwndFiles,
|
---|
350 | UM_CONTAINER_FILLED,
|
---|
351 | MPVOID,
|
---|
352 | MPVOID);
|
---|
353 | if(grep.dupehead)
|
---|
354 | FreeDupes(&grep);
|
---|
355 | if(grep.numlines &&
|
---|
356 | grep.matched)
|
---|
357 | free(grep.matched);
|
---|
358 | DosPostEventSem(CompactSem);
|
---|
359 | }
|
---|
360 |
|
---|
361 |
|
---|
362 | static BOOL IsExcluded (char *name,char **fle,int numfls) {
|
---|
363 |
|
---|
364 | register int x;
|
---|
365 | char *n;
|
---|
366 |
|
---|
367 | n = strrchr(name,'\\');
|
---|
368 | if(!n)
|
---|
369 | n = strrchr(name,':');
|
---|
370 | if(n)
|
---|
371 | n++;
|
---|
372 | else
|
---|
373 | n = name;
|
---|
374 | for(x = 0;x < numfls;x++) {
|
---|
375 | if(*fle[x] == '/' &&
|
---|
376 | wildcard((strchr(fle[x],'\\') ||
|
---|
377 | strchr(fle[x],':')) ?
|
---|
378 | name : n,fle[x] + 1,FALSE))
|
---|
379 | return TRUE;
|
---|
380 | }
|
---|
381 | return FALSE;
|
---|
382 | }
|
---|
383 |
|
---|
384 |
|
---|
385 | static VOID doallsubdirs (GREP *grep,CHAR *searchPath,BOOL recursing,
|
---|
386 | char **fle,int numfls) {
|
---|
387 |
|
---|
388 | /* process all subdirectories */
|
---|
389 |
|
---|
390 | FILEFINDBUF4 findBuffer;
|
---|
391 | HDIR findHandle = HDIR_CREATE;
|
---|
392 | LONG findCount = 1L;
|
---|
393 | CHAR *p = NULL;
|
---|
394 |
|
---|
395 | /* add a mask to search path */
|
---|
396 | if(searchPath[strlen(searchPath) - 1] != '\\')
|
---|
397 | strcat(searchPath,"\\");
|
---|
398 | strcat(searchPath,"*");
|
---|
399 | /* step through all subdirectories */
|
---|
400 | DosError(FERR_DISABLEHARDERR);
|
---|
401 | if(!DosFindFirst(searchPath,&findHandle,(MUST_HAVE_DIRECTORY |
|
---|
402 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN | FILE_READONLY),
|
---|
403 | &findBuffer,
|
---|
404 | (ULONG)sizeof(findBuffer),
|
---|
405 | (PULONG)&findCount,
|
---|
406 | FIL_QUERYEASIZE)) {
|
---|
407 |
|
---|
408 | /* get rid of mask portion, save end-of-directory */
|
---|
409 |
|
---|
410 | p = strrchr(searchPath,'\\');
|
---|
411 | if(p)
|
---|
412 | p++;
|
---|
413 | else
|
---|
414 | p = searchPath;
|
---|
415 | do { /* Process each directory that matches the mask */
|
---|
416 | priority_normal();
|
---|
417 | if(*grep->stopflag)
|
---|
418 | break;
|
---|
419 | if(*findBuffer.achName != '.' ||
|
---|
420 | (findBuffer.achName[1] && findBuffer.achName[1] != '.')) {
|
---|
421 | strcpy(p,findBuffer.achName) ;
|
---|
422 | if(!grep->anyexcludes || !IsExcluded(searchPath,fle,numfls)) {
|
---|
423 | domatchingfiles(grep,searchPath,fle,numfls) ;
|
---|
424 | doallsubdirs(grep,searchPath,TRUE,fle,numfls);
|
---|
425 | DosSleep(0L);
|
---|
426 | }
|
---|
427 | }
|
---|
428 | findCount = 1L;
|
---|
429 | } while(!DosFindNext(findHandle,
|
---|
430 | &findBuffer,
|
---|
431 | sizeof(findBuffer),
|
---|
432 | (PULONG)&findCount));
|
---|
433 | DosFindClose(findHandle);
|
---|
434 | priority_normal();
|
---|
435 | }
|
---|
436 | if(p) /* strip off last directory addition */
|
---|
437 | *p = 0;
|
---|
438 | }
|
---|
439 |
|
---|
440 |
|
---|
441 | static INT domatchingfiles (GREP *grep,CHAR *path,char **fle,int numfls) {
|
---|
442 |
|
---|
443 | /* process all matching files in a directory */
|
---|
444 |
|
---|
445 | PFILEFINDBUF4 findBuffer = malloc(grep->FilesToGet * sizeof(FILEFINDBUF4));
|
---|
446 | PFILEFINDBUF4 pffbFile;
|
---|
447 | register PBYTE fb;
|
---|
448 | register ULONG x;
|
---|
449 | HDIR findHandle = HDIR_CREATE;
|
---|
450 | ULONG findCount = grep->FilesToGet;
|
---|
451 | CHAR newPath[CCHMAXPATH],*p;
|
---|
452 | APIRET rc;
|
---|
453 |
|
---|
454 | if(!findBuffer)
|
---|
455 | return 0;
|
---|
456 |
|
---|
457 | /* build filemask */
|
---|
458 |
|
---|
459 | sprintf(newPath,
|
---|
460 | "%s%s%s",
|
---|
461 | path,
|
---|
462 | (path[strlen(path) - 1] == '\\') ?
|
---|
463 | NullStr : "\\",
|
---|
464 | grep->fileMask);
|
---|
465 |
|
---|
466 | MakeFullName(newPath);
|
---|
467 |
|
---|
468 | /* find and save end-of-dir position */
|
---|
469 | p = strrchr(newPath,'\\');
|
---|
470 | if(p)
|
---|
471 | p++;
|
---|
472 | else
|
---|
473 | p = newPath;
|
---|
474 |
|
---|
475 | /* step through matching files */
|
---|
476 | DosError(FERR_DISABLEHARDERR);
|
---|
477 | if(!DosFindFirst(newPath,
|
---|
478 | &findHandle,
|
---|
479 | (FILE_NORMAL | grep->attrFile | grep->antiattr),
|
---|
480 | findBuffer,
|
---|
481 | (ULONG)(grep->FilesToGet * sizeof(FILEFINDBUF4)),
|
---|
482 | (PULONG)&findCount,
|
---|
483 | FIL_QUERYEASIZE)) {
|
---|
484 |
|
---|
485 | do { /* Process each file that matches the mask */
|
---|
486 | priority_normal();
|
---|
487 | fb = (PBYTE)findBuffer;
|
---|
488 | for(x = 0L;x < findCount;x++) {
|
---|
489 | pffbFile = (PFILEFINDBUF4)fb;
|
---|
490 | if(*grep->stopflag)
|
---|
491 | break;
|
---|
492 | if(*pffbFile->achName != '.' ||
|
---|
493 | (pffbFile->achName[1] && pffbFile->achName[1] != '.')) {
|
---|
494 | strcpy(p,pffbFile->achName); /* build filename */
|
---|
495 | if(!grep->anyexcludes ||
|
---|
496 | !IsExcluded(newPath,fle,numfls)) {
|
---|
497 | if(!grep->finddupes)
|
---|
498 | doonefile(grep,
|
---|
499 | newPath,
|
---|
500 | pffbFile);
|
---|
501 | else if(!InsertDupe(grep,
|
---|
502 | newPath,
|
---|
503 | pffbFile)) {
|
---|
504 | DosFindClose(findHandle);
|
---|
505 | free(findBuffer);
|
---|
506 | return 1;
|
---|
507 | }
|
---|
508 | }
|
---|
509 | }
|
---|
510 | if(!pffbFile->oNextEntryOffset)
|
---|
511 | break;
|
---|
512 | fb += pffbFile->oNextEntryOffset;
|
---|
513 | }
|
---|
514 | findCount = grep->FilesToGet;
|
---|
515 | rc = DosFindNext(findHandle,
|
---|
516 | findBuffer,
|
---|
517 | (ULONG)(grep->FilesToGet * sizeof(FILEFINDBUF4)),
|
---|
518 | (PULONG)&findCount);
|
---|
519 | if(!rc)
|
---|
520 | DosSleep(1L);
|
---|
521 | } while(!rc);
|
---|
522 | DosFindClose(findHandle);
|
---|
523 | priority_normal();
|
---|
524 | }
|
---|
525 | free(findBuffer);
|
---|
526 | return 0 ;
|
---|
527 | }
|
---|
528 |
|
---|
529 | #pragma alloc_text(GREP,insert_grepfile,doonefile,doinsertion,freegreplist)
|
---|
530 |
|
---|
531 |
|
---|
532 | static VOID freegreplist (GREP *grep) {
|
---|
533 |
|
---|
534 | register INT x;
|
---|
535 |
|
---|
536 | if(grep) {
|
---|
537 | if(grep->insertffb) {
|
---|
538 | for(x = 0;grep->insertffb[x];x++)
|
---|
539 | free(grep->insertffb[x]);
|
---|
540 | free(grep->insertffb);
|
---|
541 | }
|
---|
542 | if(grep->dir) {
|
---|
543 | for(x = 0;grep->dir[x];x++)
|
---|
544 | free(grep->dir[x]);
|
---|
545 | free(grep->dir);
|
---|
546 | }
|
---|
547 | grep->dir = NULL;
|
---|
548 | grep->insertffb = NULL;
|
---|
549 | grep->toinsert = 0L;
|
---|
550 | grep->insertedbytes = 0L;
|
---|
551 | }
|
---|
552 | }
|
---|
553 |
|
---|
554 |
|
---|
555 | static BOOL doinsertion (GREP *grep) {
|
---|
556 |
|
---|
557 | RECORDINSERT ri;
|
---|
558 | DIRCNRDATA *dcd;
|
---|
559 | PCNRITEM pci,pciFirst;
|
---|
560 | INT x;
|
---|
561 |
|
---|
562 | if(!grep ||
|
---|
563 | !grep->toinsert ||
|
---|
564 | !grep->insertffb ||
|
---|
565 | !grep->dir)
|
---|
566 | return FALSE;
|
---|
567 | pci = WinSendMsg(grep->hwndFiles,
|
---|
568 | CM_ALLOCRECORD,
|
---|
569 | MPFROMLONG(EXTRA_RECORD_BYTES),
|
---|
570 | MPFROMLONG(grep->toinsert));
|
---|
571 | if(pci) {
|
---|
572 | if(grep->sayfiles)
|
---|
573 | WinSetWindowText(grep->hwndCurFile,
|
---|
574 | GetPString(IDS_GREPINSERTINGTEXT));
|
---|
575 | pciFirst = pci;
|
---|
576 | dcd = INSTDATA(grep->hwndFiles);
|
---|
577 | for(x = 0; grep->insertffb[x]; x++) {
|
---|
578 | FillInRecordFromFFB(grep->hwndFiles,
|
---|
579 | pci,
|
---|
580 | grep->dir[x],
|
---|
581 | grep->insertffb[x],
|
---|
582 | FALSE,
|
---|
583 | dcd);
|
---|
584 | pci = (PCNRITEM) pci->rc.preccNextRecord;
|
---|
585 | }
|
---|
586 | memset(&ri,0,sizeof(RECORDINSERT));
|
---|
587 | ri.cb = sizeof(RECORDINSERT);
|
---|
588 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
589 | ri.pRecordParent = (PRECORDCORE)NULL;
|
---|
590 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
591 | ri.cRecordsInsert = grep->toinsert;
|
---|
592 | ri.fInvalidateRecord = TRUE;
|
---|
593 | WinSendMsg(grep->hwndFiles,
|
---|
594 | CM_INSERTRECORD,
|
---|
595 | MPFROMP(pciFirst),
|
---|
596 | MPFROMP(&ri));
|
---|
597 | if(dcd) {
|
---|
598 | DosEnterCritSec();
|
---|
599 | dcd->totalbytes += grep->insertedbytes;
|
---|
600 | DosExitCritSec();
|
---|
601 | }
|
---|
602 | if(grep->toinsert == grep->FilesToGet)
|
---|
603 | DosSleep(1L);
|
---|
604 | freegreplist(grep);
|
---|
605 | PostMsg(grep->hwndFiles,
|
---|
606 | UM_RESCAN,
|
---|
607 | MPVOID,
|
---|
608 | MPVOID);
|
---|
609 | return TRUE;
|
---|
610 | }
|
---|
611 | freegreplist(grep);
|
---|
612 | return FALSE;
|
---|
613 | }
|
---|
614 |
|
---|
615 |
|
---|
616 | static BOOL insert_grepfile (GREP *grep,CHAR *filename,FILEFINDBUF4 *f) {
|
---|
617 |
|
---|
618 | CHAR *p,szDirectory[CCHMAXPATH];
|
---|
619 |
|
---|
620 | if(WinIsWindow(grep->ghab,grep->hwndFiles)) {
|
---|
621 | grep->numfiles++;
|
---|
622 | strcpy(szDirectory,filename);
|
---|
623 | p = strrchr(szDirectory,'\\');
|
---|
624 | if(p) {
|
---|
625 | if(p < szDirectory + 4)
|
---|
626 | p++;
|
---|
627 | *p = 0;
|
---|
628 | if(!grep->insertffb) {
|
---|
629 | grep->insertffb = malloc(sizeof(FILEFINDBUF4 *) *
|
---|
630 | (grep->FilesToGet + 1));
|
---|
631 | if(!grep->insertffb)
|
---|
632 | return FALSE;
|
---|
633 | memset(grep->insertffb,0,sizeof(FILEFINDBUF4 *) *
|
---|
634 | (grep->FilesToGet + 1));
|
---|
635 | grep->dir = malloc(sizeof(CHAR *) * (grep->FilesToGet + 1));
|
---|
636 | if(!grep->dir) {
|
---|
637 | free(grep->insertffb);
|
---|
638 | return FALSE;
|
---|
639 | }
|
---|
640 | memset(grep->dir,0,sizeof(CHAR *) * (grep->FilesToGet + 1));
|
---|
641 | }
|
---|
642 | grep->insertffb[grep->toinsert] = malloc(sizeof(FILEFINDBUF4));
|
---|
643 | if(!grep->insertffb[grep->toinsert])
|
---|
644 | return FALSE;
|
---|
645 | memcpy(grep->insertffb[grep->toinsert],f,sizeof(FILEFINDBUF4));
|
---|
646 | grep->dir[grep->toinsert] = strdup(szDirectory);
|
---|
647 | if(!grep->dir) {
|
---|
648 | free(grep->insertffb[grep->toinsert]);
|
---|
649 | return FALSE;
|
---|
650 | }
|
---|
651 | grep->insertedbytes += (f->cbFile + ((f->cbList > 4L) ? f->cbList : 0L));
|
---|
652 | grep->toinsert++;
|
---|
653 | if(grep->toinsert == grep->FilesToGet)
|
---|
654 | return doinsertion(grep);
|
---|
655 | return TRUE;
|
---|
656 | }
|
---|
657 | }
|
---|
658 | else
|
---|
659 | freegreplist(grep);
|
---|
660 | return FALSE;
|
---|
661 | }
|
---|
662 |
|
---|
663 |
|
---|
664 | static BOOL doonefile (GREP *grep,CHAR *filename,FILEFINDBUF4 *f) {
|
---|
665 |
|
---|
666 | /* process a single file */
|
---|
667 |
|
---|
668 | CHAR *input;
|
---|
669 | FILE *inputFile;
|
---|
670 | ULONG pos;
|
---|
671 | BOOL ret = FALSE,strmatch = FALSE;
|
---|
672 |
|
---|
673 | grep->fileCount++;
|
---|
674 | if(grep->sayfiles)
|
---|
675 | WinSetWindowText(grep->hwndCurFile,
|
---|
676 | filename);
|
---|
677 |
|
---|
678 | if(grep->greaterthan || grep->lessthan) {
|
---|
679 |
|
---|
680 | BOOL keep = TRUE;
|
---|
681 | ULONG adjsize;
|
---|
682 |
|
---|
683 | adjsize = f->cbFile + ((grep->searchEAs) ?
|
---|
684 | ((f->cbList > 4L) ?
|
---|
685 | 0L :
|
---|
686 | f->cbList) :
|
---|
687 | 0L);
|
---|
688 | if(grep->greaterthan) {
|
---|
689 | if(adjsize < grep->greaterthan)
|
---|
690 | keep = FALSE;
|
---|
691 | }
|
---|
692 | if(keep && grep->lessthan) {
|
---|
693 | if(adjsize > grep->lessthan)
|
---|
694 | keep = FALSE;
|
---|
695 | }
|
---|
696 | if(!keep)
|
---|
697 | return ret;
|
---|
698 | }
|
---|
699 |
|
---|
700 | if(grep->newerthan || grep->olderthan) {
|
---|
701 |
|
---|
702 | BOOL keep = TRUE;
|
---|
703 | ULONG numsecs;
|
---|
704 |
|
---|
705 | numsecs = SecsSince1980(&f->fdateLastWrite,
|
---|
706 | &f->ftimeLastWrite);
|
---|
707 | if(grep->newerthan) {
|
---|
708 | if(numsecs < grep->newerthan)
|
---|
709 | keep = FALSE;
|
---|
710 | }
|
---|
711 | if(keep && grep->olderthan) {
|
---|
712 | if(numsecs > grep->olderthan)
|
---|
713 | keep = FALSE;
|
---|
714 | }
|
---|
715 | if(!keep)
|
---|
716 | return ret;
|
---|
717 | }
|
---|
718 |
|
---|
719 | if((!grep->searchEAs && !grep->searchFiles) ||
|
---|
720 | !*grep->searchPattern) /* just a find */
|
---|
721 | return insert_grepfile(grep,filename,f);
|
---|
722 |
|
---|
723 | if(grep->searchEAs) {
|
---|
724 |
|
---|
725 | HOLDFEA *head,*info;
|
---|
726 | USHORT codepage,num,type,len;
|
---|
727 | BOOL alltext;
|
---|
728 | CHAR *data,temp;
|
---|
729 |
|
---|
730 | head = GetFileEAs(filename,FALSE,TRUE);
|
---|
731 | if(head) {
|
---|
732 | info = head;
|
---|
733 | while(info && !strmatch) {
|
---|
734 | alltext = TRUE;
|
---|
735 | switch(*(USHORT *)info->value) {
|
---|
736 | case EAT_ASCII:
|
---|
737 | if(match(info->value + (sizeof(USHORT) * 2),
|
---|
738 | grep->searchPattern,grep->absFlag,
|
---|
739 | (grep->caseFlag == FALSE),
|
---|
740 | info->cbValue - (sizeof(USHORT) * 2),
|
---|
741 | grep->numlines,
|
---|
742 | grep->matched,
|
---|
743 | !grep->findifany)) {
|
---|
744 | Free_FEAList(head);
|
---|
745 | strmatch = TRUE;
|
---|
746 | }
|
---|
747 | break;
|
---|
748 | case EAT_MVST:
|
---|
749 | codepage = *(USHORT *)(info->value + sizeof(USHORT));
|
---|
750 | num = *(USHORT *)(info->value + (sizeof(USHORT) * 2));
|
---|
751 | type = *(USHORT *)(info->value + (sizeof(USHORT) * 3));
|
---|
752 | if(type == EAT_ASCII) {
|
---|
753 | data = info->value + (sizeof(USHORT) * 4);
|
---|
754 | len = *(USHORT *)data;
|
---|
755 | data += sizeof(USHORT);
|
---|
756 | while((data - info->value) + len <=
|
---|
757 | info->cbValue) {
|
---|
758 | temp = *(data + len);
|
---|
759 | *(data + len) = 0;
|
---|
760 | if(match(data,
|
---|
761 | grep->searchPattern,
|
---|
762 | grep->absFlag,
|
---|
763 | (grep->caseFlag == FALSE),
|
---|
764 | len,
|
---|
765 | grep->numlines,
|
---|
766 | grep->matched,
|
---|
767 | !grep->findifany)) {
|
---|
768 | Free_FEAList(head);
|
---|
769 | strmatch = TRUE;
|
---|
770 | break;
|
---|
771 | }
|
---|
772 | data += len;
|
---|
773 | if(data - info->value >= info->cbValue)
|
---|
774 | break;
|
---|
775 | *data = temp;
|
---|
776 | len = *(USHORT *)data;
|
---|
777 | data += sizeof(USHORT);
|
---|
778 | }
|
---|
779 | }
|
---|
780 | break;
|
---|
781 | case EAT_MVMT:
|
---|
782 | codepage = *(USHORT *)(info->value + sizeof(USHORT));
|
---|
783 | num = *(USHORT *)(info->value + (sizeof(USHORT) * 2));
|
---|
784 | data = info->value + (sizeof(USHORT) * 3);
|
---|
785 | type = *(USHORT *)data;
|
---|
786 | data += sizeof(USHORT);
|
---|
787 | len = *(USHORT *)data;
|
---|
788 | data += sizeof(USHORT);
|
---|
789 | while((data - info->value) - len <=
|
---|
790 | info->cbValue) {
|
---|
791 | if(type != EAT_ASCII) {
|
---|
792 | alltext = FALSE;
|
---|
793 | break;
|
---|
794 | }
|
---|
795 | data += len;
|
---|
796 | if(data - info->value >= info->cbValue)
|
---|
797 | break;
|
---|
798 | type = *(USHORT *)data;
|
---|
799 | data += sizeof(USHORT);
|
---|
800 | len = *(USHORT *)data;
|
---|
801 | data += sizeof(USHORT);
|
---|
802 | }
|
---|
803 | if(alltext) {
|
---|
804 | data = info->value + (sizeof(USHORT) * 3);
|
---|
805 | type = *(USHORT *)data;
|
---|
806 | data += sizeof(USHORT);
|
---|
807 | len = *(USHORT *)data;
|
---|
808 | data += sizeof(USHORT);
|
---|
809 | while((data - info->value) - len <=
|
---|
810 | info->cbValue) {
|
---|
811 | temp = *(data + len);
|
---|
812 | *(data + len) = 0;
|
---|
813 | if(match(data,
|
---|
814 | grep->searchPattern,
|
---|
815 | grep->absFlag,
|
---|
816 | (grep->caseFlag == FALSE),
|
---|
817 | len,
|
---|
818 | grep->numlines,
|
---|
819 | grep->matched,
|
---|
820 | !grep->findifany)) {
|
---|
821 | Free_FEAList(head);
|
---|
822 | strmatch = TRUE;
|
---|
823 | break;
|
---|
824 | }
|
---|
825 | data += len;
|
---|
826 | *data = temp;
|
---|
827 | if(data - info->value >= info->cbValue)
|
---|
828 | break;
|
---|
829 | type = *(USHORT *)data;
|
---|
830 | data += sizeof(USHORT);
|
---|
831 | len = *(USHORT *)data;
|
---|
832 | data += sizeof(USHORT);
|
---|
833 | }
|
---|
834 | }
|
---|
835 | break;
|
---|
836 | default:
|
---|
837 | break;
|
---|
838 | }
|
---|
839 | info = info->next;
|
---|
840 | }
|
---|
841 | Free_FEAList(head);
|
---|
842 | DosSleep(1L);
|
---|
843 | }
|
---|
844 | }
|
---|
845 |
|
---|
846 | if(grep->searchFiles) {
|
---|
847 | input = malloc(65537);
|
---|
848 | if(input) {
|
---|
849 |
|
---|
850 | LONG len;
|
---|
851 |
|
---|
852 | if((inputFile = _fsopen(filename,"rb",SH_DENYNO)) != NULL) {
|
---|
853 | pos = ftell(inputFile);
|
---|
854 | while(!feof(inputFile)) {
|
---|
855 | if(pos)
|
---|
856 | fseek(inputFile,pos - 1024,SEEK_SET);
|
---|
857 | len = fread(input,1,65536,inputFile);
|
---|
858 | if(len >= 0) {
|
---|
859 | if(*grep->stopflag)
|
---|
860 | break;
|
---|
861 | if(match(input,
|
---|
862 | grep->searchPattern,
|
---|
863 | grep->absFlag,
|
---|
864 | (grep->caseFlag == FALSE),
|
---|
865 | len,
|
---|
866 | grep->numlines,
|
---|
867 | grep->matched,
|
---|
868 | !grep->findifany)) {
|
---|
869 | strmatch = TRUE;
|
---|
870 | break;
|
---|
871 | }
|
---|
872 | }
|
---|
873 | else
|
---|
874 | break;
|
---|
875 | }
|
---|
876 | fclose(inputFile) ;
|
---|
877 | }
|
---|
878 | free(input);
|
---|
879 | DosSleep(1L);
|
---|
880 | }
|
---|
881 | }
|
---|
882 |
|
---|
883 | Match:
|
---|
884 |
|
---|
885 | if(strmatch)
|
---|
886 | ret = insert_grepfile(grep,
|
---|
887 | filename,
|
---|
888 | f);
|
---|
889 | return ret;
|
---|
890 | }
|
---|
891 |
|
---|
892 |
|
---|
893 | #pragma alloc_text(DUPES,InsertDupe,FillDupes,FreeDupes,CRCFile,CRCBlock)
|
---|
894 | #pragma alloc_text(DUPES,comparenamesq,comparenamesqe,comparenamesb)
|
---|
895 | #pragma alloc_text(DUPES,comparenamesbe,comparesizesq,comparesizesb)
|
---|
896 |
|
---|
897 | static LONG cr3tab[] = { /* CRC polynomial 0xEDB88320 */
|
---|
898 |
|
---|
899 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
---|
900 | 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
---|
901 | 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
---|
902 | 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
|
---|
903 | 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
---|
904 | 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
---|
905 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
|
---|
906 | 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
|
---|
907 | 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
---|
908 | 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
---|
909 | 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
|
---|
910 | 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
---|
911 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
|
---|
912 | 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
|
---|
913 | 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
---|
914 | 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
|
---|
915 | 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
|
---|
916 | 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
---|
917 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
|
---|
918 | 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
---|
919 | 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
---|
920 | 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
|
---|
921 | 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
|
---|
922 | 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
---|
923 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
---|
924 | 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
|
---|
925 | 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
---|
926 | 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
|
---|
927 | 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
|
---|
928 | 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
---|
929 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
|
---|
930 | 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
|
---|
931 | 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
---|
932 | 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
|
---|
933 | 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
---|
934 | 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
---|
935 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
|
---|
936 | 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
|
---|
937 | 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
---|
938 | 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
---|
939 | 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
|
---|
940 | 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
---|
941 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
|
---|
942 | 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
|
---|
943 | 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
---|
944 | 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
|
---|
945 | 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
|
---|
946 | 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
---|
947 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
|
---|
948 | 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
---|
949 | 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
---|
950 | 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
|
---|
951 | 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
|
---|
952 | 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
---|
953 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
---|
954 | 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
|
---|
955 | 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
---|
956 | 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
|
---|
957 | 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
|
---|
958 | 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
---|
959 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
|
---|
960 | 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
|
---|
961 | 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
---|
962 | 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
---|
963 | };
|
---|
964 |
|
---|
965 |
|
---|
966 | LONG CRCBlock (register CHAR *str, register INT blklen, register LONG crc) {
|
---|
967 |
|
---|
968 | while (blklen--) {
|
---|
969 | crc = cr3tab[((INT) crc ^ *str) & 0xff] ^ ((crc >> 8) & 0x00FFFFFF);
|
---|
970 | str++;
|
---|
971 | }
|
---|
972 | return crc;
|
---|
973 | }
|
---|
974 |
|
---|
975 |
|
---|
976 | LONG CRCFile (CHAR *filename,INT *error) {
|
---|
977 |
|
---|
978 | LONG CRC = -1L,len;
|
---|
979 | FILE *fp;
|
---|
980 | CHAR *buffer;
|
---|
981 |
|
---|
982 | *error = 0;
|
---|
983 | buffer = malloc(65535);
|
---|
984 | if(buffer) {
|
---|
985 | fp = _fsopen(filename,"rb",SH_DENYNO);
|
---|
986 | if(fp) {
|
---|
987 | while(!feof(fp)) {
|
---|
988 | len = fread(buffer,1,65535,fp);
|
---|
989 | if(len && len < 65536L)
|
---|
990 | CRC = CRCBlock(buffer,len,CRC);
|
---|
991 | else
|
---|
992 | break;
|
---|
993 | DosSleep(0L);
|
---|
994 | }
|
---|
995 | fclose(fp);
|
---|
996 | DosSleep(1L);
|
---|
997 | }
|
---|
998 | else
|
---|
999 | *error = -2;
|
---|
1000 | free(buffer);
|
---|
1001 | }
|
---|
1002 | else
|
---|
1003 | *error = -1;
|
---|
1004 | return CRC;
|
---|
1005 | }
|
---|
1006 |
|
---|
1007 |
|
---|
1008 | static VOID FreeDupes (GREP *g) {
|
---|
1009 |
|
---|
1010 | DUPES *i,*next;
|
---|
1011 |
|
---|
1012 | i = g->dupehead;
|
---|
1013 | while(i) {
|
---|
1014 | next = i->next;
|
---|
1015 | if(i->name)
|
---|
1016 | free(i->name);
|
---|
1017 | free(i);
|
---|
1018 | i = next;
|
---|
1019 | }
|
---|
1020 | g->dupehead = g->dupelast = NULL;
|
---|
1021 | if(g->dupenames)
|
---|
1022 | free(g->dupenames);
|
---|
1023 | if(g->dupesizes)
|
---|
1024 | free(g->dupesizes);
|
---|
1025 | g->dupesizes = g->dupenames = NULL;
|
---|
1026 | }
|
---|
1027 |
|
---|
1028 |
|
---|
1029 | int comparenamesq (const void *v1,const void *v2) {
|
---|
1030 |
|
---|
1031 | DUPES *d1 = *(DUPES **)v1;
|
---|
1032 | DUPES *d2 = *(DUPES **)v2;
|
---|
1033 | CHAR *p1,*p2;
|
---|
1034 |
|
---|
1035 | p1 = strrchr(d1->name,'\\');
|
---|
1036 | if(p1)
|
---|
1037 | p1++;
|
---|
1038 | else
|
---|
1039 | p1 = d1->name;
|
---|
1040 | p2 = strrchr(d2->name,'\\');
|
---|
1041 | if(p2)
|
---|
1042 | p2++;
|
---|
1043 | else
|
---|
1044 | p2 = d2->name;
|
---|
1045 | return stricmp(p1,p2);
|
---|
1046 | }
|
---|
1047 |
|
---|
1048 |
|
---|
1049 | int comparenamesqe (const void *v1,const void *v2) {
|
---|
1050 |
|
---|
1051 | DUPES *d1 = *(DUPES **)v1;
|
---|
1052 | DUPES *d2 = *(DUPES **)v2;
|
---|
1053 | CHAR *p1,*p2,*p1e,*p2e,e1,e2;
|
---|
1054 | int ret;
|
---|
1055 |
|
---|
1056 | p1 = strrchr(d1->name,'\\');
|
---|
1057 | if(p1)
|
---|
1058 | p1++;
|
---|
1059 | else
|
---|
1060 | p1 = d1->name;
|
---|
1061 | p1e = strrchr(p1,'.');
|
---|
1062 | if(p1e) {
|
---|
1063 | e1 = *p1e;
|
---|
1064 | *p1e = 0;
|
---|
1065 | }
|
---|
1066 | p2 = strrchr(d2->name,'\\');
|
---|
1067 | if(p2)
|
---|
1068 | p2++;
|
---|
1069 | else
|
---|
1070 | p2 = d2->name;
|
---|
1071 | p2e = strrchr(p2,'.');
|
---|
1072 | if(p2e) {
|
---|
1073 | e2 = *p2e;
|
---|
1074 | *p2e = 0;
|
---|
1075 | }
|
---|
1076 | ret = stricmp(p1,p2);
|
---|
1077 | if(p1e)
|
---|
1078 | *p1e = e1;
|
---|
1079 | if(p2e)
|
---|
1080 | *p2e = e2;
|
---|
1081 | return ret;
|
---|
1082 | }
|
---|
1083 |
|
---|
1084 |
|
---|
1085 | int comparesizesq (const void *v1,const void *v2) {
|
---|
1086 |
|
---|
1087 | DUPES *d1 = *(DUPES **)v1;
|
---|
1088 | DUPES *d2 = *(DUPES **)v2;
|
---|
1089 |
|
---|
1090 | return (d1->size > d2->size) ? 1 : (d1->size == d2->size) ? 0 : -1;
|
---|
1091 | }
|
---|
1092 |
|
---|
1093 |
|
---|
1094 | int comparenamesb (const void *v1,const void *v2) {
|
---|
1095 |
|
---|
1096 | DUPES *d1 = (DUPES *)v1;
|
---|
1097 | DUPES *d2 = *(DUPES **)v2;
|
---|
1098 | CHAR *p1,*p2;
|
---|
1099 |
|
---|
1100 | p1 = strrchr(d1->name,'\\');
|
---|
1101 | if(p1)
|
---|
1102 | p1++;
|
---|
1103 | else
|
---|
1104 | p1 = d1->name;
|
---|
1105 | p2 = strrchr(d2->name,'\\');
|
---|
1106 | if(p2)
|
---|
1107 | p2++;
|
---|
1108 | else
|
---|
1109 | p2 = d2->name;
|
---|
1110 | return stricmp(p1,p2);
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 |
|
---|
1114 | int comparenamesbe (const void *v1,const void *v2) {
|
---|
1115 |
|
---|
1116 | DUPES *d1 = (DUPES *)v1;
|
---|
1117 | DUPES *d2 = *(DUPES **)v2;
|
---|
1118 | CHAR *p1,*p2,*p1e,*p2e,e1,e2;
|
---|
1119 | int ret;
|
---|
1120 |
|
---|
1121 | p1 = strrchr(d1->name,'\\');
|
---|
1122 | if(p1)
|
---|
1123 | p1++;
|
---|
1124 | else
|
---|
1125 | p1 = d1->name;
|
---|
1126 | p1e = strrchr(p1,'.');
|
---|
1127 | if(p1e) {
|
---|
1128 | e1 = *p1e;
|
---|
1129 | *p1e = 0;
|
---|
1130 | }
|
---|
1131 | p2 = strrchr(d2->name,'\\');
|
---|
1132 | if(p2)
|
---|
1133 | p2++;
|
---|
1134 | else
|
---|
1135 | p2 = d2->name;
|
---|
1136 | p2e = strrchr(p2,'.');
|
---|
1137 | if(p2e) {
|
---|
1138 | e2 = *p2e;
|
---|
1139 | *p2e = 0;
|
---|
1140 | }
|
---|
1141 | ret = stricmp(p1,p2);
|
---|
1142 | if(p1e)
|
---|
1143 | *p1e = e1;
|
---|
1144 | if(p2e)
|
---|
1145 | *p2e = e2;
|
---|
1146 | return ret;
|
---|
1147 | }
|
---|
1148 |
|
---|
1149 |
|
---|
1150 | int comparesizesb (const void *v1,const void *v2) {
|
---|
1151 |
|
---|
1152 | DUPES *d1 = (DUPES *)v1;
|
---|
1153 | DUPES *d2 = *(DUPES **)v2;
|
---|
1154 |
|
---|
1155 | return (d1->size > d2->size) ? 1 : (d1->size == d2->size) ? 0 : -1;
|
---|
1156 | }
|
---|
1157 |
|
---|
1158 |
|
---|
1159 | static VOID FillDupes (GREP *g) {
|
---|
1160 |
|
---|
1161 | DUPES *c,*i,**r;
|
---|
1162 | register CHAR *pc,*pi;
|
---|
1163 | CHAR **list = NULL;
|
---|
1164 | INT numfiles = 0,numalloced = 0,error;
|
---|
1165 | register ULONG x = 0L,y = 0L;
|
---|
1166 | ULONG cntr = 100;
|
---|
1167 |
|
---|
1168 | if(g->CRCdupes)
|
---|
1169 | cntr = 50;
|
---|
1170 | i = g->dupehead;
|
---|
1171 | while(i) {
|
---|
1172 | x++;
|
---|
1173 | i = i->next;
|
---|
1174 | }
|
---|
1175 | if(x) {
|
---|
1176 | WinSetWindowText(g->hwndCurFile,
|
---|
1177 | GetPString(IDS_GREPDUPESORTINGTEXT));
|
---|
1178 | DosSleep(1L);
|
---|
1179 | g->dupenames = malloc(sizeof(DUPES *) * (x + 1));
|
---|
1180 | if(!g->nosizedupes)
|
---|
1181 | g->dupesizes = malloc(sizeof(DUPES *) * (x + 1));
|
---|
1182 | if(g->dupenames && (g->nosizedupes || g->dupesizes)) {
|
---|
1183 | i = g->dupehead;
|
---|
1184 | while(i) {
|
---|
1185 | g->dupenames[y] = i;
|
---|
1186 | if(!g->nosizedupes)
|
---|
1187 | g->dupesizes[y] = i;
|
---|
1188 | i = i->next;
|
---|
1189 | y++;
|
---|
1190 | }
|
---|
1191 | g->dupenames[y] = NULL;
|
---|
1192 | if(!g->nosizedupes)
|
---|
1193 | g->dupesizes[y] = NULL;
|
---|
1194 | DosSleep(1L);
|
---|
1195 | qsort(g->dupenames,
|
---|
1196 | x,
|
---|
1197 | sizeof(DUPES *),
|
---|
1198 | ((g->ignoreextdupes) ?
|
---|
1199 | comparenamesqe :
|
---|
1200 | comparenamesq));
|
---|
1201 | DosSleep(1L);
|
---|
1202 | if(!g->nosizedupes) {
|
---|
1203 | qsort(g->dupesizes,
|
---|
1204 | x,
|
---|
1205 | sizeof(DUPES *),
|
---|
1206 | comparesizesq);
|
---|
1207 | DosSleep(1L);
|
---|
1208 | }
|
---|
1209 | WinSetWindowText(g->hwndCurFile,
|
---|
1210 | GetPString(IDS_GREPDUPECOMPARINGTEXT));
|
---|
1211 |
|
---|
1212 | i = g->dupehead;
|
---|
1213 | y = 0L;
|
---|
1214 | while(i) {
|
---|
1215 | if(*g->stopflag)
|
---|
1216 | break;
|
---|
1217 | if(!(i->flags & GF_SKIPME)) {
|
---|
1218 | r = (DUPES **)bsearch(i,g->dupenames,x,sizeof(DUPES *),
|
---|
1219 | ((g->ignoreextdupes) ? comparenamesbe :
|
---|
1220 | comparenamesb));
|
---|
1221 | if(r) {
|
---|
1222 | while(r > g->dupenames && ((g->ignoreextdupes) ?
|
---|
1223 | !comparenamesqe((r - 1),&i) :
|
---|
1224 | !comparenamesq((r - 1),&i)))
|
---|
1225 | r--;
|
---|
1226 | while(*r && ((g->ignoreextdupes) ?
|
---|
1227 | !comparenamesqe(r,&i) :
|
---|
1228 | !comparenamesq(r,&i))) {
|
---|
1229 | if(*r == i || ((*r)->flags & (GF_INSERTED | GF_SKIPME))) {
|
---|
1230 | r++;
|
---|
1231 | continue;
|
---|
1232 | }
|
---|
1233 | if(g->CRCdupes) {
|
---|
1234 | if((*r)->CRC == -1L) {
|
---|
1235 | (*r)->CRC = CRCFile((*r)->name,&error);
|
---|
1236 | if(error)
|
---|
1237 | (*r)->CRC = -1L;
|
---|
1238 | else if((*r)->CRC == -1L)
|
---|
1239 | (*r)->CRC = 0L;
|
---|
1240 | }
|
---|
1241 | if(i->CRC == -1L) {
|
---|
1242 | i->CRC = CRCFile(i->name,&error);
|
---|
1243 | if(error)
|
---|
1244 | i->CRC = -1L;
|
---|
1245 | else if(i->CRC == -1L)
|
---|
1246 | i->CRC = 0L;
|
---|
1247 | }
|
---|
1248 | if(((*r)->size != i->size) || ((*r)->CRC != -1L &&
|
---|
1249 | i->CRC != -1L && (*r)->CRC != i->CRC)) {
|
---|
1250 | r++;
|
---|
1251 | continue;
|
---|
1252 | }
|
---|
1253 | }
|
---|
1254 | if(!AddToList((*r)->name,
|
---|
1255 | &list,
|
---|
1256 | &numfiles,
|
---|
1257 | &numalloced)) {
|
---|
1258 | (*r)->flags |= GF_INSERTED;
|
---|
1259 | if(g->sayfiles)
|
---|
1260 | WinSetWindowText(g->hwndFiles,
|
---|
1261 | (*r)->name);
|
---|
1262 | if((*r)->size == i->size &&
|
---|
1263 | (i->date.year == (*r)->date.year &&
|
---|
1264 | i->date.month == (*r)->date.month &&
|
---|
1265 | i->date.day == (*r)->date.day &&
|
---|
1266 | i->time.hours == (*r)->time.hours &&
|
---|
1267 | i->time.minutes == (*r)->time.minutes &&
|
---|
1268 | i->time.twosecs == (*r)->time.twosecs))
|
---|
1269 | (*r)->flags |= GF_SKIPME;
|
---|
1270 | }
|
---|
1271 | if(!(i->flags & (GF_INSERTED | GF_SKIPME))) {
|
---|
1272 | if(!AddToList(i->name,
|
---|
1273 | &list,
|
---|
1274 | &numfiles,
|
---|
1275 | &numalloced)) {
|
---|
1276 | i->flags |= GF_INSERTED;
|
---|
1277 | if((*r)->flags & GF_SKIPME)
|
---|
1278 | i->flags |= GF_SKIPME;
|
---|
1279 | }
|
---|
1280 | }
|
---|
1281 | r++;
|
---|
1282 | }
|
---|
1283 | }
|
---|
1284 | if(!g->nosizedupes) {
|
---|
1285 | r = (DUPES **)bsearch(i,
|
---|
1286 | g->dupesizes,
|
---|
1287 | x,
|
---|
1288 | sizeof(DUPES *),
|
---|
1289 | comparesizesb);
|
---|
1290 | if(r) {
|
---|
1291 | while(r > g->dupesizes && !comparesizesq((r - 1),&i))
|
---|
1292 | r--;
|
---|
1293 | while(*r && !comparesizesq(r,&i)) {
|
---|
1294 | if(*r == i || ((*r)->flags & (GF_INSERTED | GF_SKIPME)) ||
|
---|
1295 | (i->date.year != (*r)->date.year ||
|
---|
1296 | i->date.month != (*r)->date.month ||
|
---|
1297 | i->date.day != (*r)->date.day ||
|
---|
1298 | i->time.hours != (*r)->time.hours ||
|
---|
1299 | i->time.minutes != (*r)->time.minutes ||
|
---|
1300 | i->time.twosecs != (*r)->time.twosecs)) {
|
---|
1301 | r++;
|
---|
1302 | continue;
|
---|
1303 | }
|
---|
1304 | if(g->CRCdupes) {
|
---|
1305 | if((*r)->CRC == -1L) {
|
---|
1306 | (*r)->CRC = CRCFile((*r)->name,&error);
|
---|
1307 | if(error)
|
---|
1308 | (*r)->CRC = -1L;
|
---|
1309 | else if((*r)->CRC == -1L)
|
---|
1310 | (*r)->CRC = 0L;
|
---|
1311 | }
|
---|
1312 | if(i->CRC == -1L) {
|
---|
1313 | i->CRC = CRCFile(i->name,&error);
|
---|
1314 | if(error)
|
---|
1315 | i->CRC = -1L;
|
---|
1316 | else if(i->CRC == -1L)
|
---|
1317 | i->CRC = 0L;
|
---|
1318 | }
|
---|
1319 | if((*r)->CRC != -1L && i->CRC != -1L &&
|
---|
1320 | (*r)->CRC != i->CRC) {
|
---|
1321 | *r++;
|
---|
1322 | continue;
|
---|
1323 | }
|
---|
1324 | }
|
---|
1325 | if(!AddToList((*r)->name,
|
---|
1326 | &list,
|
---|
1327 | &numfiles,
|
---|
1328 | &numalloced)) {
|
---|
1329 | if(g->sayfiles)
|
---|
1330 | WinSetWindowText(g->hwndCurFile,
|
---|
1331 | (*r)->name);
|
---|
1332 | (*r)->flags |= GF_INSERTED;
|
---|
1333 | if(((g->ignoreextdupes) ?
|
---|
1334 | comparenamesqe(r,&i) :
|
---|
1335 | comparenamesq(r,&i)))
|
---|
1336 | (*r)->flags |= GF_SKIPME;
|
---|
1337 | }
|
---|
1338 | if(!(i->flags & (GF_INSERTED | GF_SKIPME))) {
|
---|
1339 | if(!AddToList(i->name,
|
---|
1340 | &list,
|
---|
1341 | &numfiles,
|
---|
1342 | &numalloced)) {
|
---|
1343 | i->flags |= GF_INSERTED;
|
---|
1344 | if((*r)->flags & GF_SKIPME)
|
---|
1345 | i->flags |= GF_SKIPME;
|
---|
1346 | }
|
---|
1347 | }
|
---|
1348 | r++;
|
---|
1349 | }
|
---|
1350 | }
|
---|
1351 | }
|
---|
1352 | }
|
---|
1353 | i = i->next;
|
---|
1354 | y++;
|
---|
1355 | if(!(y % cntr)) {
|
---|
1356 |
|
---|
1357 | CHAR s[44];
|
---|
1358 |
|
---|
1359 | sprintf(s,
|
---|
1360 | GetPString(IDS_GREPDUPECHECKPROGTEXT),
|
---|
1361 | y,
|
---|
1362 | g->numfiles);
|
---|
1363 | WinSetWindowText(g->hwndCurFile,
|
---|
1364 | s);
|
---|
1365 | DosSleep(128L);
|
---|
1366 | }
|
---|
1367 | DosSleep(y % 2);
|
---|
1368 | }
|
---|
1369 | }
|
---|
1370 | else {
|
---|
1371 | DosBeep(50,100);
|
---|
1372 | WinSetWindowText(g->hwndCurFile,
|
---|
1373 | GetPString(IDS_GREPDUPECOMPARINGTEXT));
|
---|
1374 | x = y = 0L;
|
---|
1375 | if(g->dupenames) {
|
---|
1376 | free(g->dupenames);
|
---|
1377 | g->dupenames = NULL;
|
---|
1378 | }
|
---|
1379 | if(g->dupesizes) {
|
---|
1380 | free(g->dupesizes);
|
---|
1381 | g->dupesizes = NULL;
|
---|
1382 | }
|
---|
1383 | i = g->dupehead;
|
---|
1384 | while(i) {
|
---|
1385 | if(*g->stopflag)
|
---|
1386 | break;
|
---|
1387 | if(!(i->flags & GF_SKIPME)) {
|
---|
1388 | if(!(y % cntr)) {
|
---|
1389 |
|
---|
1390 | CHAR s[44];
|
---|
1391 |
|
---|
1392 | sprintf(s,
|
---|
1393 | GetPString(IDS_GREPDUPECHECKPROGTEXT),
|
---|
1394 | y,
|
---|
1395 | g->numfiles);
|
---|
1396 | WinSetWindowText(g->hwndCurFile,
|
---|
1397 | s);
|
---|
1398 | DosSleep(0L);
|
---|
1399 | }
|
---|
1400 | y++;
|
---|
1401 | pi = strrchr(i->name,'\\');
|
---|
1402 | if(pi)
|
---|
1403 | *pi++;
|
---|
1404 | else
|
---|
1405 | pi = i->name;
|
---|
1406 | c = g->dupehead;
|
---|
1407 | while(c) {
|
---|
1408 | if(*g->stopflag)
|
---|
1409 | break;
|
---|
1410 | if(c != i && !(c->flags & (GF_INSERTED | GF_SKIPME))) {
|
---|
1411 | x++;
|
---|
1412 | pc = strrchr(c->name,'\\');
|
---|
1413 | if(pc)
|
---|
1414 | pc++;
|
---|
1415 | else
|
---|
1416 | pc = c->name;
|
---|
1417 | if((!g->nosizedupes && i->size == c->size &&
|
---|
1418 | i->date.year == c->date.year &&
|
---|
1419 | i->date.month == c->date.month &&
|
---|
1420 | i->date.day == c->date.day &&
|
---|
1421 | i->time.hours == c->time.hours &&
|
---|
1422 | i->time.minutes == c->time.minutes &&
|
---|
1423 | i->time.twosecs == c->time.twosecs) ||
|
---|
1424 | !stricmp(pc,pi)) { /* potential dupe */
|
---|
1425 | if(g->CRCdupes) {
|
---|
1426 | if(g->CRCdupes) {
|
---|
1427 | if(c->CRC == -1L) {
|
---|
1428 | c->CRC = CRCFile(c->name,&error);
|
---|
1429 | if(error)
|
---|
1430 | c->CRC = -1L;
|
---|
1431 | else if(c->CRC == -1L)
|
---|
1432 | c->CRC = 0L;
|
---|
1433 | }
|
---|
1434 | if(i->CRC == -1L) {
|
---|
1435 | i->CRC = CRCFile(i->name,&error);
|
---|
1436 | if(error)
|
---|
1437 | i->CRC = -1L;
|
---|
1438 | else if(i->CRC == -1L)
|
---|
1439 | i->CRC = 0L;
|
---|
1440 | }
|
---|
1441 | if((c->size != i->size) || (c->CRC != -1L &&
|
---|
1442 | i->CRC != -1L && c->CRC != i->CRC)) {
|
---|
1443 | c = c->next;
|
---|
1444 | continue;
|
---|
1445 | }
|
---|
1446 | }
|
---|
1447 | }
|
---|
1448 | if(AddToList(c->name,
|
---|
1449 | &list,
|
---|
1450 | &numfiles,
|
---|
1451 | &numalloced))
|
---|
1452 | goto BreakOut;
|
---|
1453 | if(!(i->flags & GF_INSERTED)) {
|
---|
1454 | if(AddToList(i->name,
|
---|
1455 | &list,
|
---|
1456 | &numfiles,
|
---|
1457 | &numalloced))
|
---|
1458 | goto BreakOut;
|
---|
1459 | }
|
---|
1460 | if(g->sayfiles)
|
---|
1461 | WinSetWindowText(g->hwndCurFile,
|
---|
1462 | pc);
|
---|
1463 | c->flags |= GF_INSERTED;
|
---|
1464 | i->flags |= GF_INSERTED;
|
---|
1465 | if(!stricmp(pc,pi)) {
|
---|
1466 | c->flags |= GF_SKIPME;
|
---|
1467 | i->flags |= GF_SKIPME;
|
---|
1468 | }
|
---|
1469 | }
|
---|
1470 | else if(!(x % 100L))
|
---|
1471 | DosSleep(1L);
|
---|
1472 | }
|
---|
1473 | c = c->next;
|
---|
1474 | }
|
---|
1475 | }
|
---|
1476 | i = i->next;
|
---|
1477 | }
|
---|
1478 | }
|
---|
1479 | }
|
---|
1480 | BreakOut:
|
---|
1481 | FreeDupes(g);
|
---|
1482 | if(numfiles && list) {
|
---|
1483 | if(!PostMsg(g->hwndFiles,
|
---|
1484 | WM_COMMAND,
|
---|
1485 | MPFROM2SHORT(IDM_COLLECTOR,0),
|
---|
1486 | MPFROMP(list)))
|
---|
1487 | FreeList(list);
|
---|
1488 | }
|
---|
1489 | else
|
---|
1490 | DosPostEventSem(CompactSem);
|
---|
1491 | }
|
---|
1492 |
|
---|
1493 |
|
---|
1494 | static BOOL InsertDupe (GREP *g,CHAR *dir,FILEFINDBUF4 *f) {
|
---|
1495 |
|
---|
1496 | DUPES *info;
|
---|
1497 |
|
---|
1498 | if(*dir) {
|
---|
1499 | info = malloc(sizeof(DUPES));
|
---|
1500 | if(info) {
|
---|
1501 | memset(info,0,sizeof(DUPES));
|
---|
1502 | info->name = strdup(dir);
|
---|
1503 | if(info->name) {
|
---|
1504 | info->size = f->cbFile;
|
---|
1505 | info->date = f->fdateLastWrite;
|
---|
1506 | info->time = f->ftimeLastWrite;
|
---|
1507 | info->CRC = -1L;
|
---|
1508 | g->numfiles++;
|
---|
1509 | if(!g->dupehead)
|
---|
1510 | g->dupehead = info;
|
---|
1511 | if(g->dupelast)
|
---|
1512 | g->dupelast->next = info;
|
---|
1513 | g->dupelast = info;
|
---|
1514 | info->next = NULL;
|
---|
1515 | return TRUE;
|
---|
1516 | }
|
---|
1517 | else
|
---|
1518 | free(info);
|
---|
1519 | }
|
---|
1520 | DosBeep(50,100);
|
---|
1521 | return FALSE;
|
---|
1522 | }
|
---|
1523 | return TRUE;
|
---|
1524 | }
|
---|
1525 |
|
---|