source: trunk/dll/filldir.c@ 304

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

FillInRecordFromFFB: correct longname display enable
FillInRecordFromFSA: correct longname display enable
Drop obsolete code

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