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