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