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