source: trunk/dll/filldir.c@ 70

Last change on this file since 70 was 70, checked in by root, 22 years ago

Add JFS and FAT32 support

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