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