source: trunk/dll/filldir.c@ 251

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

Renames

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