source: trunk/dll/filldir.c@ 551

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

Indentation cleanup

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