source: trunk/dll/filldir.c@ 174

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

Drop stale debug code

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