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