source: trunk/dll/filldir.c@ 145

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

Rework Win_Error usage

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