source: trunk/dll/filldir.c@ 51

Last change on this file since 51 was 51, checked in by root, 23 years ago

Standardize EA match

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 49.1 KB
Line 
1
2/***********************************************************************
3
4 $Id: filldir.c 51 2003-02-12 20:22:14Z root $
5
6 Fill Directory Tree Containers
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2001, 2002 Steven H.Levine
10
11 Revisions 12 Sep 02 SHL - Rework symbols to understand code
12 08 Feb 03 SHL - DropHelp: calc EA size consistently
13
14***********************************************************************/
15
16
17#define INCL_DOS
18#define INCL_WIN
19
20#include <os2.h>
21#include <stdarg.h>
22#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
25#include <ctype.h>
26#include <time.h>
27#include "fm3dll.h"
28#include "fm3str.h"
29
30#pragma alloc_text(FILLDIR,FillInRecordFromFFB,FillInRecordFromFSA,IDFile)
31#pragma alloc_text(FILLDIR1,ProcessDirectory,FillDirCnr,FillTreeCnr)
32
33
34HPOINTER IDFile (ULONG cmp) {
35
36 HPOINTER hptr;
37
38 hptr = (HPOINTER)0;
39 if(cmp == *(ULONG *)".EXE" || cmp == *(ULONG *)".CMD" ||
40 cmp == *(ULONG *)".BAT" || cmp == *(ULONG *)".COM")
41 hptr = hptrApp;
42 else if(cmp == *(ULONG *)".ZIP" || cmp == *(ULONG *)".LZH" ||
43 cmp == *(ULONG *)".ARJ" || cmp == *(ULONG *)".ARC" ||
44 cmp == *(ULONG *)".ZOO" || cmp == *(ULONG *)".RAR")
45 hptr = hptrArc;
46 else if(cmp == *(ULONG *)".BMP" || cmp == *(ULONG *)".ICO" ||
47 cmp == *(ULONG *)".PTR" || cmp == *(ULONG *)".GIF" ||
48 cmp == *(ULONG *)".TIF" || cmp == *(ULONG *)".PCX" ||
49 cmp == *(ULONG *)".TGA" || cmp == *(ULONG *)".XBM")
50 hptr = hptrArt;
51 return hptr;
52}
53
54
55ULONG FillInRecordFromFFB (HWND hwndCnr,PCNRITEM pci, const PSZ pszDirectory,
56 const PFILEFINDBUF4 pffb,const BOOL partial,
57 DIRCNRDATA *dcd)
58{
59
60 /* fill in a container record from a FILEFINDBUF4 structure */
61
62 CHAR attrstring[] = "RHS\0DA",cmps[] = ".xxx";
63 register CHAR *p;
64 HPOINTER hptr;
65 register INT x,y;
66 INT t;
67 ULONG cmp;
68
69 pci->hwndCnr = hwndCnr;
70 t = strlen(pszDirectory);
71 memcpy(pci->szFileName,pszDirectory,t + 1);
72 /* note! we cheat below, and accept the full pathname in pszDirectory
73 if !*pffb->achName. speeds up and simplifies processing elsewhere
74 (like in update.c) */
75 if(*pffb->achName) {
76 p = pci->szFileName + (t - 1);
77 if(*p != '\\') {
78 p++;
79 *p = '\\';
80 }
81 p++;
82 memcpy(p,pffb->achName,pffb->cchName + 1);
83 }
84 /* load the object's Subject, if required */
85 if(pffb->cbList > 4L &&
86 dcd && fLoadSubject &&
87 (isalpha(*pci->szFileName) &&
88 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADSUBJS))) {
89
90 APIRET rc;
91 EAOP2 eaop;
92 PGEA2LIST pgealist;
93 PFEA2LIST pfealist;
94 PGEA2 pgea;
95 PFEA2 pfea;
96 CHAR *value;
97
98 pgealist = malloc(sizeof(GEA2LIST) + 32);
99 if(pgealist) {
100 memset(pgealist,0,sizeof(GEA2LIST) + 32);
101 pgea = &pgealist->list[0];
102 strcpy(pgea->szName,SUBJECT);
103 pgea->cbName = strlen(pgea->szName);
104 pgea->oNextEntryOffset = 0L;
105 pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
106 pfealist = malloc(1532);
107 if(pfealist) {
108 memset(pfealist,0,1532);
109 pfealist->cbList = 1024;
110 eaop.fpGEA2List = pgealist;
111 eaop.fpFEA2List = pfealist;
112 eaop.oError = 0L;
113 rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
114 (PVOID)&eaop,(ULONG)sizeof(EAOP2));
115 if(!rc) {
116 pfea = &eaop.fpFEA2List->list[0];
117 value = pfea->szName + pfea->cbName + 1;
118 value[pfea->cbValue] = 0;
119 if(*(USHORT *)value == EAT_ASCII)
120 strncpy(pci->subject,value + (sizeof(USHORT) * 2),39);
121 pci->subject[39] = 0;
122 }
123 free(pfealist);
124 }
125 free(pgealist);
126 }
127 }
128 pci->pszSubject = pci->subject;
129 /* load the object's longname */
130 *pci->Longname = 0;
131 if(pffb->cbList > 4L &&
132 dcd && fLoadLongnames &&
133 (isalpha(*pci->szFileName) &&
134 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLONGNAMES) &&
135 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADLONGS))) {
136
137 APIRET rc;
138 EAOP2 eaop;
139 PGEA2LIST pgealist;
140 PFEA2LIST pfealist;
141 PGEA2 pgea;
142 PFEA2 pfea;
143 CHAR *value;
144
145 pgealist = malloc(sizeof(GEA2LIST) + 32);
146 if(pgealist) {
147 memset(pgealist,0,sizeof(GEA2LIST) + 32);
148 pgea = &pgealist->list[0];
149 strcpy(pgea->szName,LONGNAME);
150 pgea->cbName = strlen(pgea->szName);
151 pgea->oNextEntryOffset = 0L;
152 pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
153 pfealist = malloc(1532);
154 if(pfealist) {
155 memset(pfealist,0,1532);
156 pfealist->cbList = 1024;
157 eaop.fpGEA2List = pgealist;
158 eaop.fpFEA2List = pfealist;
159 eaop.oError = 0L;
160 rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
161 (PVOID)&eaop,(ULONG)sizeof(EAOP2));
162 if(!rc) {
163 pfea = &eaop.fpFEA2List->list[0];
164 value = pfea->szName + pfea->cbName + 1;
165 value[pfea->cbValue] = 0;
166 if(*(USHORT *)value == EAT_ASCII)
167 strncpy(pci->Longname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP);
168 pci->Longname[CCHMAXPATHCOMP - 1] = 0;
169 }
170 free(pfealist);
171 }
172 free(pgealist);
173 }
174 }
175 pci->pszLongname = pci->Longname;
176
177 /* do anything required to case of filename */
178 if(fForceUpper)
179 strupr(pci->szFileName);
180 else if(fForceLower)
181 strlwr(pci->szFileName);
182
183 /* get an icon to use with it */
184 if(pffb->attrFile & FILE_DIRECTORY) {
185 if(!fNoIconsDirs && (!isalpha(*pci->szFileName) ||
186 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))
187 hptr = WinLoadFileIcon(pci->szFileName, FALSE);
188 else
189 hptr = (HPOINTER)0;
190 }
191 else {
192 if (!fNoIconsFiles && (!isalpha(*pci->szFileName) ||
193 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))
194 hptr = WinLoadFileIcon(pci->szFileName, FALSE);
195 else
196 hptr = (HPOINTER)0;
197 if (!hptr || hptr == WinQuerySysPointer(HWND_DESKTOP,SPTR_FILE,FALSE)) {
198 p = strrchr(pci->szFileName,'.');
199 if(p && !p[4]) {
200 cmps[1] = toupper(p[1]);
201 cmps[2] = toupper(p[2]);
202 cmps[3] = toupper(p[3]);
203 cmp = *(ULONG *)cmps;
204 hptr = IDFile(cmp);
205 }
206 else
207 hptr = (HPOINTER)0;
208 }
209 }
210 if(!hptr)
211 hptr = ((pffb->attrFile & FILE_DIRECTORY) != 0) ? hptrDir :
212 ((pffb->attrFile & FILE_SYSTEM) != 0) ? hptrSystem :
213 ((pffb->attrFile & FILE_HIDDEN) != 0) ? hptrHidden :
214 ((pffb->attrFile & FILE_READONLY) != 0) ? hptrReadonly :
215 hptrFile;
216
217 /* decide where to point for the container's title text */
218 if(partial) {
219 p = strrchr(pci->szFileName,'\\');
220 if(!p) {
221 p = strrchr(pci->szFileName,':');
222 if(!p)
223 p = pci->szFileName;
224 else
225 p++;
226 }
227 else if((dcd && dcd->type == TREE_FRAME) ||
228 (!(pffb->attrFile & FILE_DIRECTORY) || !*(p + 1)))
229 p++;
230 if(!*p)
231 p = pci->szFileName;
232 }
233 else
234 p = pci->szFileName;
235 /* now fill the darned thing in... */
236 pci->pszFileName = p;
237 pci->date.day = pffb->fdateLastWrite.day;
238 pci->date.month = pffb->fdateLastWrite.month;
239 pci->date.year = pffb->fdateLastWrite.year + 1980;
240 pci->time.seconds = pffb->ftimeLastWrite.twosecs * 2;
241 pci->time.minutes = pffb->ftimeLastWrite.minutes;
242 pci->time.hours = pffb->ftimeLastWrite.hours;
243 pci->ladate.day = pffb->fdateLastAccess.day;
244 pci->ladate.month = pffb->fdateLastAccess.month;
245 pci->ladate.year = pffb->fdateLastAccess.year + 1980;
246 pci->latime.seconds = pffb->ftimeLastAccess.twosecs * 2;
247 pci->latime.minutes = pffb->ftimeLastAccess.minutes;
248 pci->latime.hours = pffb->ftimeLastAccess.hours;
249 pci->crdate.day = pffb->fdateCreation.day;
250 pci->crdate.month = pffb->fdateCreation.month;
251 pci->crdate.year = pffb->fdateCreation.year + 1980;
252 pci->crtime.seconds = pffb->ftimeCreation.twosecs * 2;
253 pci->crtime.minutes = pffb->ftimeCreation.minutes;
254 pci->crtime.hours = pffb->ftimeCreation.hours;
255 pci->easize = CBLIST_TO_EASIZE(pffb->cbList);
256 pci->cbFile = pffb->cbFile;
257 pci->attrFile = pffb->attrFile;
258 /* build attribute string for display */
259 y = 0;
260 for(x = 0;x < 6;x++)
261 if(attrstring[x])
262 pci->szDispAttr[y++] = (CHAR)((pci->attrFile & (1 << x)) ?
263 attrstring[x] : '-');
264 pci->szDispAttr[5] = 0;
265 pci->pszDispAttr = pci->szDispAttr;
266 pci->rc.pszIcon = pci->pszFileName;
267 pci->rc.hptrIcon = hptr;
268
269 /* check to see if record should be visible */
270 if(dcd && (*dcd->mask.szMask || dcd->mask.antiattr ||
271 ((dcd->mask.attrFile &
272 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) !=
273 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)))) {
274 if(*dcd->mask.szMask || dcd->mask.antiattr) {
275 if(!Filter((PMINIRECORDCORE)pci,(PVOID)&dcd->mask))
276 pci->rc.flRecordAttr |= CRA_FILTERED;
277 }
278 else if((!(dcd->mask.attrFile & FILE_HIDDEN) &&
279 (pci->attrFile & FILE_HIDDEN)) ||
280 (!(dcd->mask.attrFile & FILE_SYSTEM) &&
281 (pci->attrFile & FILE_SYSTEM)) ||
282 (!(dcd->mask.attrFile & FILE_READONLY) &&
283 (pci->attrFile & FILE_READONLY)) ||
284 (!(dcd->mask.attrFile & FILE_ARCHIVED) &&
285 (pci->attrFile & FILE_ARCHIVED)))
286 pci->rc.flRecordAttr |= CRA_FILTERED;
287 }
288
289 return pffb->cbFile + pci->easize;
290}
291
292
293ULONG FillInRecordFromFSA (HWND hwndCnr,PCNRITEM pci,const PSZ pszFileName,
294 const PFILESTATUS4 pfsa4,
295 const BOOL partial,
296 DIRCNRDATA *dcd)
297{
298
299 HPOINTER hptr;
300 CHAR attrstring[] = "RHS\0DA",cmps[] = ".xxx";
301 register CHAR *p;
302 register INT x,y;
303 ULONG cmp;
304
305 /* fill in a container record from a FILESTATUS4 structure */
306
307 pci->hwndCnr = hwndCnr;
308 strcpy(pci->szFileName,pszFileName);
309 /* load the object's Subject, if required */
310 if(pfsa4->cbList > 4L &&
311 dcd && fLoadSubject &&
312 (!isalpha(*pci->szFileName) ||
313 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADSUBJS))) {
314
315 APIRET rc;
316 EAOP2 eaop;
317 PGEA2LIST pgealist;
318 PFEA2LIST pfealist;
319 PGEA2 pgea;
320 PFEA2 pfea;
321 CHAR *value;
322
323 pgealist = malloc(sizeof(GEA2LIST) + 32);
324 if(pgealist) {
325 memset(pgealist,0,sizeof(GEA2LIST) + 32);
326 pgea = &pgealist->list[0];
327 strcpy(pgea->szName,SUBJECT);
328 pgea->cbName = strlen(pgea->szName);
329 pgea->oNextEntryOffset = 0L;
330 pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
331 pfealist = malloc(1532);
332 if(pfealist) {
333 memset(pfealist,0,1532);
334 pfealist->cbList = 1024;
335 eaop.fpGEA2List = pgealist;
336 eaop.fpFEA2List = pfealist;
337 eaop.oError = 0L;
338 rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
339 (PVOID)&eaop,
340 (ULONG)sizeof(EAOP2));
341 if(!rc) {
342 pfea = &eaop.fpFEA2List->list[0];
343 value = pfea->szName + pfea->cbName + 1;
344 value[pfea->cbValue] = 0;
345 if(*(USHORT *)value == EAT_ASCII)
346 strncpy(pci->subject,value + (sizeof(USHORT) * 2),39);
347 pci->subject[39] = 0;
348 }
349 free(pfealist);
350 }
351 free(pgealist);
352 }
353 }
354 pci->pszSubject = pci->subject;
355 *pci->Longname = 0;
356 if(pfsa4->cbList > 4L &&
357 dcd && fLoadLongnames &&
358 (!isalpha(*pci->szFileName) ||
359 ((driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLONGNAMES) &&
360 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADLONGS))))
361 {
362 APIRET rc;
363 EAOP2 eaop;
364 PGEA2LIST pgealist;
365 PFEA2LIST pfealist;
366 PGEA2 pgea;
367 PFEA2 pfea;
368 CHAR *value;
369
370 pgealist = malloc(sizeof(GEA2LIST) + 32);
371 if(pgealist) {
372 memset(pgealist,0,sizeof(GEA2LIST) + 32);
373 pgea = &pgealist->list[0];
374 strcpy(pgea->szName,LONGNAME);
375 pgea->cbName = strlen(pgea->szName);
376 pgea->oNextEntryOffset = 0L;
377 pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
378 pfealist = malloc(1532);
379 if(pfealist) {
380 memset(pfealist,0,1532);
381 pfealist->cbList = 1024;
382 eaop.fpGEA2List = pgealist;
383 eaop.fpFEA2List = pfealist;
384 eaop.oError = 0L;
385 rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
386 (PVOID)&eaop,(ULONG)sizeof(EAOP2));
387 if(!rc) {
388 pfea = &eaop.fpFEA2List->list[0];
389 value = pfea->szName + pfea->cbName + 1;
390 value[pfea->cbValue] = 0;
391 if(*(USHORT *)value == EAT_ASCII)
392 strncpy(pci->Longname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP);
393 pci->Longname[CCHMAXPATHCOMP - 1] = 0;
394 }
395 free(pfealist);
396 }
397 free(pgealist);
398 }
399 }
400 pci->pszLongname = pci->Longname;
401 if(fForceUpper)
402 strupr(pci->szFileName);
403 else if(fForceLower)
404 strlwr(pci->szFileName);
405
406 if(pfsa4->attrFile & FILE_DIRECTORY) {
407 if(!fNoIconsDirs && (!isalpha(*pci->szFileName) ||
408 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))
409 hptr = WinLoadFileIcon(pci->szFileName, FALSE);
410 else
411 hptr = (HPOINTER)0;
412 }
413 else {
414 if(!fNoIconsFiles && (!isalpha(*pci->szFileName) ||
415 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))
416 hptr = WinLoadFileIcon(pci->szFileName, FALSE);
417 else {
418 p = strrchr(pci->szFileName,'.');
419 if(p && !p[4]) {
420 cmps[1] = toupper(p[1]);
421 cmps[2] = toupper(p[2]);
422 cmps[3] = toupper(p[3]);
423 cmp = *(ULONG *)cmps;
424 hptr = IDFile(cmp);
425 }
426 else
427 hptr = (HPOINTER)0;
428 }
429 }
430 if(!hptr)
431 hptr = ((pfsa4->attrFile & FILE_DIRECTORY) != 0) ? hptrDir :
432 ((pfsa4->attrFile & FILE_SYSTEM) != 0) ? hptrSystem :
433 ((pfsa4->attrFile & FILE_HIDDEN) != 0) ? hptrHidden :
434 ((pfsa4->attrFile & FILE_READONLY) != 0) ? hptrReadonly :
435 hptrFile;
436
437 if(partial) {
438 p = strrchr(pci->szFileName,'\\');
439 if(!p) {
440 p = strrchr(pci->szFileName,':');
441 if(!p)
442 p = pci->szFileName;
443 else
444 p++;
445 }
446 else if((dcd && dcd->type == TREE_FRAME) ||
447 (!(pfsa4->attrFile & FILE_DIRECTORY) || !*(p + 1)))
448 p++;
449 if(!*p)
450 p = pci->szFileName;
451 }
452 else
453 p = pci->szFileName;
454 pci->pszFileName = p;
455 pci->date.day = pfsa4->fdateLastWrite.day;
456 pci->date.month = pfsa4->fdateLastWrite.month;
457 pci->date.year = pfsa4->fdateLastWrite.year + 1980;
458 pci->time.seconds = pfsa4->ftimeLastWrite.twosecs * 2;
459 pci->time.minutes = pfsa4->ftimeLastWrite.minutes;
460 pci->time.hours = pfsa4->ftimeLastWrite.hours;
461 pci->ladate.day = pfsa4->fdateLastAccess.day;
462 pci->ladate.month = pfsa4->fdateLastAccess.month;
463 pci->ladate.year = pfsa4->fdateLastAccess.year + 1980;
464 pci->latime.seconds = pfsa4->ftimeLastAccess.twosecs * 2;
465 pci->latime.minutes = pfsa4->ftimeLastAccess.minutes;
466 pci->latime.hours = pfsa4->ftimeLastAccess.hours;
467 pci->crdate.day = pfsa4->fdateCreation.day;
468 pci->crdate.month = pfsa4->fdateCreation.month;
469 pci->crdate.year = pfsa4->fdateCreation.year + 1980;
470 pci->crtime.seconds = pfsa4->ftimeCreation.twosecs * 2;
471 pci->crtime.minutes = pfsa4->ftimeCreation.minutes;
472 pci->crtime.hours = pfsa4->ftimeCreation.hours;
473 pci->easize = CBLIST_TO_EASIZE(pfsa4->cbList);
474 pci->cbFile = pfsa4->cbFile;
475 pci->attrFile = pfsa4->attrFile;
476 y = 0;
477 for(x = 0;x < 6;x++)
478 if(attrstring[x])
479 pci->szDispAttr[y++] = (CHAR)((pci->attrFile & (1 << x)) ?
480 attrstring[x] : '-');
481 pci->szDispAttr[5] = 0;
482 pci->pszDispAttr = pci->szDispAttr;
483 pci->rc.pszIcon = pci->pszFileName;
484 pci->rc.hptrIcon = hptr;
485
486 if(dcd && (*dcd->mask.szMask || dcd->mask.antiattr ||
487 ((dcd->mask.attrFile &
488 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) !=
489 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)))) {
490 if(*dcd->mask.szMask || dcd->mask.antiattr) {
491 if(!Filter((PMINIRECORDCORE)pci,(PVOID)&dcd->mask))
492 pci->rc.flRecordAttr |= CRA_FILTERED;
493 }
494 else if((!(dcd->mask.attrFile & FILE_HIDDEN) &&
495 (pci->attrFile & FILE_HIDDEN)) ||
496 (!(dcd->mask.attrFile & FILE_SYSTEM) &&
497 (pci->attrFile & FILE_SYSTEM)) ||
498 (!(dcd->mask.attrFile & FILE_READONLY) &&
499 (pci->attrFile & FILE_READONLY)) ||
500 (!(dcd->mask.attrFile & FILE_ARCHIVED) &&
501 (pci->attrFile & FILE_ARCHIVED)))
502 pci->rc.flRecordAttr |= CRA_FILTERED;
503 }
504
505 return pfsa4->cbFile + pci->easize;
506}
507
508
509ULONG ProcessDirectory (const HWND hwndCnr, const PCNRITEM pciParent,
510 const CHAR *szDirBase, const BOOL filestoo,
511 const BOOL recurse,const BOOL partial,
512 CHAR *stopflag,DIRCNRDATA *dcd,ULONG *foundany)
513{
514
515 /* put all the directories (and files if filestoo is TRUE) from a
516 * directory into the container. recurse through subdirectories if
517 * recurse is TRUE.
518 */
519
520 PSZ pszFileSpec;
521 INT t;
522 PFILEFINDBUF4 paffbFound,*papffbSelected,pffbFile,paffbTotal = NULL,paffbTemp;
523 HDIR hdir = HDIR_CREATE;
524 ULONG ulMaxFiles,ulExtraBytes,ulM = 1L,ulTotal = 0L;
525 LONG numbytes,totalbytes,returnbytes = 0L;
526 PCH pchEndPath;
527 APIRET rc;
528 PCNRITEM pci,pciFirst,pcit;
529 RECORDINSERT ri;
530 register PBYTE pByte,pByte2;
531
532 if(foundany)
533 (*foundany) = 0L;
534 if(isalpha(*szDirBase) && szDirBase[1] == ':' && szDirBase[2] == '\\') {
535// if(!(driveflags[toupper(*szDirBase) - 'A'] & DRIVE_NOLONGNAMES))
536 ulExtraBytes = EXTRA_RECORD_BYTES;
537// else
538// ulExtraBytes = EXTRA_RECORD_BYTES2;
539 if((driveflags[toupper(*szDirBase) - 'A'] & DRIVE_REMOTE) && fRemoteBug)
540 ulM = 1L; /* file system gets confused */
541 else if(driveflags[toupper(*szDirBase) - 'A'] & DRIVE_ZIPSTREAM)
542 ulM = min(FilesToGet,225); /* anything more is wasted */
543 else
544 ulM = FilesToGet; /* full-out */
545 }
546 else {
547 ulExtraBytes = EXTRA_RECORD_BYTES;
548 ulM = FilesToGet;
549 }
550 if(OS2ver[0] == 20 && OS2ver[1] < 30)
551 ulM = min(ulM,(65535 / sizeof(FILEFINDBUF4)));
552
553 ulMaxFiles = ulM;
554 pszFileSpec = malloc(CCHMAXPATH + 2);
555 paffbFound = malloc((ulM + 1L) * sizeof(FILEFINDBUF4));
556 papffbSelected = malloc((ulM + 1L) * sizeof(PFILEFINDBUF4));
557 if(paffbFound && papffbSelected && pszFileSpec) {
558 t = strlen(szDirBase);
559 memcpy(pszFileSpec,szDirBase,t + 1);
560 pchEndPath = pszFileSpec + t;
561 if(*(pchEndPath - 1) != '\\') {
562 memcpy(pchEndPath,"\\",2);
563 pchEndPath++;
564 }
565 memcpy(pchEndPath,"*",2);
566 DosError(FERR_DISABLEHARDERR);
567 rc = DosFindFirst(pszFileSpec, &hdir,
568 FILE_NORMAL | ((filestoo) ? FILE_DIRECTORY :
569 MUST_HAVE_DIRECTORY) | FILE_READONLY |
570 FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
571 paffbFound, ulM * sizeof(FILEFINDBUF4),
572 &ulMaxFiles, FIL_QUERYEASIZE);
573 priority_normal();
574 *pchEndPath = 0;
575 if(!rc) {
576 while(!rc) {
577 /*
578 * remove . and .. from list if present
579 * also counter file system bugs that sometimes
580 * allows normal files to slip through when
581 * only directories should appear (only a few
582 * network file systems exhibit such a problem).
583 */
584 {
585 register ULONG x;
586
587 if(stopflag && *stopflag)
588 goto Abort;
589 pByte = (PBYTE)paffbFound;
590 x = 0L;
591 while(x < ulMaxFiles) {
592 pffbFile = (PFILEFINDBUF4)pByte;
593 if(!*pffbFile->achName ||
594 (!filestoo && !(pffbFile->attrFile & FILE_DIRECTORY)) ||
595 (((pffbFile->attrFile & FILE_DIRECTORY) &&
596 pffbFile->achName[0] == '.') &&
597 (!pffbFile->achName[1] || (pffbFile->achName[1] == '.' &&
598 !pffbFile->achName[2]))))
599 ulMaxFiles--;
600 else
601 papffbSelected[x++] = pffbFile;
602 if(!pffbFile->oNextEntryOffset) {
603 ulMaxFiles = x;
604 break;
605 }
606 pByte += pffbFile->oNextEntryOffset;
607 }
608 if(ulMaxFiles) {
609 if(stopflag && *stopflag)
610 goto Abort;
611 if(fSyncUpdates) {
612 pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
613 MPFROMLONG(ulExtraBytes),
614 MPFROMLONG(ulMaxFiles));
615 if(pciFirst) {
616
617 register INT i;
618
619 pci = pciFirst;
620 totalbytes = 0L;
621 for(i = 0; i < ulMaxFiles; i++) {
622 pffbFile = papffbSelected[i];
623 numbytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec,
624 pffbFile,partial,dcd);
625 if(numbytes > -1L) {
626 pci = (PCNRITEM)pci->rc.preccNextRecord;
627 totalbytes += numbytes;
628 }
629 else {
630 General_Error(WinQueryAnchorBlock(hwndCnr),HWND_DESKTOP,
631 __FILE__,__LINE__,
632 GetPString(IDS_FILLDIRERR1TEXT),
633 hwndCnr);
634 ulMaxFiles--;
635 }
636 }
637 if(ulMaxFiles) {
638 memset(&ri,0,sizeof(RECORDINSERT));
639 ri.cb = sizeof(RECORDINSERT);
640 ri.pRecordOrder = (PRECORDCORE) CMA_END;
641 ri.pRecordParent = (PRECORDCORE) pciParent;
642 ri.zOrder = (ULONG) CMA_TOP;
643 ri.cRecordsInsert = ulMaxFiles;
644 ri.fInvalidateRecord = (!fSyncUpdates && dcd &&
645 dcd->type == DIR_FRAME) ?
646 FALSE : TRUE;
647 if(!WinSendMsg(hwndCnr,
648 CM_INSERTRECORD,
649 MPFROMP(pciFirst),
650 MPFROMP(&ri))) {
651 DosSleep(100L);
652 WinSetFocus(HWND_DESKTOP,hwndCnr);
653 if(!WinSendMsg(hwndCnr,
654 CM_INSERTRECORD,
655 MPFROMP(pciFirst),
656 MPFROMP(&ri))) {
657
658 { // SHL
659 CHAR sz[80];
660 sprintf(sz, "rc = %d", rc);
661 WinMessageBox(HWND_DESKTOP, /* Parent window */
662 HWND_DESKTOP, /* Owner window */
663 sz, /* Message */
664 "Debug", /* Title bar message */
665 0, /* Message identifier */
666 MB_ENTER | MB_ICONEXCLAMATION | MB_MOVEABLE);
667 } // SHL
668
669 General_Error(WinQueryAnchorBlock(hwndCnr),
670 HWND_DESKTOP,
671 __FILE__,
672 __LINE__,
673 GetPString(IDS_FILLDIRERR2TEXT));
674 totalbytes = -1L;
675 if(WinIsWindow((HAB)0,hwndCnr)) {
676 pci = pciFirst;
677 while(pci) {
678 pcit = (PCNRITEM)pci->rc.preccNextRecord;
679 WinSendMsg(hwndCnr,
680 CM_FREERECORD,
681 MPFROMP(&pci),
682 MPFROMSHORT(1));
683 pci = pcit;
684 }
685 }
686 }
687 }
688 }
689 }
690 else {
691 General_Error(WinQueryAnchorBlock(hwndCnr),
692 HWND_DESKTOP,
693 __FILE__,
694 __LINE__,
695 GetPString(IDS_FILLDIRERR3TEXT));
696 totalbytes = -1L;
697 }
698 if(totalbytes > -1L) {
699 returnbytes += totalbytes;
700 if(foundany)
701 (*foundany) += ulMaxFiles;
702 }
703 }
704 else {
705 paffbTemp = realloc(paffbTotal,sizeof(FILEFINDBUF4) *
706 (ulMaxFiles + ulTotal));
707 if(paffbTemp) {
708 paffbTotal = paffbTemp;
709 for(x = 0;x < ulMaxFiles;x++)
710 paffbTotal[x + ulTotal] = *papffbSelected[x];
711 ulTotal += ulMaxFiles;
712 }
713 else {
714 saymsg(MB_ENTER,
715 HWND_DESKTOP,
716 GetPString(IDS_ERRORTEXT),
717 GetPString(IDS_OUTOFMEMORY));
718 break;
719 }
720 }
721 }
722 }
723 if(stopflag && *stopflag)
724 goto Abort;
725 ulMaxFiles = ulM;
726 DosError(FERR_DISABLEHARDERR);
727 rc = DosFindNext(hdir, paffbFound, ulM * sizeof(FILEFINDBUF4),
728 &ulMaxFiles);
729 priority_normal();
730 if(rc)
731 DosError(FERR_DISABLEHARDERR);
732 }
733 DosFindClose(hdir);
734
735 if(paffbFound || papffbSelected) {
736 if(paffbFound)
737 free(paffbFound);
738 if(papffbSelected)
739 free(papffbSelected);
740 papffbSelected = NULL;
741 paffbFound = NULL;
742 }
743
744 if(ulTotal && paffbTotal) {
745 if(stopflag && *stopflag)
746 goto Abort;
747 pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
748 MPFROMLONG(ulExtraBytes),
749 MPFROMLONG(ulTotal));
750 if(pciFirst) {
751
752 register INT i;
753
754 pci = pciFirst;
755 totalbytes = 0L;
756 pByte2 = (PBYTE)paffbTotal;
757 for(i = 0; i < ulTotal; i++) {
758 pffbFile = (PFILEFINDBUF4)pByte2;
759 numbytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec,
760 pffbFile,partial,dcd);
761 if(numbytes > -1L) {
762 pci = (PCNRITEM)pci->rc.preccNextRecord;
763 totalbytes += numbytes;
764 }
765 else {
766 General_Error(WinQueryAnchorBlock(hwndCnr),
767 HWND_DESKTOP,
768 __FILE__,
769 __LINE__,
770 GetPString(IDS_FILLDIRERR4TEXT),
771 hwndCnr);
772 ulTotal--;
773 }
774 pByte2 += sizeof(FILEFINDBUF4);
775 }
776 if(ulTotal) {
777 memset(&ri,0,sizeof(RECORDINSERT));
778 ri.cb = sizeof(RECORDINSERT);
779 ri.pRecordOrder = (PRECORDCORE) CMA_END;
780 ri.pRecordParent = (PRECORDCORE) pciParent;
781 ri.zOrder = (ULONG) CMA_TOP;
782 ri.cRecordsInsert = ulTotal;
783 ri.fInvalidateRecord = (!fSyncUpdates && dcd &&
784 dcd->type == DIR_FRAME) ?
785 FALSE : TRUE;
786 if(!WinSendMsg(hwndCnr,CM_INSERTRECORD,
787 MPFROMP(pciFirst),MPFROMP(&ri))) {
788 DosSleep(100L);
789 WinSetFocus(HWND_DESKTOP,hwndCnr);
790 if(!WinSendMsg(hwndCnr,CM_INSERTRECORD,
791 MPFROMP(pciFirst),MPFROMP(&ri))) {
792
793 { // SHL
794 CHAR sz[80];
795 sprintf(sz, "rc = %d", rc);
796 WinMessageBox(HWND_DESKTOP, /* Parent window */
797 HWND_DESKTOP, /* Owner window */
798 sz, /* Message */
799 "Debug", /* Title bar message */
800 0, /* Message identifier */
801 MB_ENTER | MB_ICONEXCLAMATION | MB_MOVEABLE);
802 } // SHL
803
804 General_Error(WinQueryAnchorBlock(hwndCnr),
805 HWND_DESKTOP,
806 __FILE__,
807 __LINE__,
808 GetPString(IDS_FILLDIRERR5TEXT));
809 totalbytes = -1L;
810 if(WinIsWindow((HAB)0,hwndCnr)) {
811 pci = pciFirst;
812 while(pci) {
813 pcit = (PCNRITEM)pci->rc.preccNextRecord;
814 WinSendMsg(hwndCnr,CM_FREERECORD,
815 MPFROMP(&pci),MPFROMSHORT(1));
816 pci = pcit;
817 }
818 }
819 }
820 }
821 }
822 }
823 else {
824 General_Error(WinQueryAnchorBlock(hwndCnr),
825 HWND_DESKTOP,
826 __FILE__,
827 __LINE__,
828 GetPString(IDS_FILLDIRERR3TEXT));
829 totalbytes = -1L;
830 }
831 if(totalbytes > -1L) {
832 returnbytes += totalbytes;
833 if(foundany)
834 (*foundany) += ulMaxFiles;
835 }
836 }
837 }
838
839 if(!fSyncUpdates && dcd && dcd->type == DIR_FRAME)
840 WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID,
841 MPFROM2SHORT(0,CMA_ERASE));
842 }
843Abort:
844 if(paffbTotal || papffbSelected || paffbFound || pszFileSpec) {
845 if(paffbTotal)
846 free(paffbTotal);
847 if(pszFileSpec)
848 free(pszFileSpec);
849 if(paffbFound)
850 free(paffbFound);
851 if(papffbSelected)
852 free(papffbSelected);
853 }
854 if(recurse) {
855 pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent),
856 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
857 while(pci && (INT)pci != -1) {
858 if(pci->attrFile & FILE_DIRECTORY)
859 Stubby(hwndCnr,pci);
860 pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
861 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
862 }
863 }
864
865 return returnbytes;
866}
867
868
869ULONG FillDirCnr (HWND hwndCnr,CHAR *directory,DIRCNRDATA *dcd) {
870
871 ULONG ret;
872
873 ret = ProcessDirectory(hwndCnr,(PCNRITEM)NULL,directory,TRUE,FALSE,TRUE,
874 (dcd) ? &dcd->stopflag : NULL,dcd,NULL);
875 DosPostEventSem(CompactSem);
876 return ret;
877}
878
879
880ULONG FillTreeCnr (HWND hwndCnr,HWND hwndParent) {
881
882 ULONG ulDriveNum,ulDriveMap,numtoinsert = 0L,drvtype;
883 PCNRITEM pci,pciFirst = NULL,pciNext,pciParent = NULL;
884 INT x,removable;
885 CHAR szDrive[] = " :\\",FileSystem[CCHMAXPATH],suggest[32];
886 FILESTATUS4 fsa4;
887 APIRET rc;
888 BOOL drivesbuilt = FALSE;
889 static BOOL didonce = FALSE;
890
891 fDummy = TRUE;
892 *suggest = 0;
893 for(x = 0;x < 26;x++)
894 driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS |
895 DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS |
896 DRIVE_INCLUDEFILES | DRIVE_SLOW);
897 memset(driveserial,-1,sizeof(driveserial));
898 {
899 ULONG startdrive = 3L;
900
901 DosError(FERR_DISABLEHARDERR);
902 if(!DosQuerySysInfo(QSV_BOOT_DRIVE,
903 QSV_BOOT_DRIVE,
904 (PVOID)&startdrive,
905 (ULONG)sizeof(ULONG)) &&
906 startdrive)
907 driveflags[startdrive - 1] |= DRIVE_BOOT;
908 }
909 DosError(FERR_DISABLEHARDERR);
910 rc = DosQCurDisk(&ulDriveNum,
911 &ulDriveMap);
912 if(rc) {
913 Dos_Error(MB_CANCEL,
914 rc,
915 HWND_DESKTOP,
916 __FILE__,
917 __LINE__,
918 GetPString(IDS_FILLDIRERR6TEXT));
919 exit(0);
920 }
921 for(x = 0;x < 26;x++)
922 if((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE))
923 numtoinsert++;
924 if(numtoinsert)
925 pciFirst = WinSendMsg(hwndCnr,
926 CM_ALLOCRECORD,
927 MPFROMLONG(EXTRA_RECORD_BYTES2),
928 MPFROMLONG((ULONG)numtoinsert));
929 if(pciFirst) {
930 pci = pciFirst;
931 for(x = 0;x < 26;x++) {
932 if((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) {
933 *szDrive = (CHAR)x + 'A';
934
935 {
936 CHAR s[80];
937 ULONG flags = 0,size = sizeof(ULONG);
938
939 sprintf(s,"%c.DriveFlags",toupper(*szDrive));
940 if(PrfQueryProfileData(fmprof,appname,s,&flags,&size) &&
941 size == sizeof(ULONG))
942 driveflags[toupper(*szDrive) - 'A'] |= flags;
943 }
944
945 if(x > 1) {
946 if(!(driveflags[x] & DRIVE_NOPRESCAN)) {
947 *FileSystem = 0;
948 drvtype = 0;
949 removable = CheckDrive(*szDrive,FileSystem,&drvtype);
950 driveserial[x] = -1;
951 if(removable != -1) {
952
953 struct {
954 ULONG serial;
955 CHAR volumelength;
956 CHAR volumelabel[CCHMAXPATH];
957 } volser;
958
959 DosError(FERR_DISABLEHARDERR);
960 if(!DosQueryFSInfo((ULONG)x,
961 FSIL_VOLSER,
962 &volser,
963 sizeof(volser)))
964 driveserial[x] = volser.serial;
965 }
966 else
967 driveflags[x] |= DRIVE_INVALID;
968 memset(&fsa4,0,sizeof(FILESTATUS4));
969 driveflags[x] |= ((removable == -1 || removable == 1) ?
970 DRIVE_REMOVABLE : 0);
971 if(drvtype & DRIVE_REMOTE)
972 driveflags[x] |= DRIVE_REMOTE;
973 if(strcmp(FileSystem,HPFS) &&
974 strcmp(FileSystem,HPFS386) &&
975 strcmp(FileSystem,CDFS))
976 driveflags[x] |= DRIVE_NOLONGNAMES;
977 if(!strcmp(FileSystem,CDFS)) {
978 removable = 1;
979 driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE |
980 DRIVE_CDROM);
981 }
982 else if(!stricmp(FileSystem,CBSIFS)) {
983 driveflags[x] |= DRIVE_ZIPSTREAM;
984 driveflags[x] &= (~DRIVE_REMOTE);
985 if(drvtype & DRIVE_REMOVABLE)
986 driveflags[x] |= DRIVE_REMOVABLE;
987 if(!(drvtype & DRIVE_NOLONGNAMES))
988 driveflags[x] &= (~DRIVE_NOLONGNAMES);
989 }
990
991 pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
992 if((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum)
993 pci->rc.flRecordAttr |= (CRA_CURSORED | CRA_SELECTED);
994
995 if(removable == 0) {
996 pci->attrFile |= FILE_DIRECTORY;
997 DosError(FERR_DISABLEHARDERR);
998 rc = DosQueryPathInfo(szDrive,
999 FIL_QUERYEASIZE,
1000 &fsa4,
1001 (ULONG)sizeof(FILESTATUS4));
1002 if(rc == 58) {
1003 DosError(FERR_DISABLEHARDERR);
1004 rc = DosQueryPathInfo(szDrive,
1005 FIL_STANDARD,
1006 &fsa4,
1007 (ULONG)sizeof(FILESTATUS3));
1008 fsa4.cbList = 0;
1009 }
1010 if(rc && !didonce) {
1011 if(!*suggest) {
1012 *suggest = '/';
1013 suggest[1] = 0;
1014 }
1015 sprintf(suggest + strlen(suggest),
1016 "%c",
1017 toupper(*szDrive));
1018 strcpy(pci->szFileName,szDrive);
1019 pci->pszFileName = pci->szFileName;
1020 pci->rc.pszIcon = pci->pszFileName;
1021 pci->attrFile = FILE_DIRECTORY;
1022 strcpy(pci->szDispAttr,"----D-");
1023 pci->pszDispAttr = pci->szDispAttr;
1024 driveserial[x] = -1;
1025 }
1026 else
1027 FillInRecordFromFSA(hwndCnr,
1028 pci,
1029 szDrive,
1030 &fsa4,
1031 TRUE,
1032 NULL);
1033 }
1034 else {
1035 strcpy(pci->szFileName,szDrive);
1036 pci->pszFileName = pci->szFileName;
1037 pci->rc.pszIcon = pci->pszFileName;
1038 pci->attrFile = FILE_DIRECTORY;
1039 strcpy(pci->szDispAttr,"----D-");
1040 pci->pszDispAttr = pci->szDispAttr;
1041 }
1042 *pci->szFileName = toupper(*pci->szFileName);
1043 if(driveflags[x] & DRIVE_CDROM)
1044 pci->rc.hptrIcon = hptrCDROM;
1045 else
1046 pci->rc.hptrIcon = (driveflags[x] & DRIVE_REMOVABLE) ?
1047 hptrRemovable :
1048 (driveflags[x] & DRIVE_REMOTE) ?
1049 hptrRemote :
1050 (driveflags[x] & DRIVE_ZIPSTREAM) ?
1051 hptrZipstrm : hptrDrive;
1052 }
1053 else {
1054 pci->rc.hptrIcon = hptrDunno;
1055 strcpy(pci->szFileName,szDrive);
1056 pci->pszFileName = pci->szFileName;
1057 pci->rc.pszIcon = pci->pszFileName;
1058 pci->attrFile = FILE_DIRECTORY;
1059 strcpy(pci->szDispAttr,"----D-");
1060 pci->pszDispAttr = pci->szDispAttr;
1061 driveserial[x] = -1;
1062 }
1063 }
1064 else {
1065 pci->rc.hptrIcon = hptrFloppy;
1066 strcpy(pci->szFileName,szDrive);
1067 pci->pszFileName = pci->szFileName;
1068 pci->rc.pszIcon = pci->pszFileName;
1069 pci->attrFile = FILE_DIRECTORY;
1070 strcpy(pci->szDispAttr,"----D-");
1071 pci->pszDispAttr = pci->szDispAttr;
1072 driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOLONGNAMES);
1073 driveserial[x] = -1;
1074 }
1075 pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
1076 pci = (PCNRITEM)pci->rc.preccNextRecord; /* next rec */
1077 }
1078 else if(!(ulDriveMap & (1L << x)))
1079 driveflags[x] |= DRIVE_INVALID;
1080 }
1081 PostMsg(hwndMain,
1082 UM_BUILDDRIVES,
1083 MPVOID,
1084 MPVOID);
1085 drivesbuilt = TRUE;
1086 /* insert the drives */
1087 if(numtoinsert && pciFirst) {
1088
1089 RECORDINSERT ri;
1090
1091 memset(&ri,0,sizeof(RECORDINSERT));
1092 ri.cb = sizeof(RECORDINSERT);
1093 ri.pRecordOrder = (PRECORDCORE)CMA_END;
1094 ri.pRecordParent = (PRECORDCORE)NULL;
1095 ri.zOrder = (ULONG)CMA_TOP;
1096 ri.cRecordsInsert = numtoinsert;
1097 ri.fInvalidateRecord = FALSE;
1098 if(!WinSendMsg(hwndCnr,
1099 CM_INSERTRECORD,
1100 MPFROMP(pciFirst),
1101 MPFROMP(&ri)))
1102 General_Error(WinQueryAnchorBlock(hwndCnr),
1103 hwndCnr,
1104 __FILE__,
1105 __LINE__,
1106 GetPString(IDS_FILLDIRERR5TEXT));
1107 }
1108 /* move cursor onto the default drive rather than the first drive */
1109 if(!fSwitchTree) {
1110 pci = (PCNRITEM)WinSendMsg(hwndCnr,
1111 CM_QUERYRECORD,
1112 MPVOID,
1113 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
1114 while(pci && (INT)pci != -1) {
1115 if((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum) {
1116 WinSendMsg(hwndCnr,
1117 CM_SETRECORDEMPHASIS,
1118 MPFROMP(pci),
1119 MPFROM2SHORT(TRUE,CRA_CURSORED));
1120 break;
1121 }
1122 pci = (PCNRITEM)WinSendMsg(hwndCnr,
1123 CM_QUERYRECORD,
1124 MPFROMP(pci),
1125 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
1126 }
1127 }
1128
1129 if(hwndParent)
1130 WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
1131 MAIN_DRIVELIST),
1132 LM_DELETEALL,
1133 MPVOID,
1134 MPVOID);
1135
1136 if(fShowEnv) {
1137
1138 RECORDINSERT ri;
1139
1140 pciParent = WinSendMsg(hwndCnr,
1141 CM_ALLOCRECORD,
1142 MPFROMLONG(EXTRA_RECORD_BYTES2),
1143 MPFROMLONG(1));
1144 if(pciParent) {
1145 pciParent->flags |= RECFLAGS_ENV;
1146 strcpy(pciParent->szFileName,GetPString(IDS_ENVVARSTEXT));
1147 pciParent->pszFileName = pciParent->szFileName;
1148 pciParent->rc.hptrIcon = hptrEnv;
1149 pciParent->rc.pszIcon = pciParent->pszFileName;
1150 strcpy(pciParent->szDispAttr,"------");
1151 pciParent->pszDispAttr = pciParent->szDispAttr;
1152 memset(&ri,0,sizeof(RECORDINSERT));
1153 ri.cb = sizeof(RECORDINSERT);
1154 ri.pRecordOrder = (PRECORDCORE)CMA_END;
1155 ri.pRecordParent = (PRECORDCORE)NULL;
1156 ri.zOrder = (ULONG)CMA_TOP;
1157 ri.cRecordsInsert = 1;
1158 ri.fInvalidateRecord = FALSE;
1159 if(WinSendMsg(hwndCnr,
1160 CM_INSERTRECORD,
1161 MPFROMP(pciParent),
1162 MPFROMP(&ri))) {
1163
1164 char *p,*pp;
1165
1166 p = GetPString(IDS_ENVVARNAMES);
1167 while(*p == ' ')
1168 p++;
1169 while(*p) {
1170 *FileSystem = 0;
1171 pp = FileSystem;
1172 while(*p && *p != ' ')
1173 *pp++ = *p++;
1174 *pp = 0;
1175 while(*p == ' ')
1176 p++;
1177 if(*FileSystem &&
1178 (!stricmp(FileSystem,"LIBPATH") ||
1179 getenv(FileSystem))) {
1180 pci = WinSendMsg(hwndCnr,
1181 CM_ALLOCRECORD,
1182 MPFROMLONG(EXTRA_RECORD_BYTES2),
1183 MPFROMLONG(1));
1184 if(pci) {
1185 pci->flags |= RECFLAGS_ENV;
1186 sprintf(pci->szFileName,
1187 "%%%s%%",
1188 FileSystem);
1189 pci->pszFileName = pci->szFileName;
1190 pci->rc.hptrIcon = hptrEnv;
1191 pci->rc.pszIcon = pci->pszFileName;
1192 strcpy(pci->szDispAttr,"------");
1193 pci->pszDispAttr = pci->szDispAttr;
1194 memset(&ri,0,sizeof(RECORDINSERT));
1195 ri.cb = sizeof(RECORDINSERT);
1196 ri.pRecordOrder = (PRECORDCORE)CMA_END;
1197 ri.pRecordParent = (PRECORDCORE)pciParent;
1198 ri.zOrder = (ULONG)CMA_TOP;
1199 ri.cRecordsInsert = 1;
1200 ri.fInvalidateRecord = FALSE;
1201 if(!WinSendMsg(hwndCnr,
1202 CM_INSERTRECORD,
1203 MPFROMP(pci),
1204 MPFROMP(&ri))) {
1205 General_Error(WinQueryAnchorBlock(hwndCnr),
1206 hwndCnr,
1207 __FILE__,
1208 __LINE__,
1209 GetPString(IDS_FILLDIRERR5TEXT));
1210 WinSendMsg(hwndCnr,
1211 CM_FREERECORD,
1212 MPFROMP(&pci),
1213 MPFROMSHORT(1));
1214 }
1215 }
1216 }
1217 }
1218 WinSendMsg(hwndCnr,
1219 CM_INVALIDATERECORD,
1220 MPFROMP(&pciParent),
1221 MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
1222 }
1223 else
1224 WinSendMsg(hwndCnr,
1225 CM_FREERECORD,
1226 MPFROMP(&pciParent),
1227 MPFROMSHORT(1));
1228 }
1229 }
1230
1231 x = 0;
1232 pci = (PCNRITEM)WinSendMsg(hwndCnr,
1233 CM_QUERYRECORD,
1234 MPVOID,
1235 MPFROM2SHORT(CMA_FIRST,
1236 CMA_ITEMORDER));
1237 while(pci && (INT)pci != -1) {
1238 pciNext = (PCNRITEM)WinSendMsg(hwndCnr,
1239 CM_QUERYRECORD,
1240 MPFROMP(pci),
1241 MPFROM2SHORT(CMA_NEXT,
1242 CMA_ITEMORDER));
1243 if(!(pci->flags & RECFLAGS_ENV)) {
1244 if((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum ||
1245 toupper(*pci->szFileName) > 'B') {
1246 if(!(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_INVALID) &&
1247 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOPRESCAN) &&
1248 (!fNoRemovableScan ||
1249 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE))) {
1250 if(!Stubby(hwndCnr,pci)) {
1251 WinSendMsg(hwndCnr,
1252 CM_INVALIDATERECORD,
1253 MPFROMP(&pci),
1254 MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
1255 goto SkipBadRec;
1256 }
1257 }
1258 }
1259 else
1260 WinSendMsg(hwndCnr,
1261 CM_INVALIDATERECORD,
1262 MPFROMP(&pci),
1263 MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
1264 WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
1265 MAIN_DRIVELIST),
1266 LM_INSERTITEM,
1267 MPFROM2SHORT(LIT_SORTASCENDING,0),
1268 MPFROMP(pci->szFileName));
1269 }
1270SkipBadRec:
1271 x++;
1272 pci = pciNext;
1273 }
1274 if(hwndParent)
1275 WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
1276 MAIN_DRIVELIST),LM_SELECTITEM,MPFROM2SHORT(0,0),
1277 MPFROMLONG(TRUE));
1278
1279 pci = (PCNRITEM)WinSendMsg(hwndCnr,
1280 CM_QUERYRECORD,
1281 MPVOID,
1282 MPFROM2SHORT(CMA_FIRST,
1283 CMA_ITEMORDER));
1284 while(pci && (INT)pci != -1) {
1285 pciNext = (PCNRITEM)WinSendMsg(hwndCnr,
1286 CM_QUERYRECORD,
1287 MPFROMP(pci),
1288 MPFROM2SHORT(CMA_NEXT,
1289 CMA_ITEMORDER));
1290 if(pci->flags & RECFLAGS_ENV) {
1291 pci = (PCNRITEM)WinSendMsg(hwndCnr,
1292 CM_QUERYRECORD,
1293 MPFROMP(pci),
1294 MPFROM2SHORT(CMA_FIRSTCHILD,
1295 CMA_ITEMORDER));
1296 while(pci && (INT)pci != -1) {
1297 if(pci->flags & RECFLAGS_ENV)
1298 FleshEnv(hwndCnr,pci);
1299 pci = (PCNRITEM)WinSendMsg(hwndCnr,
1300 CM_QUERYRECORD,
1301 MPFROMP(pci),
1302 MPFROM2SHORT(CMA_NEXT,
1303 CMA_ITEMORDER));
1304 }
1305 break;
1306 }
1307 pci = (PCNRITEM)WinSendMsg(hwndCnr,
1308 CM_QUERYRECORD,
1309 MPFROMP(pci),
1310 MPFROM2SHORT(CMA_NEXT,
1311 CMA_ITEMORDER));
1312 }
1313
1314 }
1315 else {
1316 General_Error(WinQueryAnchorBlock(hwndCnr),
1317 hwndCnr,
1318 __FILE__,
1319 __LINE__,
1320 GetPString(IDS_FILLDIRERR7TEXT));
1321 exit(0);
1322 }
1323 if(!drivesbuilt && hwndMain)
1324 PostMsg(hwndMain,
1325 UM_BUILDDRIVES,
1326 MPVOID,
1327 MPVOID);
1328 DosSleep(33L);
1329 fDummy = FALSE;
1330 DosPostEventSem(CompactSem);
1331 {
1332 BYTE info;
1333 BOOL includesyours = FALSE;
1334
1335 if(*suggest ||
1336 (!(driveflags[1] & DRIVE_IGNORE) &&
1337 fFirstTime)) {
1338 if(!DosDevConfig(&info,
1339 DEVINFO_FLOPPY) &&
1340 info == 1) {
1341 if(!*suggest) {
1342 *suggest = '/';
1343 suggest[1] = 0;
1344 }
1345 else
1346 memmove(suggest + 2,suggest + 1,strlen(suggest));
1347 suggest[1] = 'B';
1348 }
1349 }
1350 if(*suggest) {
1351 for(x = 2;x < 26;x++) {
1352 if(driveflags[x] & DRIVE_IGNORE) {
1353 includesyours = TRUE;
1354 sprintf(suggest + strlen(suggest),
1355 "%c",
1356 (char)(x + 'A'));
1357 }
1358 }
1359 strcat(suggest," %*");
1360 if(saymsg(MB_YESNO | MB_ICONEXCLAMATION,
1361 (hwndParent) ? hwndParent : hwndCnr,
1362 GetPString(IDS_SUGGESTTITLETEXT),
1363 GetPString(IDS_SUGGEST1TEXT),
1364 (includesyours) ?
1365 GetPString(IDS_SUGGEST2TEXT) :
1366 NullStr,
1367 suggest) == MBID_YES) {
1368
1369 char s[64];
1370
1371 sprintf(s,
1372 "PARAMETERS=%s",
1373 suggest);
1374 WinCreateObject(WPProgram,
1375 "FM/2",
1376 s,
1377 FM3Folder,
1378 CO_UPDATEIFEXISTS);
1379 WinCreateObject(WPProgram,
1380 "FM/2 Lite",
1381 s,
1382 FM3Folder,
1383 CO_UPDATEIFEXISTS);
1384 WinCreateObject(WPProgram,
1385 "Archive Viewer/2",
1386 s,
1387 FM3Tools,
1388 CO_UPDATEIFEXISTS);
1389 WinCreateObject(WPProgram,
1390 "Dir Sizes",
1391 s,
1392 FM3Tools,
1393 CO_UPDATEIFEXISTS);
1394 WinCreateObject(WPProgram,
1395 "Visual Tree",
1396 s,
1397 FM3Tools,
1398 CO_UPDATEIFEXISTS);
1399 WinCreateObject(WPProgram,
1400 "Visual Directory",
1401 s,
1402 FM3Tools,
1403 CO_UPDATEIFEXISTS);
1404 WinCreateObject(WPProgram,
1405 "Global File Viewer",
1406 s,
1407 FM3Tools,
1408 CO_UPDATEIFEXISTS);
1409 WinCreateObject(WPProgram,
1410 "Databar",
1411 s,
1412 FM3Tools,
1413 CO_UPDATEIFEXISTS);
1414 }
1415 }
1416 }
1417 didonce = TRUE;
1418 return 0L;
1419}
1420
Note: See TracBrowser for help on using the repository browser.