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