source: trunk/dll/filldir.c@ 689

Last change on this file since 689 was 689, checked in by Steven Levine, 18 years ago

Commit OpenWatcom compatibility updates

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