source: trunk/dll/filldir.c@ 617

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

Convert win bmp to os2 increase extension check for icons to 4 letters from 3 add mommy make it stop to help

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