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