source: trunk/dll/filldir.c@ 167

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

Rework for ULONGLONG
Rework FillInRecordFromFFB
Rework FillTreeCnr

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