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