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