source: trunk/dll/filldir.c@ 551

Last change on this file since 551 was 551, checked in by Gregg Young, 19 years ago

Indentation cleanup

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