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
RevLine 
[31]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
[167]9 Copyright (c) 2001, 2005 Steven H. Levine
[31]10
[145]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
[167]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
[31]20
21***********************************************************************/
22
[2]23#define INCL_DOS
24#define INCL_WIN
[167]25#define INCL_LONGLONG
26#include <os2.h>
[2]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>
[167]34
[2]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
[167]42static HPOINTER IDFile(ULONG cmp)
[90]43{
[2]44 HPOINTER hptr;
45
46 hptr = (HPOINTER)0;
[167]47 if (cmp == *(ULONG *)".EXE" || cmp == *(ULONG *)".CMD" ||
48 cmp == *(ULONG *)".BAT" || cmp == *(ULONG *)".COM")
[2]49 hptr = hptrApp;
[167]50 else if (cmp == *(ULONG *)".ZIP" || cmp == *(ULONG *)".LZH" ||
51 cmp == *(ULONG *)".ARJ" || cmp == *(ULONG *)".ARC" ||
52 cmp == *(ULONG *)".ZOO" || cmp == *(ULONG *)".RAR")
[2]53 hptr = hptrArc;
[167]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")
[2]58 hptr = hptrArt;
59 return hptr;
60}
61
62
[167]63ULONGLONG FillInRecordFromFFB(HWND hwndCnr,PCNRITEM pci, const PSZ pszDirectory,
64 const PFILEFINDBUF4 pffb,const BOOL partial,
65 DIRCNRDATA *dcd)
[31]66{
[2]67 /* fill in a container record from a FILEFINDBUF4 structure */
68
[167]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;
[2]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
[167]84 (like in update.c)
85 */
86 if (*pffb->achName)
87 {
[2]88 p = pci->szFileName + (t - 1);
[167]89 if (*p != '\\') {
[2]90 p++;
91 *p = '\\';
92 }
93 p++;
94 memcpy(p,pffb->achName,pffb->cchName + 1);
95 }
96 /* load the object's Subject, if required */
[167]97 if (pffb->cbList > 4L &&
98 dcd && fLoadSubject &&
99 (isalpha(*pci->szFileName) &&
100 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADSUBJS)))
101 {
[2]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);
[167]111 if (pgealist)
112 {
[2]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);
[167]120 if (pfealist)
121 {
[2]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));
[167]129 if (!rc) {
[2]130 pfea = &eaop.fpFEA2List->list[0];
131 value = pfea->szName + pfea->cbName + 1;
132 value[pfea->cbValue] = 0;
[167]133 if (*(USHORT *)value == EAT_ASCII)
134 strncpy(pci->szSubject,value + (sizeof(USHORT) * 2),39);
135 pci->szSubject[39] = 0;
[2]136 }
137 free(pfealist);
138 }
139 free(pgealist);
140 }
141 }
[167]142 pci->pszSubject = pci->szSubject;
[2]143 /* load the object's longname */
[167]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 {
[2]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);
[167]160 if (pgealist)
161 {
[2]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);
[167]169 if (pfealist) {
[2]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));
[167]177 if (!rc)
178 {
[2]179 pfea = &eaop.fpFEA2List->list[0];
180 value = pfea->szName + pfea->cbName + 1;
181 value[pfea->cbValue] = 0;
[167]182 if (*(USHORT *)value == EAT_ASCII)
183 strncpy(pci->szLongname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP);
184 pci->szLongname[CCHMAXPATHCOMP - 1] = 0;
[2]185 }
186 free(pfealist);
187 }
188 free(pgealist);
189 }
190 }
[167]191 pci->pszLongname = pci->szLongname;
[2]192
193 /* do anything required to case of filename */
[167]194 if (fForceUpper)
[2]195 strupr(pci->szFileName);
[167]196 else if (fForceLower)
[2]197 strlwr(pci->szFileName);
198
199 /* get an icon to use with it */
[167]200 if (pffb->attrFile & FILE_DIRECTORY)
201 {
202 if (!fNoIconsDirs && (!isalpha(*pci->szFileName) ||
203 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))
[2]204 hptr = WinLoadFileIcon(pci->szFileName, FALSE);
205 else
206 hptr = (HPOINTER)0;
207 }
[167]208 else
209 {
[42]210 if (!fNoIconsFiles && (!isalpha(*pci->szFileName) ||
[2]211 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))
[167]212 {
[2]213 hptr = WinLoadFileIcon(pci->szFileName, FALSE);
[167]214 }
[42]215 else
216 hptr = (HPOINTER)0;
[167]217
218 if (!hptr || hptr == WinQuerySysPointer(HWND_DESKTOP,SPTR_FILE,FALSE))
219 {
[2]220 p = strrchr(pci->szFileName,'.');
[167]221 if (p && !p[4])
222 {
[2]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 }
[167]233 if (!hptr)
234 {
[2]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;
[167]240 }
[2]241
242 /* decide where to point for the container's title text */
[167]243 if (partial)
244 {
[2]245 p = strrchr(pci->szFileName,'\\');
[167]246 if (!p)
247 {
[2]248 p = strrchr(pci->szFileName,':');
[167]249 if (!p)
[2]250 p = pci->szFileName;
251 else
252 p++;
253 }
[167]254 else if ((dcd && dcd->type == TREE_FRAME) ||
255 (!(pffb->attrFile & FILE_DIRECTORY) || !*(p + 1)))
256 {
[2]257 p++;
[167]258 }
259 if (!*p)
[2]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;
[51]284 pci->easize = CBLIST_TO_EASIZE(pffb->cbList);
[2]285 pci->cbFile = pffb->cbFile;
286 pci->attrFile = pffb->attrFile;
287 /* build attribute string for display */
288 y = 0;
[167]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 }
[2]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 */
[167]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 {
[2]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)))
[167]321 {
[2]322 pci->rc.flRecordAttr |= CRA_FILTERED;
[167]323 }
[2]324 }
325
326 return pffb->cbFile + pci->easize;
327
[167]328} // FillInRecordFromFFB
[2]329
[167]330
331ULONGLONG FillInRecordFromFSA(HWND hwndCnr,
332 PCNRITEM pci,
333 const PSZ pszFileName,
334 const PFILESTATUS4 pfsa4,
335 const BOOL partial,
336 DIRCNRDATA *dcd) // Optional
[31]337{
[2]338 HPOINTER hptr;
[167]339 CHAR attrstring[] = "RHS\0DA";
340 CHAR cmps[] = ".xxx";
[2]341 register CHAR *p;
[167]342 register INT x;
343 register INT y;
[2]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 */
[167]351 if (pfsa4->cbList > 4L &&
352 dcd &&
353 fLoadSubject &&
354 (!isalpha(*pci->szFileName) ||
355 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADSUBJS)))
356 {
[2]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);
[167]366 if (pgealist) {
[2]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);
[167]374 if (pfealist) {
[2]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));
[167]383 if (!rc) {
[2]384 pfea = &eaop.fpFEA2List->list[0];
385 value = pfea->szName + pfea->cbName + 1;
386 value[pfea->cbValue] = 0;
[167]387 if (*(USHORT *)value == EAT_ASCII)
388 strncpy(pci->szSubject,value + (sizeof(USHORT) * 2),39);
389 pci->szSubject[39] = 0;
[2]390 }
391 free(pfealist);
392 }
393 free(pgealist);
394 }
395 }
[167]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))))
[51]404 {
[2]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);
[167]414 if (pgealist) {
[2]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);
[167]422 if (pfealist) {
[2]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));
[167]430 if (!rc) {
[2]431 pfea = &eaop.fpFEA2List->list[0];
432 value = pfea->szName + pfea->cbName + 1;
433 value[pfea->cbValue] = 0;
[167]434 if (*(USHORT *)value == EAT_ASCII)
435 strncpy(pci->szLongname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP);
436 pci->szLongname[CCHMAXPATHCOMP - 1] = 0;
[2]437 }
438 free(pfealist);
439 }
440 free(pgealist);
441 }
442 }
[167]443 pci->pszLongname = pci->szLongname;
444 if (fForceUpper)
[2]445 strupr(pci->szFileName);
[167]446 else if (fForceLower)
[2]447 strlwr(pci->szFileName);
448
[167]449 if (pfsa4->attrFile & FILE_DIRECTORY) {
450 if (!fNoIconsDirs && (!isalpha(*pci->szFileName) ||
451 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))
[2]452 hptr = WinLoadFileIcon(pci->szFileName, FALSE);
453 else
454 hptr = (HPOINTER)0;
455 }
[167]456 else
457 {
458 if (!fNoIconsFiles && (!isalpha(*pci->szFileName) ||
459 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))
[2]460 hptr = WinLoadFileIcon(pci->szFileName, FALSE);
[167]461 else
462 {
[2]463 p = strrchr(pci->szFileName,'.');
[167]464 if (p && !p[4]) {
[2]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 }
[167]475 if (!hptr)
[2]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
[167]482 if (partial) {
[2]483 p = strrchr(pci->szFileName,'\\');
[167]484 if (!p) {
[2]485 p = strrchr(pci->szFileName,':');
[167]486 if (!p)
[2]487 p = pci->szFileName;
488 else
489 p++;
490 }
[167]491 else if ((dcd && dcd->type == TREE_FRAME) ||
492 !(pfsa4->attrFile & FILE_DIRECTORY) ||
493 !*(p + 1))
[2]494 p++;
[167]495 if (!*p)
[2]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;
[51]519 pci->easize = CBLIST_TO_EASIZE(pfsa4->cbList);
[2]520 pci->cbFile = pfsa4->cbFile;
521 pci->attrFile = pfsa4->attrFile;
522 y = 0;
523 for(x = 0;x < 6;x++)
[167]524 if (attrstring[x])
[2]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
[167]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))
[2]541 pci->rc.flRecordAttr |= CRA_FILTERED;
542 }
[167]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)))
[2]551 pci->rc.flRecordAttr |= CRA_FILTERED;
552 }
553
554 return pfsa4->cbFile + pci->easize;
555
[167]556} // FillInRecordFromFSA
[2]557
[167]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
[31]566{
[2]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
[42]572 PSZ pszFileSpec;
[2]573 INT t;
[167]574 PFILEFINDBUF4 paffbFound;
575 PFILEFINDBUF4 *papffbSelected;
576 PFILEFINDBUF4 pffbFile;
577 PFILEFINDBUF4 paffbTotal = NULL;
578 PFILEFINDBUF4 paffbTemp;
[2]579 HDIR hdir = HDIR_CREATE;
[167]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;
[2]588 PCH pchEndPath;
589 APIRET rc;
[167]590 PCNRITEM pci;
591 PCNRITEM pciFirst;
592 PCNRITEM pcit;
[2]593 RECORDINSERT ri;
[167]594 PBYTE pByte;
595 PBYTE pByte2;
596 BOOL ok = TRUE;
[2]597
[167]598 if (isalpha(*szDirBase) && szDirBase[1] == ':' && szDirBase[2] == '\\')
599 {
600 // if (!(driveflags[toupper(*szDirBase) - 'A'] & DRIVE_NOLONGNAMES))
[2]601 ulExtraBytes = EXTRA_RECORD_BYTES;
[167]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)
[2]607 ulM = min(FilesToGet,225); /* anything more is wasted */
608 else
609 ulM = FilesToGet; /* full-out */
610 }
[167]611 else
612 {
[2]613 ulExtraBytes = EXTRA_RECORD_BYTES;
614 ulM = FilesToGet;
615 }
[167]616 if (OS2ver[0] == 20 && OS2ver[1] < 30)
[2]617 ulM = min(ulM,(65535 / sizeof(FILEFINDBUF4)));
618
[167]619 ulFileCnt = ulM;
[42]620 pszFileSpec = malloc(CCHMAXPATH + 2);
[90]621 paffbFound = malloc((ulM + 1) * sizeof(FILEFINDBUF4));
622 papffbSelected = malloc((ulM + 1) * sizeof(PFILEFINDBUF4));
[167]623 if (paffbFound && papffbSelected && pszFileSpec) {
[2]624 t = strlen(szDirBase);
[42]625 memcpy(pszFileSpec,szDirBase,t + 1);
626 pchEndPath = pszFileSpec + t;
[167]627 if (*(pchEndPath - 1) != '\\') {
[2]628 memcpy(pchEndPath,"\\",2);
629 pchEndPath++;
630 }
631 memcpy(pchEndPath,"*",2);
632 DosError(FERR_DISABLEHARDERR);
[42]633 rc = DosFindFirst(pszFileSpec, &hdir,
[2]634 FILE_NORMAL | ((filestoo) ? FILE_DIRECTORY :
635 MUST_HAVE_DIRECTORY) | FILE_READONLY |
636 FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
[42]637 paffbFound, ulM * sizeof(FILEFINDBUF4),
[167]638 &ulFileCnt, FIL_QUERYEASIZE);
[2]639 priority_normal();
640 *pchEndPath = 0;
[167]641 if (!rc)
642 {
643 while (!rc)
644 {
[2]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
[167]655 if (stopflag && *stopflag)
[2]656 goto Abort;
[42]657 pByte = (PBYTE)paffbFound;
[2]658 x = 0L;
[167]659 while (x < ulFileCnt)
660 {
[42]661 pffbFile = (PFILEFINDBUF4)pByte;
[167]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 }
[2]671 else
[42]672 papffbSelected[x++] = pffbFile;
[167]673 if (!pffbFile->oNextEntryOffset)
674 {
675 ulFileCnt = x;
[2]676 break;
677 }
[42]678 pByte += pffbFile->oNextEntryOffset;
[2]679 }
[167]680 if (ulFileCnt)
681 {
682 if (stopflag && *stopflag)
[2]683 goto Abort;
[167]684 if (fSyncUpdates)
685 {
[2]686 pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
687 MPFROMLONG(ulExtraBytes),
[167]688 MPFROMLONG(ulFileCnt));
689 if (pciFirst)
690 {
[2]691 register INT i;
692
693 pci = pciFirst;
[167]694 ullTotalBytes = 0;
695 for(i = 0; i < ulFileCnt; i++) {
[42]696 pffbFile = papffbSelected[i];
[167]697 ullBytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec,
698 pffbFile,partial,dcd);
699 if (rc)
700 {
[2]701 pci = (PCNRITEM)pci->rc.preccNextRecord;
[167]702 ullTotalBytes += ullBytes;
[2]703 }
[167]704 else
705 {
[145]706 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
707 GetPString(IDS_FILLDIRERR1TEXT),
708 hwndCnr);
[167]709 ulFileCnt--;
[2]710 }
711 }
[167]712 if (ulFileCnt)
713 {
[2]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;
[167]719 ri.cRecordsInsert = ulFileCnt;
[2]720 ri.fInvalidateRecord = (!fSyncUpdates && dcd &&
721 dcd->type == DIR_FRAME) ?
722 FALSE : TRUE;
[167]723 if (!WinSendMsg(hwndCnr,
724 CM_INSERTRECORD,
725 MPFROMP(pciFirst),
726 MPFROMP(&ri)))
[90]727 {
[2]728 DosSleep(100L);
729 WinSetFocus(HWND_DESKTOP,hwndCnr);
[167]730 if (!WinSendMsg(hwndCnr,
731 CM_INSERTRECORD,
732 MPFROMP(pciFirst),
733 MPFROMP(&ri))) {
[31]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
[145]746 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
747 GetPString(IDS_FILLDIRERR2TEXT));
[167]748 ok = FALSE;
749 ullTotalBytes = 0;
750 if (WinIsWindow((HAB)0,hwndCnr))
751 {
[2]752 pci = pciFirst;
[167]753 while (pci)
754 {
[2]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 }
[167]767 else
768 {
[145]769 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
770 GetPString(IDS_FILLDIRERR3TEXT));
[167]771 ok = FALSE;
772 ullTotalBytes = 0;
[2]773 }
[167]774 if (ok)
775 {
776 ullReturnBytes += ullTotalBytes;
777 ulReturnFiles += ulFileCnt;
[2]778 }
779 }
[167]780 else
781 {
[42]782 paffbTemp = realloc(paffbTotal,sizeof(FILEFINDBUF4) *
[167]783 (ulFileCnt + ulTotal));
784 if (paffbTemp)
785 {
[42]786 paffbTotal = paffbTemp;
[167]787 for(x = 0;x < ulFileCnt;x++)
[42]788 paffbTotal[x + ulTotal] = *papffbSelected[x];
[167]789 ulTotal += ulFileCnt;
[2]790 }
[167]791 else
792 {
[2]793 saymsg(MB_ENTER,
794 HWND_DESKTOP,
795 GetPString(IDS_ERRORTEXT),
796 GetPString(IDS_OUTOFMEMORY));
797 break;
798 }
799 }
800 }
801 }
[167]802 if (stopflag && *stopflag)
[2]803 goto Abort;
[167]804 ulFileCnt = ulM;
[2]805 DosError(FERR_DISABLEHARDERR);
[42]806 rc = DosFindNext(hdir, paffbFound, ulM * sizeof(FILEFINDBUF4),
[167]807 &ulFileCnt);
[2]808 priority_normal();
[167]809 if (rc)
[2]810 DosError(FERR_DISABLEHARDERR);
811 }
812 DosFindClose(hdir);
813
[167]814 if (paffbFound || papffbSelected) {
815 if (paffbFound)
[42]816 free(paffbFound);
[167]817 if (papffbSelected)
[42]818 free(papffbSelected);
819 papffbSelected = NULL;
820 paffbFound = NULL;
[2]821 }
822
[167]823 if (ulTotal && paffbTotal)
824 {
825
826 if (stopflag && *stopflag)
[2]827 goto Abort;
[167]828
[2]829 pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
830 MPFROMLONG(ulExtraBytes),
831 MPFROMLONG(ulTotal));
[167]832 if (pciFirst)
833 {
[2]834 register INT i;
835
836 pci = pciFirst;
[167]837 ullTotalBytes = 0;
[42]838 pByte2 = (PBYTE)paffbTotal;
[167]839 for(i = 0; i < ulTotal; i++)
840 {
[42]841 pffbFile = (PFILEFINDBUF4)pByte2;
[167]842 ullBytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec,
[2]843 pffbFile,partial,dcd);
[167]844 pci = (PCNRITEM)pci->rc.preccNextRecord;
845 ullTotalBytes += ullBytes;
846
[42]847 pByte2 += sizeof(FILEFINDBUF4);
[2]848 }
[167]849 if (ulTotal)
850 {
[2]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;
[167]860 if (!WinSendMsg(hwndCnr,CM_INSERTRECORD,
861 MPFROMP(pciFirst),MPFROMP(&ri)))
862 {
[2]863 DosSleep(100L);
864 WinSetFocus(HWND_DESKTOP,hwndCnr);
[167]865 if (!WinSendMsg(hwndCnr,CM_INSERTRECORD,
[90]866 MPFROMP(pciFirst),MPFROMP(&ri)))
867 {
[31]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
[145]879 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
880 GetPString(IDS_FILLDIRERR5TEXT));
[167]881 ok = FALSE;
882 ullTotalBytes = 0;
883 if (WinIsWindow((HAB)0,hwndCnr))
884 {
[2]885 pci = pciFirst;
[167]886 while (pci)
887 {
[2]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 }
[167]898 else
899 {
[145]900 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
901 GetPString(IDS_FILLDIRERR3TEXT));
[167]902 ok = FALSE;
903 ullTotalBytes = 0;
[2]904 }
[167]905 if (ok)
906 {
907 ullReturnBytes += ullTotalBytes;
908 ulReturnFiles += ulFileCnt;
[2]909 }
910 }
911 }
912
[167]913 if (!fSyncUpdates && dcd && dcd->type == DIR_FRAME)
[2]914 WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID,
915 MPFROM2SHORT(0,CMA_ERASE));
916 }
917Abort:
[167]918 if (paffbTotal || papffbSelected || paffbFound || pszFileSpec)
919 {
920 if (paffbTotal)
[42]921 free(paffbTotal);
[167]922 if (pszFileSpec)
[42]923 free(pszFileSpec);
[167]924 if (paffbFound)
[42]925 free(paffbFound);
[167]926 if (papffbSelected)
[42]927 free(papffbSelected);
[2]928 }
[167]929 if (recurse)
930 {
[2]931 pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent),
932 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
[167]933 while (pci && (INT)pci != -1)
934 {
935 if (pci->attrFile & FILE_DIRECTORY)
[2]936 Stubby(hwndCnr,pci);
937 pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
938 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
939 }
940 }
941
[167]942 if (pulTotalFiles)
943 *pulTotalFiles = ulReturnFiles;
[2]944
[167]945 if (pullTotalBytes)
946 *pullTotalBytes = ullReturnBytes;
[2]947
[167]948} // ProcessDirectory
949
950
951VOID FillDirCnr(HWND hwndCnr,
952 CHAR *pszDirectory,
953 DIRCNRDATA *dcd,
954 PULONGLONG pullTotalBytes)
[90]955{
[167]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);
[2]966 DosPostEventSem(CompactSem);
967
[167]968} // FillDirCnr
[2]969
[167]970
971VOID FillTreeCnr(HWND hwndCnr,HWND hwndParent)
[90]972{
[2]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;
[167]984 for (x = 0;x < 26;x++)
[2]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);
[167]993 if (!DosQuerySysInfo(QSV_BOOT_DRIVE,
994 QSV_BOOT_DRIVE,
995 (PVOID)&startdrive,
996 (ULONG)sizeof(ULONG)) &&
[2]997 startdrive)
998 driveflags[startdrive - 1] |= DRIVE_BOOT;
999 }
1000 DosError(FERR_DISABLEHARDERR);
1001 rc = DosQCurDisk(&ulDriveNum,
1002 &ulDriveMap);
[167]1003 if (rc)
1004 {
[2]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++)
[167]1014 if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE))
[2]1015 numtoinsert++;
[167]1016 if (numtoinsert)
[2]1017 pciFirst = WinSendMsg(hwndCnr,
1018 CM_ALLOCRECORD,
1019 MPFROMLONG(EXTRA_RECORD_BYTES2),
1020 MPFROMLONG((ULONG)numtoinsert));
[167]1021 if (pciFirst)
1022 {
[2]1023 pci = pciFirst;
1024 for(x = 0;x < 26;x++) {
[167]1025 if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE))
1026 {
[2]1027 *szDrive = (CHAR)x + 'A';
1028
1029 {
1030 CHAR s[80];
[167]1031 ULONG flags = 0;
1032 ULONG size = sizeof(ULONG);
[2]1033
1034 sprintf(s,"%c.DriveFlags",toupper(*szDrive));
[167]1035 if (PrfQueryProfileData(fmprof,appname,s,&flags,&size) &&
1036 size == sizeof(ULONG))
1037 {
[2]1038 driveflags[toupper(*szDrive) - 'A'] |= flags;
[167]1039 }
[2]1040 }
1041
[167]1042 if (x > 1)
1043 {
1044 if (!(driveflags[x] & DRIVE_NOPRESCAN))
1045 {
[2]1046 *FileSystem = 0;
1047 drvtype = 0;
1048 removable = CheckDrive(*szDrive,FileSystem,&drvtype);
1049 driveserial[x] = -1;
[167]1050 if (removable != -1)
1051 {
[2]1052 struct {
1053 ULONG serial;
1054 CHAR volumelength;
1055 CHAR volumelabel[CCHMAXPATH];
1056 } volser;
1057
1058 DosError(FERR_DISABLEHARDERR);
[167]1059 if (!DosQueryFSInfo((ULONG)x,
1060 FSIL_VOLSER,
1061 &volser,
1062 sizeof(volser)))
1063 {
[2]1064 driveserial[x] = volser.serial;
[167]1065 }
[2]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);
[167]1072 if (drvtype & DRIVE_REMOTE)
[2]1073 driveflags[x] |= DRIVE_REMOTE;
[70]1074 if (strcmp(FileSystem,HPFS) &&
1075 strcmp(FileSystem,JFS) &&
1076 strcmp(FileSystem,CDFS) &&
1077 strcmp(FileSystem,FAT32) &&
1078 strcmp(FileSystem,HPFS386))
1079 {
[2]1080 driveflags[x] |= DRIVE_NOLONGNAMES;
[70]1081 }
[167]1082 if (!strcmp(FileSystem,CDFS))
1083 {
[2]1084 removable = 1;
[70]1085 driveflags[x] |= DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE |
1086 DRIVE_CDROM;
[2]1087 }
[167]1088 else if (!stricmp(FileSystem,CBSIFS))
[70]1089 {
[2]1090 driveflags[x] |= DRIVE_ZIPSTREAM;
[70]1091 driveflags[x] &= ~DRIVE_REMOTE;
[167]1092 if (drvtype & DRIVE_REMOVABLE)
[2]1093 driveflags[x] |= DRIVE_REMOVABLE;
[167]1094 if (!(drvtype & DRIVE_NOLONGNAMES))
[70]1095 driveflags[x] &= ~DRIVE_NOLONGNAMES;
[2]1096 }
1097
1098 pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
[167]1099 if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum)
[2]1100 pci->rc.flRecordAttr |= (CRA_CURSORED | CRA_SELECTED);
1101
[167]1102 if (removable == 0)
1103 {
[2]1104 pci->attrFile |= FILE_DIRECTORY;
1105 DosError(FERR_DISABLEHARDERR);
1106 rc = DosQueryPathInfo(szDrive,
1107 FIL_QUERYEASIZE,
1108 &fsa4,
1109 (ULONG)sizeof(FILESTATUS4));
[167]1110 if (rc == 58)
1111 {
[2]1112 DosError(FERR_DISABLEHARDERR);
1113 rc = DosQueryPathInfo(szDrive,
1114 FIL_STANDARD,
1115 &fsa4,
1116 (ULONG)sizeof(FILESTATUS3));
1117 fsa4.cbList = 0;
1118 }
[167]1119 if (rc && !didonce)
1120 {
1121 if (!*suggest)
1122 {
[2]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 }
[167]1145 else
1146 {
[2]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);
[167]1155 if (driveflags[x] & DRIVE_CDROM)
[2]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 }
[167]1165 else
1166 {
[2]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 }
[167]1177 else
1178 {
[2]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 }
[167]1192 else if (!(ulDriveMap & (1L << x)))
[2]1193 driveflags[x] |= DRIVE_INVALID;
1194 }
1195 PostMsg(hwndMain,
1196 UM_BUILDDRIVES,
1197 MPVOID,
1198 MPVOID);
1199 drivesbuilt = TRUE;
1200 /* insert the drives */
[167]1201 if (numtoinsert && pciFirst)
1202 {
[2]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;
[167]1212 if (!WinSendMsg(hwndCnr,
1213 CM_INSERTRECORD,
1214 MPFROMP(pciFirst),
1215 MPFROMP(&ri)))
[145]1216 Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__,
1217 GetPString(IDS_FILLDIRERR5TEXT));
[2]1218 }
1219 /* move cursor onto the default drive rather than the first drive */
[167]1220 if (!fSwitchTree)
1221 {
[2]1222 pci = (PCNRITEM)WinSendMsg(hwndCnr,
1223 CM_QUERYRECORD,
1224 MPVOID,
1225 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
[167]1226 while(pci && (INT)pci != -1)
1227 {
1228 if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum)
1229 {
[2]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
[167]1243 if (hwndParent)
[2]1244 WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
1245 MAIN_DRIVELIST),
1246 LM_DELETEALL,
1247 MPVOID,
1248 MPVOID);
1249
[167]1250 if (fShowEnv)
1251 {
[2]1252 RECORDINSERT ri;
1253
1254 pciParent = WinSendMsg(hwndCnr,
1255 CM_ALLOCRECORD,
1256 MPFROMLONG(EXTRA_RECORD_BYTES2),
1257 MPFROMLONG(1));
[167]1258 if (pciParent)
1259 {
[2]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;
[167]1274 if (WinSendMsg(hwndCnr,
1275 CM_INSERTRECORD,
1276 MPFROMP(pciParent),
1277 MPFROMP(&ri))) {
[2]1278
1279 char *p,*pp;
1280
1281 p = GetPString(IDS_ENVVARNAMES);
1282 while(*p == ' ')
1283 p++;
[167]1284 while (*p)
1285 {
[2]1286 *FileSystem = 0;
1287 pp = FileSystem;
1288 while(*p && *p != ' ')
1289 *pp++ = *p++;
1290 *pp = 0;
1291 while(*p == ' ')
1292 p++;
[167]1293 if (*FileSystem &&
1294 (!stricmp(FileSystem,"LIBPATH") ||
1295 getenv(FileSystem)))
1296 {
[2]1297 pci = WinSendMsg(hwndCnr,
1298 CM_ALLOCRECORD,
1299 MPFROMLONG(EXTRA_RECORD_BYTES2),
1300 MPFROMLONG(1));
[167]1301 if (pci)
1302 {
[2]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;
[167]1319 if (!WinSendMsg(hwndCnr,
1320 CM_INSERTRECORD,
1321 MPFROMP(pci),
1322 MPFROMP(&ri))) {
[145]1323 Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__,
1324 GetPString(IDS_FILLDIRERR5TEXT));
[2]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,
[167]1350 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
1351 while (pci && (INT)pci != -1)
1352 {
[2]1353 pciNext = (PCNRITEM)WinSendMsg(hwndCnr,
1354 CM_QUERYRECORD,
1355 MPFROMP(pci),
[167]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) &&
[2]1363 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOPRESCAN) &&
1364 (!fNoRemovableScan ||
[167]1365 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE)))
1366 {
1367 if (!Stubby(hwndCnr,pci))
1368 {
[2]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));
[167]1382
[2]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 }
[167]1393 if (hwndParent)
[2]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));
[167]1403 while (pci && (INT)pci != -1)
1404 {
[2]1405 pciNext = (PCNRITEM)WinSendMsg(hwndCnr,
1406 CM_QUERYRECORD,
1407 MPFROMP(pci),
1408 MPFROM2SHORT(CMA_NEXT,
1409 CMA_ITEMORDER));
[167]1410 if (pci->flags & RECFLAGS_ENV)
1411 {
[2]1412 pci = (PCNRITEM)WinSendMsg(hwndCnr,
1413 CM_QUERYRECORD,
1414 MPFROMP(pci),
1415 MPFROM2SHORT(CMA_FIRSTCHILD,
1416 CMA_ITEMORDER));
[167]1417 while (pci && (INT)pci != -1)
1418 {
1419 if (pci->flags & RECFLAGS_ENV)
[2]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 }
[167]1437 else
1438 {
[145]1439 Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__,
1440 GetPString(IDS_FILLDIRERR7TEXT));
[2]1441 exit(0);
1442 }
[167]1443 if (!drivesbuilt && hwndMain)
[2]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
[167]1455 if (*suggest ||
1456 (!(driveflags[1] & DRIVE_IGNORE) &&
1457 fFirstTime))
1458 {
1459 if (!DosDevConfig(&info,
[2]1460 DEVINFO_FLOPPY) &&
[167]1461 info == 1)
1462 {
1463 if (!*suggest)
1464 {
[2]1465 *suggest = '/';
1466 suggest[1] = 0;
1467 }
1468 else
1469 memmove(suggest + 2,suggest + 1,strlen(suggest));
1470 suggest[1] = 'B';
1471 }
1472 }
[167]1473 if (*suggest)
1474 {
1475 for(x = 2;x < 26;x++)
1476 {
1477 if (driveflags[x] & DRIVE_IGNORE)
1478 {
[2]1479 includesyours = TRUE;
1480 sprintf(suggest + strlen(suggest),
1481 "%c",
1482 (char)(x + 'A'));
1483 }
1484 }
1485 strcat(suggest," %*");
[167]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 {
[2]1493 char s[64];
1494
[167]1495 sprintf(s, "PARAMETERS=%s", suggest);
[2]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
[167]1541} // FillTreeCnr
1542
Note: See TracBrowser for help on using the repository browser.