[31] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: filldir.c 384 2006-07-27 06:42:04Z root $
|
---|
| 5 |
|
---|
| 6 | Fill Directory Tree Containers
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[359] | 9 | Copyright (c) 2001, 2006 Steven H. Levine
|
---|
[31] | 10 |
|
---|
[145] | 11 | 10 Jan 04 SHL ProcessDirectory: avoid most large drive failures
|
---|
| 12 | 24 May 05 SHL Rework Win_Error usage
|
---|
[167] | 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
|
---|
[174] | 17 | 28 May 05 SHL Drop stale debug code
|
---|
[188] | 18 | 05 Jun 05 SHL Comments
|
---|
[214] | 19 | 09 Jun 05 SHL Rework WinLoadFileIcon enables
|
---|
| 20 | 09 Jun 05 SHL Rework IDFile
|
---|
[246] | 21 | 13 Aug 05 SHL Renames
|
---|
[282] | 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
|
---|
[359] | 25 | 22 Jul 06 SHL Check more run time errors
|
---|
[31] | 26 |
|
---|
| 27 | ***********************************************************************/
|
---|
| 28 |
|
---|
[2] | 29 | #define INCL_DOS
|
---|
| 30 | #define INCL_WIN
|
---|
[167] | 31 | #define INCL_LONGLONG
|
---|
| 32 | #include <os2.h>
|
---|
[2] | 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>
|
---|
[167] | 40 |
|
---|
[2] | 41 | #include "fm3dll.h"
|
---|
| 42 | #include "fm3str.h"
|
---|
| 43 |
|
---|
[359] | 44 | static PSZ pszSrcFile = __FILE__;
|
---|
| 45 |
|
---|
[2] | 46 | #pragma alloc_text(FILLDIR,FillInRecordFromFFB,FillInRecordFromFSA,IDFile)
|
---|
| 47 | #pragma alloc_text(FILLDIR1,ProcessDirectory,FillDirCnr,FillTreeCnr)
|
---|
| 48 |
|
---|
| 49 |
|
---|
[214] | 50 | static HPOINTER IDFile(PSZ p)
|
---|
[90] | 51 | {
|
---|
[2] | 52 | HPOINTER hptr;
|
---|
[214] | 53 | ULONG cmp;
|
---|
| 54 | CHAR cmps[4];
|
---|
[2] | 55 |
|
---|
[214] | 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 |
|
---|
[2] | 84 | return hptr;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 |
|
---|
[214] | 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 |
|
---|
[167] | 153 | ULONGLONG FillInRecordFromFFB(HWND hwndCnr,PCNRITEM pci, const PSZ pszDirectory,
|
---|
[214] | 154 | const PFILEFINDBUF4 pffb,const BOOL partial,
|
---|
| 155 | DIRCNRDATA *dcd)
|
---|
[31] | 156 | {
|
---|
[2] | 157 | /* fill in a container record from a FILEFINDBUF4 structure */
|
---|
| 158 |
|
---|
[167] | 159 | CHAR attrstring[] = "RHS\0DA";
|
---|
| 160 | CHAR *p;
|
---|
| 161 | HPOINTER hptr;
|
---|
| 162 | UINT x;
|
---|
| 163 | UINT y;
|
---|
| 164 | UINT t;
|
---|
[2] | 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
|
---|
[167] | 171 | (like in update.c)
|
---|
| 172 | */
|
---|
| 173 | if (*pffb->achName)
|
---|
| 174 | {
|
---|
[2] | 175 | p = pci->szFileName + (t - 1);
|
---|
[167] | 176 | if (*p != '\\') {
|
---|
[2] | 177 | p++;
|
---|
| 178 | *p = '\\';
|
---|
| 179 | }
|
---|
| 180 | p++;
|
---|
| 181 | memcpy(p,pffb->achName,pffb->cchName + 1);
|
---|
| 182 | }
|
---|
| 183 | /* load the object's Subject, if required */
|
---|
[167] | 184 | if (pffb->cbList > 4L &&
|
---|
| 185 | dcd && fLoadSubject &&
|
---|
| 186 | (isalpha(*pci->szFileName) &&
|
---|
| 187 | !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADSUBJS)))
|
---|
| 188 | {
|
---|
[2] | 189 | APIRET rc;
|
---|
| 190 | EAOP2 eaop;
|
---|
| 191 | PGEA2LIST pgealist;
|
---|
| 192 | PFEA2LIST pfealist;
|
---|
| 193 | PGEA2 pgea;
|
---|
| 194 | PFEA2 pfea;
|
---|
| 195 | CHAR *value;
|
---|
| 196 |
|
---|
[359] | 197 | pgealist = xmallocz(sizeof(GEA2LIST) + 32,pszSrcFile,__LINE__);
|
---|
| 198 | if (pgealist) {
|
---|
[2] | 199 | pgea = &pgealist->list[0];
|
---|
| 200 | strcpy(pgea->szName,SUBJECT);
|
---|
| 201 | pgea->cbName = strlen(pgea->szName);
|
---|
[188] | 202 | pgea->oNextEntryOffset = 0;
|
---|
[2] | 203 | pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
|
---|
[359] | 204 | pfealist = xmallocz(1532,pszSrcFile,__LINE__);
|
---|
| 205 | if (pfealist) {
|
---|
[214] | 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);
|
---|
[2] | 221 | }
|
---|
| 222 | free(pgealist);
|
---|
| 223 | }
|
---|
| 224 | }
|
---|
[167] | 225 | pci->pszSubject = pci->szSubject;
|
---|
[2] | 226 | /* load the object's longname */
|
---|
[167] | 227 | *pci->szLongname = 0;
|
---|
[282] | 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)
|
---|
[167] | 234 | {
|
---|
[2] | 235 | APIRET rc;
|
---|
| 236 | EAOP2 eaop;
|
---|
| 237 | PGEA2LIST pgealist;
|
---|
| 238 | PFEA2LIST pfealist;
|
---|
| 239 | PGEA2 pgea;
|
---|
| 240 | PFEA2 pfea;
|
---|
| 241 | CHAR *value;
|
---|
| 242 |
|
---|
[359] | 243 | pgealist = xmallocz(sizeof(GEA2LIST) + 32,pszSrcFile,__LINE__);
|
---|
| 244 | if (pgealist) {
|
---|
[2] | 245 | pgea = &pgealist->list[0];
|
---|
| 246 | strcpy(pgea->szName,LONGNAME);
|
---|
| 247 | pgea->cbName = strlen(pgea->szName);
|
---|
[188] | 248 | pgea->oNextEntryOffset = 0;
|
---|
[2] | 249 | pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
|
---|
[359] | 250 | pfealist = xmallocz(1532,pszSrcFile,__LINE__);
|
---|
[167] | 251 | if (pfealist) {
|
---|
[214] | 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)
|
---|
[167] | 259 | {
|
---|
[214] | 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);
|
---|
[2] | 268 | }
|
---|
| 269 | free(pgealist);
|
---|
| 270 | }
|
---|
| 271 | }
|
---|
[167] | 272 | pci->pszLongname = pci->szLongname;
|
---|
[2] | 273 |
|
---|
| 274 | /* do anything required to case of filename */
|
---|
[167] | 275 | if (fForceUpper)
|
---|
[2] | 276 | strupr(pci->szFileName);
|
---|
[167] | 277 | else if (fForceLower)
|
---|
[2] | 278 | strlwr(pci->szFileName);
|
---|
| 279 |
|
---|
| 280 | /* get an icon to use with it */
|
---|
[167] | 281 | if (pffb->attrFile & FILE_DIRECTORY)
|
---|
| 282 | {
|
---|
[214] | 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
|
---|
[2] | 291 | hptr = WinLoadFileIcon(pci->szFileName, FALSE);
|
---|
| 292 | }
|
---|
[167] | 293 | else
|
---|
| 294 | {
|
---|
[214] | 295 | // is file
|
---|
| 296 | if (fNoIconsFiles ||
|
---|
| 297 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS) ||
|
---|
| 298 | !isalpha(*pci->szFileName))
|
---|
[167] | 299 | {
|
---|
[214] | 300 | hptr = (HPOINTER)0;
|
---|
[167] | 301 | }
|
---|
[42] | 302 | else
|
---|
[214] | 303 | hptr = WinLoadFileIcon(pci->szFileName, FALSE);
|
---|
[167] | 304 |
|
---|
[214] | 305 | if (!hptr || IsDefaultIcon(hptr))
|
---|
| 306 | hptr = IDFile(pci->szFileName);
|
---|
[2] | 307 | }
|
---|
[214] | 308 |
|
---|
[167] | 309 | if (!hptr)
|
---|
| 310 | {
|
---|
[214] | 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;
|
---|
[167] | 320 | }
|
---|
[2] | 321 |
|
---|
| 322 | /* decide where to point for the container's title text */
|
---|
[167] | 323 | if (partial)
|
---|
| 324 | {
|
---|
[2] | 325 | p = strrchr(pci->szFileName,'\\');
|
---|
[167] | 326 | if (!p)
|
---|
| 327 | {
|
---|
[2] | 328 | p = strrchr(pci->szFileName,':');
|
---|
[167] | 329 | if (!p)
|
---|
[214] | 330 | p = pci->szFileName;
|
---|
[2] | 331 | else
|
---|
[214] | 332 | p++;
|
---|
[2] | 333 | }
|
---|
[167] | 334 | else if ((dcd && dcd->type == TREE_FRAME) ||
|
---|
[214] | 335 | (!(pffb->attrFile & FILE_DIRECTORY) || !*(p + 1)))
|
---|
[167] | 336 | {
|
---|
[2] | 337 | p++;
|
---|
[167] | 338 | }
|
---|
| 339 | if (!*p)
|
---|
[2] | 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;
|
---|
[51] | 364 | pci->easize = CBLIST_TO_EASIZE(pffb->cbList);
|
---|
[2] | 365 | pci->cbFile = pffb->cbFile;
|
---|
| 366 | pci->attrFile = pffb->attrFile;
|
---|
| 367 | /* build attribute string for display */
|
---|
| 368 | y = 0;
|
---|
[167] | 369 | for (x = 0; x < 6; x++)
|
---|
| 370 | {
|
---|
| 371 | if (attrstring[x])
|
---|
| 372 | {
|
---|
| 373 | pci->szDispAttr[y++] =
|
---|
[214] | 374 | (CHAR)((pci->attrFile & (1 << x)) ? attrstring[x] : '-');
|
---|
[167] | 375 | }
|
---|
| 376 | }
|
---|
[2] | 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 */
|
---|
[167] | 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 | {
|
---|
[2] | 390 | if(!Filter((PMINIRECORDCORE)pci,(PVOID)&dcd->mask))
|
---|
[214] | 391 | pci->rc.flRecordAttr |= CRA_FILTERED;
|
---|
[2] | 392 | }
|
---|
| 393 | else if((!(dcd->mask.attrFile & FILE_HIDDEN) &&
|
---|
[214] | 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)))
|
---|
[167] | 401 | {
|
---|
[2] | 402 | pci->rc.flRecordAttr |= CRA_FILTERED;
|
---|
[167] | 403 | }
|
---|
[2] | 404 | }
|
---|
| 405 |
|
---|
| 406 | return pffb->cbFile + pci->easize;
|
---|
| 407 |
|
---|
[167] | 408 | } // FillInRecordFromFFB
|
---|
[2] | 409 |
|
---|
[167] | 410 |
|
---|
| 411 | ULONGLONG FillInRecordFromFSA(HWND hwndCnr,
|
---|
[214] | 412 | PCNRITEM pci,
|
---|
[167] | 413 | const PSZ pszFileName,
|
---|
[214] | 414 | const PFILESTATUS4 pfsa4,
|
---|
| 415 | const BOOL partial,
|
---|
| 416 | DIRCNRDATA *dcd) // Optional
|
---|
[31] | 417 | {
|
---|
[2] | 418 | HPOINTER hptr;
|
---|
[167] | 419 | CHAR attrstring[] = "RHS\0DA";
|
---|
[2] | 420 | register CHAR *p;
|
---|
[167] | 421 | register INT x;
|
---|
| 422 | register INT y;
|
---|
[2] | 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 */
|
---|
[167] | 429 | if (pfsa4->cbList > 4L &&
|
---|
| 430 | dcd &&
|
---|
| 431 | fLoadSubject &&
|
---|
| 432 | (!isalpha(*pci->szFileName) ||
|
---|
| 433 | !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADSUBJS)))
|
---|
| 434 | {
|
---|
[2] | 435 | APIRET rc;
|
---|
| 436 | EAOP2 eaop;
|
---|
| 437 | PGEA2LIST pgealist;
|
---|
| 438 | PFEA2LIST pfealist;
|
---|
| 439 | PGEA2 pgea;
|
---|
| 440 | PFEA2 pfea;
|
---|
| 441 | CHAR *value;
|
---|
| 442 |
|
---|
[359] | 443 | pgealist = xmallocz(sizeof(GEA2LIST) + 32,pszSrcFile,__LINE__);
|
---|
[167] | 444 | if (pgealist) {
|
---|
[2] | 445 | pgea = &pgealist->list[0];
|
---|
| 446 | strcpy(pgea->szName,SUBJECT);
|
---|
| 447 | pgea->cbName = strlen(pgea->szName);
|
---|
[188] | 448 | pgea->oNextEntryOffset = 0;
|
---|
[2] | 449 | pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
|
---|
[359] | 450 | pfealist = xmallocz(1532,pszSrcFile,__LINE__);
|
---|
[167] | 451 | if (pfealist) {
|
---|
[214] | 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);
|
---|
[2] | 468 | }
|
---|
| 469 | free(pgealist);
|
---|
| 470 | }
|
---|
| 471 | }
|
---|
[167] | 472 | pci->pszSubject = pci->szSubject;
|
---|
| 473 | *pci->szLongname = 0;
|
---|
[282] | 474 | if (fLoadLongnames &&
|
---|
[167] | 475 | dcd &&
|
---|
[282] | 476 | pfsa4->cbList > 4L &&
|
---|
| 477 | isalpha(*pci->szFileName) &&
|
---|
| 478 | ~driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLONGNAMES &&
|
---|
| 479 | ~driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADLONGS)
|
---|
[51] | 480 | {
|
---|
[2] | 481 | APIRET rc;
|
---|
| 482 | EAOP2 eaop;
|
---|
| 483 | PGEA2LIST pgealist;
|
---|
| 484 | PFEA2LIST pfealist;
|
---|
| 485 | PGEA2 pgea;
|
---|
| 486 | PFEA2 pfea;
|
---|
| 487 | CHAR *value;
|
---|
| 488 |
|
---|
[359] | 489 | pgealist = xmallocz(sizeof(GEA2LIST) + 32,pszSrcFile,__LINE__);
|
---|
[167] | 490 | if (pgealist) {
|
---|
[2] | 491 | pgea = &pgealist->list[0];
|
---|
| 492 | strcpy(pgea->szName,LONGNAME);
|
---|
| 493 | pgea->cbName = strlen(pgea->szName);
|
---|
[188] | 494 | pgea->oNextEntryOffset = 0;
|
---|
[2] | 495 | pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
|
---|
[359] | 496 | pfealist = xmallocz(1532,pszSrcFile,__LINE__);
|
---|
[167] | 497 | if (pfealist) {
|
---|
[214] | 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);
|
---|
[2] | 513 | }
|
---|
| 514 | free(pgealist);
|
---|
| 515 | }
|
---|
| 516 | }
|
---|
[167] | 517 | pci->pszLongname = pci->szLongname;
|
---|
| 518 | if (fForceUpper)
|
---|
[2] | 519 | strupr(pci->szFileName);
|
---|
[167] | 520 | else if (fForceLower)
|
---|
[2] | 521 | strlwr(pci->szFileName);
|
---|
| 522 |
|
---|
[214] | 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
|
---|
[2] | 532 | hptr = WinLoadFileIcon(pci->szFileName, FALSE);
|
---|
| 533 | }
|
---|
[167] | 534 | else
|
---|
| 535 | {
|
---|
[214] | 536 | if (fNoIconsFiles ||
|
---|
| 537 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS) ||
|
---|
| 538 | !isalpha(*pci->szFileName))
|
---|
[167] | 539 | {
|
---|
[214] | 540 | hptr = IDFile(pci->szFileName);
|
---|
[2] | 541 | }
|
---|
[214] | 542 | else
|
---|
| 543 | hptr = WinLoadFileIcon(pci->szFileName, FALSE);
|
---|
[2] | 544 | }
|
---|
[167] | 545 | if (!hptr)
|
---|
[214] | 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 | }
|
---|
[2] | 557 |
|
---|
[214] | 558 | if (partial)
|
---|
| 559 | {
|
---|
[2] | 560 | p = strrchr(pci->szFileName,'\\');
|
---|
[167] | 561 | if (!p) {
|
---|
[214] | 562 | p = strrchr(pci->szFileName,':');
|
---|
[167] | 563 | if (!p)
|
---|
[214] | 564 | p = pci->szFileName;
|
---|
[2] | 565 | else
|
---|
[214] | 566 | p++;
|
---|
[2] | 567 | }
|
---|
[167] | 568 | else if ((dcd && dcd->type == TREE_FRAME) ||
|
---|
[214] | 569 | !(pfsa4->attrFile & FILE_DIRECTORY) ||
|
---|
[167] | 570 | !*(p + 1))
|
---|
[2] | 571 | p++;
|
---|
[167] | 572 | if (!*p)
|
---|
[2] | 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;
|
---|
[51] | 596 | pci->easize = CBLIST_TO_EASIZE(pfsa4->cbList);
|
---|
[2] | 597 | pci->cbFile = pfsa4->cbFile;
|
---|
| 598 | pci->attrFile = pfsa4->attrFile;
|
---|
| 599 | y = 0;
|
---|
| 600 | for(x = 0;x < 6;x++)
|
---|
[167] | 601 | if (attrstring[x])
|
---|
[2] | 602 | pci->szDispAttr[y++] = (CHAR)((pci->attrFile & (1 << x)) ?
|
---|
[214] | 603 | attrstring[x] : '-');
|
---|
[2] | 604 | pci->szDispAttr[5] = 0;
|
---|
| 605 | pci->pszDispAttr = pci->szDispAttr;
|
---|
| 606 | pci->rc.pszIcon = pci->pszFileName;
|
---|
| 607 | pci->rc.hptrIcon = hptr;
|
---|
| 608 |
|
---|
[167] | 609 | if (dcd &&
|
---|
| 610 | (*dcd->mask.szMask || dcd->mask.antiattr ||
|
---|
| 611 | ((dcd->mask.attrFile &
|
---|
[214] | 612 | (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) !=
|
---|
| 613 | (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED))))
|
---|
[167] | 614 | {
|
---|
| 615 | if (*dcd->mask.szMask || dcd->mask.antiattr)
|
---|
| 616 | {
|
---|
| 617 | if (!Filter((PMINIRECORDCORE)pci,(PVOID)&dcd->mask))
|
---|
[214] | 618 | pci->rc.flRecordAttr |= CRA_FILTERED;
|
---|
[2] | 619 | }
|
---|
[167] | 620 | else if ((!(dcd->mask.attrFile & FILE_HIDDEN) &&
|
---|
[214] | 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)))
|
---|
[2] | 628 | pci->rc.flRecordAttr |= CRA_FILTERED;
|
---|
| 629 | }
|
---|
| 630 |
|
---|
| 631 | return pfsa4->cbFile + pci->easize;
|
---|
| 632 |
|
---|
[167] | 633 | } // FillInRecordFromFSA
|
---|
[2] | 634 |
|
---|
[167] | 635 |
|
---|
| 636 | VOID ProcessDirectory(const HWND hwndCnr, const PCNRITEM pciParent,
|
---|
[214] | 637 | const CHAR *szDirBase, const BOOL filestoo,
|
---|
| 638 | const BOOL recurse,const BOOL partial,
|
---|
| 639 | CHAR *stopflag,
|
---|
[167] | 640 | DIRCNRDATA *dcd, // Optional
|
---|
| 641 | ULONG *pulTotalFiles, // Optional
|
---|
| 642 | PULONGLONG pullTotalBytes) // Optional
|
---|
[31] | 643 | {
|
---|
[2] | 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 |
|
---|
[42] | 649 | PSZ pszFileSpec;
|
---|
[2] | 650 | INT t;
|
---|
[167] | 651 | PFILEFINDBUF4 paffbFound;
|
---|
| 652 | PFILEFINDBUF4 *papffbSelected;
|
---|
| 653 | PFILEFINDBUF4 pffbFile;
|
---|
| 654 | PFILEFINDBUF4 paffbTotal = NULL;
|
---|
| 655 | PFILEFINDBUF4 paffbTemp;
|
---|
[2] | 656 | HDIR hdir = HDIR_CREATE;
|
---|
[167] | 657 | ULONG ulFileCnt;
|
---|
| 658 | ULONG ulExtraBytes;
|
---|
| 659 | ULONG ulM = 1;
|
---|
[188] | 660 | ULONG ulTotal = 0;
|
---|
[167] | 661 | ULONGLONG ullBytes;
|
---|
| 662 | ULONGLONG ullTotalBytes;
|
---|
| 663 | ULONG ulReturnFiles = 0;
|
---|
| 664 | ULONGLONG ullReturnBytes = 0;
|
---|
[2] | 665 | PCH pchEndPath;
|
---|
| 666 | APIRET rc;
|
---|
[167] | 667 | PCNRITEM pci;
|
---|
| 668 | PCNRITEM pciFirst;
|
---|
| 669 | PCNRITEM pcit;
|
---|
[2] | 670 | RECORDINSERT ri;
|
---|
[167] | 671 | PBYTE pByte;
|
---|
| 672 | PBYTE pByte2;
|
---|
| 673 | BOOL ok = TRUE;
|
---|
[2] | 674 |
|
---|
[167] | 675 | if (isalpha(*szDirBase) && szDirBase[1] == ':' && szDirBase[2] == '\\')
|
---|
| 676 | {
|
---|
[282] | 677 | ulExtraBytes = EXTRA_RECORD_BYTES;
|
---|
[167] | 678 | if ((driveflags[toupper(*szDirBase) - 'A'] & DRIVE_REMOTE) && fRemoteBug)
|
---|
[214] | 679 | ulM = 1; /* file system gets confused */
|
---|
[167] | 680 | else if (driveflags[toupper(*szDirBase) - 'A'] & DRIVE_ZIPSTREAM)
|
---|
[2] | 681 | ulM = min(FilesToGet,225); /* anything more is wasted */
|
---|
| 682 | else
|
---|
| 683 | ulM = FilesToGet; /* full-out */
|
---|
| 684 | }
|
---|
[167] | 685 | else
|
---|
| 686 | {
|
---|
[2] | 687 | ulExtraBytes = EXTRA_RECORD_BYTES;
|
---|
| 688 | ulM = FilesToGet;
|
---|
| 689 | }
|
---|
[167] | 690 | if (OS2ver[0] == 20 && OS2ver[1] < 30)
|
---|
[2] | 691 | ulM = min(ulM,(65535 / sizeof(FILEFINDBUF4)));
|
---|
| 692 |
|
---|
[167] | 693 | ulFileCnt = ulM;
|
---|
[359] | 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__);
|
---|
[167] | 697 | if (paffbFound && papffbSelected && pszFileSpec) {
|
---|
[2] | 698 | t = strlen(szDirBase);
|
---|
[42] | 699 | memcpy(pszFileSpec,szDirBase,t + 1);
|
---|
| 700 | pchEndPath = pszFileSpec + t;
|
---|
[167] | 701 | if (*(pchEndPath - 1) != '\\') {
|
---|
[2] | 702 | memcpy(pchEndPath,"\\",2);
|
---|
| 703 | pchEndPath++;
|
---|
| 704 | }
|
---|
| 705 | memcpy(pchEndPath,"*",2);
|
---|
| 706 | DosError(FERR_DISABLEHARDERR);
|
---|
[42] | 707 | rc = DosFindFirst(pszFileSpec, &hdir,
|
---|
[214] | 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);
|
---|
[2] | 713 | priority_normal();
|
---|
| 714 | *pchEndPath = 0;
|
---|
[167] | 715 | if (!rc)
|
---|
| 716 | {
|
---|
| 717 | while (!rc)
|
---|
| 718 | {
|
---|
[214] | 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;
|
---|
[2] | 727 |
|
---|
[214] | 728 | if (stopflag && *stopflag)
|
---|
| 729 | goto Abort;
|
---|
| 730 | pByte = (PBYTE)paffbFound;
|
---|
| 731 | for (x = 0;x < ulFileCnt;)
|
---|
[174] | 732 | {
|
---|
[214] | 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]))))
|
---|
[174] | 740 | {
|
---|
[214] | 741 | ulFileCnt--; // Got . or ..
|
---|
[174] | 742 | }
|
---|
[214] | 743 | else
|
---|
| 744 | papffbSelected[x++] = pffbFile; // Count file
|
---|
| 745 | if (!pffbFile->oNextEntryOffset)
|
---|
[174] | 746 | {
|
---|
[214] | 747 | ulFileCnt = x; // Adjust count
|
---|
| 748 | break;
|
---|
| 749 | }
|
---|
| 750 | pByte += pffbFile->oNextEntryOffset;
|
---|
| 751 | }
|
---|
| 752 | if (ulFileCnt)
|
---|
[174] | 753 | {
|
---|
[214] | 754 | if (stopflag && *stopflag)
|
---|
| 755 | goto Abort;
|
---|
| 756 | if (fSyncUpdates)
|
---|
[167] | 757 | {
|
---|
[214] | 758 | pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
|
---|
| 759 | MPFROMLONG(ulExtraBytes),
|
---|
| 760 | MPFROMLONG(ulFileCnt));
|
---|
[359] | 761 | if (!pciFirst) {
|
---|
[384] | 762 | Win_Error2(hwndCnr,HWND_DESKTOP,pszSrcFile,__LINE__,
|
---|
| 763 | IDS_CMALLOCRECERRTEXT);
|
---|
[359] | 764 | ok = FALSE;
|
---|
| 765 | ullTotalBytes = 0;
|
---|
| 766 | }
|
---|
| 767 | else {
|
---|
[214] | 768 | register INT i;
|
---|
[174] | 769 |
|
---|
[214] | 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)
|
---|
[167] | 780 | {
|
---|
[214] | 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)))
|
---|
[167] | 794 | {
|
---|
[214] | 795 | DosSleep(100);
|
---|
| 796 | WinSetFocus(HWND_DESKTOP,hwndCnr);
|
---|
| 797 | if (!WinSendMsg(hwndCnr,
|
---|
| 798 | CM_INSERTRECORD,
|
---|
| 799 | MPFROMP(pciFirst),
|
---|
| 800 | MPFROMP(&ri)))
|
---|
[90] | 801 | {
|
---|
[384] | 802 | Win_Error2(hwndCnr,HWND_DESKTOP,pszSrcFile,__LINE__,
|
---|
| 803 | IDS_CMINSERTERRTEXT);
|
---|
[214] | 804 | ok = FALSE;
|
---|
| 805 | ullTotalBytes = 0;
|
---|
| 806 | if (WinIsWindow((HAB)0,hwndCnr))
|
---|
[174] | 807 | {
|
---|
[214] | 808 | pci = pciFirst;
|
---|
| 809 | while (pci)
|
---|
[167] | 810 | {
|
---|
[214] | 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)
|
---|
[174] | 824 | {
|
---|
[214] | 825 | ullReturnBytes += ullTotalBytes;
|
---|
| 826 | ulReturnFiles += ulFileCnt;
|
---|
| 827 | }
|
---|
| 828 | }
|
---|
| 829 | else
|
---|
[174] | 830 | {
|
---|
[359] | 831 | paffbTemp = xrealloc(paffbTotal,
|
---|
| 832 | sizeof(FILEFINDBUF4) * (ulFileCnt + ulTotal),
|
---|
| 833 | pszSrcFile,__LINE__);
|
---|
[214] | 834 | if (paffbTemp)
|
---|
[174] | 835 | {
|
---|
[214] | 836 | paffbTotal = paffbTemp;
|
---|
| 837 | for(x = 0;x < ulFileCnt;x++)
|
---|
| 838 | paffbTotal[x + ulTotal] = *papffbSelected[x];
|
---|
| 839 | ulTotal += ulFileCnt;
|
---|
| 840 | }
|
---|
| 841 | else
|
---|
[174] | 842 | {
|
---|
[214] | 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);
|
---|
[2] | 860 | }
|
---|
| 861 | DosFindClose(hdir);
|
---|
| 862 |
|
---|
[167] | 863 | if (paffbFound || papffbSelected) {
|
---|
[214] | 864 | if (paffbFound)
|
---|
| 865 | free(paffbFound);
|
---|
| 866 | if (papffbSelected)
|
---|
| 867 | free(papffbSelected);
|
---|
| 868 | papffbSelected = NULL;
|
---|
| 869 | paffbFound = NULL;
|
---|
[2] | 870 | }
|
---|
| 871 |
|
---|
[167] | 872 | if (ulTotal && paffbTotal)
|
---|
| 873 | {
|
---|
| 874 |
|
---|
[214] | 875 | if (stopflag && *stopflag)
|
---|
| 876 | goto Abort;
|
---|
[167] | 877 |
|
---|
[214] | 878 | pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
|
---|
| 879 | MPFROMLONG(ulExtraBytes),
|
---|
| 880 | MPFROMLONG(ulTotal));
|
---|
[359] | 881 | if (!pciFirst) {
|
---|
[384] | 882 | Win_Error2(hwndCnr,HWND_DESKTOP,pszSrcFile,__LINE__,
|
---|
| 883 | IDS_CMALLOCRECERRTEXT);
|
---|
[359] | 884 | ok = FALSE;
|
---|
| 885 | ullTotalBytes = 0;
|
---|
| 886 | }
|
---|
| 887 | else {
|
---|
[214] | 888 | register INT i;
|
---|
[2] | 889 |
|
---|
[214] | 890 | pci = pciFirst;
|
---|
| 891 | ullTotalBytes = 0;
|
---|
| 892 | pByte2 = (PBYTE)paffbTotal;
|
---|
| 893 | for(i = 0; i < ulTotal; i++)
|
---|
[167] | 894 | {
|
---|
[214] | 895 | pffbFile = (PFILEFINDBUF4)pByte2;
|
---|
| 896 | ullBytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec,
|
---|
| 897 | pffbFile,partial,dcd);
|
---|
| 898 | pci = (PCNRITEM)pci->rc.preccNextRecord;
|
---|
| 899 | ullTotalBytes += ullBytes;
|
---|
[167] | 900 |
|
---|
[214] | 901 | pByte2 += sizeof(FILEFINDBUF4);
|
---|
| 902 | }
|
---|
| 903 | if (ulTotal)
|
---|
[167] | 904 | {
|
---|
[214] | 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)))
|
---|
[167] | 916 | {
|
---|
[214] | 917 | DosSleep(100);
|
---|
| 918 | WinSetFocus(HWND_DESKTOP,hwndCnr);
|
---|
| 919 | if (!WinSendMsg(hwndCnr,CM_INSERTRECORD,
|
---|
| 920 | MPFROMP(pciFirst),MPFROMP(&ri)))
|
---|
| 921 | {
|
---|
[384] | 922 | Win_Error2(hwndCnr,HWND_DESKTOP,pszSrcFile,__LINE__,
|
---|
| 923 | IDS_CMINSERTERRTEXT);
|
---|
[214] | 924 | ok = FALSE;
|
---|
| 925 | ullTotalBytes = 0;
|
---|
| 926 | if (WinIsWindow((HAB)0,hwndCnr))
|
---|
[167] | 927 | {
|
---|
[214] | 928 | pci = pciFirst;
|
---|
| 929 | while (pci)
|
---|
[167] | 930 | {
|
---|
[214] | 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)
|
---|
[167] | 942 | {
|
---|
[214] | 943 | ullReturnBytes += ullTotalBytes;
|
---|
| 944 | ulReturnFiles += ulFileCnt;
|
---|
| 945 | }
|
---|
[2] | 946 | }
|
---|
| 947 | }
|
---|
| 948 |
|
---|
[167] | 949 | if (!fSyncUpdates && dcd && dcd->type == DIR_FRAME)
|
---|
[2] | 950 | WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID,
|
---|
[214] | 951 | MPFROM2SHORT(0,CMA_ERASE));
|
---|
[2] | 952 | }
|
---|
| 953 | Abort:
|
---|
[167] | 954 | if (paffbTotal || papffbSelected || paffbFound || pszFileSpec)
|
---|
| 955 | {
|
---|
| 956 | if (paffbTotal)
|
---|
[42] | 957 | free(paffbTotal);
|
---|
[167] | 958 | if (pszFileSpec)
|
---|
[42] | 959 | free(pszFileSpec);
|
---|
[167] | 960 | if (paffbFound)
|
---|
[42] | 961 | free(paffbFound);
|
---|
[167] | 962 | if (papffbSelected)
|
---|
[42] | 963 | free(papffbSelected);
|
---|
[2] | 964 | }
|
---|
[167] | 965 | if (recurse)
|
---|
| 966 | {
|
---|
[2] | 967 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent),
|
---|
[214] | 968 | MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
|
---|
[167] | 969 | while (pci && (INT)pci != -1)
|
---|
| 970 | {
|
---|
| 971 | if (pci->attrFile & FILE_DIRECTORY)
|
---|
[214] | 972 | Stubby(hwndCnr,pci);
|
---|
[2] | 973 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
|
---|
[214] | 974 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
[2] | 975 | }
|
---|
| 976 | }
|
---|
| 977 |
|
---|
[167] | 978 | if (pulTotalFiles)
|
---|
| 979 | *pulTotalFiles = ulReturnFiles;
|
---|
[2] | 980 |
|
---|
[167] | 981 | if (pullTotalBytes)
|
---|
| 982 | *pullTotalBytes = ullReturnBytes;
|
---|
[2] | 983 |
|
---|
[167] | 984 | } // ProcessDirectory
|
---|
| 985 |
|
---|
| 986 |
|
---|
| 987 | VOID FillDirCnr(HWND hwndCnr,
|
---|
[214] | 988 | CHAR *pszDirectory,
|
---|
| 989 | DIRCNRDATA *dcd,
|
---|
| 990 | PULONGLONG pullTotalBytes)
|
---|
[90] | 991 | {
|
---|
[167] | 992 | ProcessDirectory(hwndCnr,
|
---|
[214] | 993 | (PCNRITEM)NULL,
|
---|
[167] | 994 | pszDirectory,
|
---|
| 995 | TRUE,
|
---|
| 996 | FALSE,
|
---|
| 997 | TRUE,
|
---|
[214] | 998 | dcd ? &dcd->stopflag : NULL,
|
---|
[167] | 999 | dcd,
|
---|
| 1000 | NULL,
|
---|
| 1001 | pullTotalBytes);
|
---|
[2] | 1002 | DosPostEventSem(CompactSem);
|
---|
| 1003 |
|
---|
[167] | 1004 | } // FillDirCnr
|
---|
[2] | 1005 |
|
---|
[167] | 1006 |
|
---|
| 1007 | VOID FillTreeCnr(HWND hwndCnr,HWND hwndParent)
|
---|
[90] | 1008 | {
|
---|
[188] | 1009 | ULONG ulDriveNum,ulDriveMap,numtoinsert = 0,drvtype;
|
---|
[2] | 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;
|
---|
[167] | 1020 | for (x = 0;x < 26;x++)
|
---|
[2] | 1021 | driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS |
|
---|
[214] | 1022 | DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS |
|
---|
| 1023 | DRIVE_INCLUDEFILES | DRIVE_SLOW);
|
---|
[2] | 1024 | memset(driveserial,-1,sizeof(driveserial));
|
---|
| 1025 | {
|
---|
| 1026 | ULONG startdrive = 3L;
|
---|
| 1027 |
|
---|
| 1028 | DosError(FERR_DISABLEHARDERR);
|
---|
[167] | 1029 | if (!DosQuerySysInfo(QSV_BOOT_DRIVE,
|
---|
[214] | 1030 | QSV_BOOT_DRIVE,
|
---|
| 1031 | (PVOID)&startdrive,
|
---|
| 1032 | (ULONG)sizeof(ULONG)) &&
|
---|
[2] | 1033 | startdrive)
|
---|
| 1034 | driveflags[startdrive - 1] |= DRIVE_BOOT;
|
---|
| 1035 | }
|
---|
| 1036 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1037 | rc = DosQCurDisk(&ulDriveNum,
|
---|
[214] | 1038 | &ulDriveMap);
|
---|
[167] | 1039 | if (rc)
|
---|
| 1040 | {
|
---|
[2] | 1041 | Dos_Error(MB_CANCEL,
|
---|
[214] | 1042 | rc,
|
---|
| 1043 | HWND_DESKTOP,
|
---|
[359] | 1044 | pszSrcFile,
|
---|
[214] | 1045 | __LINE__,
|
---|
[359] | 1046 | GetPString(IDS_FILLDIRQCURERRTEXT));
|
---|
[2] | 1047 | exit(0);
|
---|
| 1048 | }
|
---|
| 1049 | for(x = 0;x < 26;x++)
|
---|
[167] | 1050 | if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE))
|
---|
[2] | 1051 | numtoinsert++;
|
---|
[167] | 1052 | if (numtoinsert)
|
---|
[2] | 1053 | pciFirst = WinSendMsg(hwndCnr,
|
---|
[214] | 1054 | CM_ALLOCRECORD,
|
---|
| 1055 | MPFROMLONG(EXTRA_RECORD_BYTES2),
|
---|
| 1056 | MPFROMLONG((ULONG)numtoinsert));
|
---|
[359] | 1057 | if (!pciFirst) {
|
---|
[384] | 1058 | Win_Error2(hwndCnr,hwndCnr,pszSrcFile,__LINE__,IDS_CMALLOCRECERRTEXT);
|
---|
[359] | 1059 | exit(0);
|
---|
| 1060 | }
|
---|
| 1061 | else {
|
---|
[2] | 1062 | pci = pciFirst;
|
---|
| 1063 | for(x = 0;x < 26;x++) {
|
---|
[167] | 1064 | if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE))
|
---|
| 1065 | {
|
---|
[214] | 1066 | *szDrive = (CHAR)x + 'A';
|
---|
[2] | 1067 |
|
---|
[214] | 1068 | {
|
---|
| 1069 | CHAR s[80];
|
---|
| 1070 | ULONG flags = 0;
|
---|
[167] | 1071 | ULONG size = sizeof(ULONG);
|
---|
[2] | 1072 |
|
---|
[214] | 1073 | sprintf(s,"%c.DriveFlags",toupper(*szDrive));
|
---|
| 1074 | if (PrfQueryProfileData(fmprof,appname,s,&flags,&size) &&
|
---|
| 1075 | size == sizeof(ULONG))
|
---|
[167] | 1076 | {
|
---|
[214] | 1077 | driveflags[toupper(*szDrive) - 'A'] |= flags;
|
---|
[167] | 1078 | }
|
---|
[214] | 1079 | }
|
---|
[2] | 1080 |
|
---|
[214] | 1081 | if (x > 1)
|
---|
[167] | 1082 | {
|
---|
[214] | 1083 | if (!(driveflags[x] & DRIVE_NOPRESCAN))
|
---|
[167] | 1084 | {
|
---|
[214] | 1085 | *FileSystem = 0;
|
---|
| 1086 | drvtype = 0;
|
---|
| 1087 | removable = CheckDrive(*szDrive,FileSystem,&drvtype);
|
---|
| 1088 | driveserial[x] = -1;
|
---|
| 1089 | if (removable != -1)
|
---|
[167] | 1090 | {
|
---|
[214] | 1091 | struct {
|
---|
| 1092 | ULONG serial;
|
---|
| 1093 | CHAR volumelength;
|
---|
| 1094 | CHAR volumelabel[CCHMAXPATH];
|
---|
| 1095 | } volser;
|
---|
[2] | 1096 |
|
---|
[214] | 1097 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1098 | if (!DosQueryFSInfo((ULONG)x,
|
---|
| 1099 | FSIL_VOLSER,
|
---|
| 1100 | &volser,
|
---|
| 1101 | sizeof(volser)))
|
---|
| 1102 | {
|
---|
| 1103 | driveserial[x] = volser.serial;
|
---|
[167] | 1104 | }
|
---|
[214] | 1105 | }
|
---|
| 1106 | else
|
---|
| 1107 | driveflags[x] |= DRIVE_INVALID;
|
---|
| 1108 | memset(&fsa4,0,sizeof(FILESTATUS4));
|
---|
| 1109 | driveflags[x] |= ((removable == -1 || removable == 1) ?
|
---|
| 1110 | DRIVE_REMOVABLE : 0);
|
---|
| 1111 | if (drvtype & DRIVE_REMOTE)
|
---|
| 1112 | driveflags[x] |= DRIVE_REMOTE;
|
---|
| 1113 | if (strcmp(FileSystem,HPFS) &&
|
---|
| 1114 | strcmp(FileSystem,JFS) &&
|
---|
| 1115 | strcmp(FileSystem,CDFS) &&
|
---|
| 1116 | strcmp(FileSystem,FAT32) &&
|
---|
| 1117 | strcmp(FileSystem,HPFS386))
|
---|
[70] | 1118 | {
|
---|
[214] | 1119 | driveflags[x] |= DRIVE_NOLONGNAMES;
|
---|
[70] | 1120 | }
|
---|
[214] | 1121 | if (!strcmp(FileSystem,CDFS))
|
---|
[167] | 1122 | {
|
---|
[214] | 1123 | removable = 1;
|
---|
| 1124 | driveflags[x] |= DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE |
|
---|
| 1125 | DRIVE_CDROM;
|
---|
| 1126 | }
|
---|
| 1127 | else if (!stricmp(FileSystem,CBSIFS))
|
---|
[70] | 1128 | {
|
---|
[214] | 1129 | driveflags[x] |= DRIVE_ZIPSTREAM;
|
---|
| 1130 | driveflags[x] &= ~DRIVE_REMOTE;
|
---|
| 1131 | if (drvtype & DRIVE_REMOVABLE)
|
---|
| 1132 | driveflags[x] |= DRIVE_REMOVABLE;
|
---|
| 1133 | if (!(drvtype & DRIVE_NOLONGNAMES))
|
---|
| 1134 | driveflags[x] &= ~DRIVE_NOLONGNAMES;
|
---|
| 1135 | }
|
---|
[2] | 1136 |
|
---|
[214] | 1137 | pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
|
---|
| 1138 | if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum)
|
---|
| 1139 | pci->rc.flRecordAttr |= (CRA_CURSORED | CRA_SELECTED);
|
---|
[2] | 1140 |
|
---|
[214] | 1141 | if (removable == 0)
|
---|
[167] | 1142 | {
|
---|
[214] | 1143 | pci->attrFile |= FILE_DIRECTORY;
|
---|
| 1144 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1145 | rc = DosQueryPathInfo(szDrive,
|
---|
| 1146 | FIL_QUERYEASIZE,
|
---|
| 1147 | &fsa4,
|
---|
| 1148 | (ULONG)sizeof(FILESTATUS4));
|
---|
| 1149 | if (rc == 58)
|
---|
[167] | 1150 | {
|
---|
[214] | 1151 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1152 | rc = DosQueryPathInfo(szDrive,
|
---|
| 1153 | FIL_STANDARD,
|
---|
| 1154 | &fsa4,
|
---|
| 1155 | (ULONG)sizeof(FILESTATUS3));
|
---|
| 1156 | fsa4.cbList = 0;
|
---|
| 1157 | }
|
---|
| 1158 | if (rc && !didonce)
|
---|
[167] | 1159 | {
|
---|
[214] | 1160 | if (!*suggest)
|
---|
[167] | 1161 | {
|
---|
[214] | 1162 | *suggest = '/';
|
---|
| 1163 | suggest[1] = 0;
|
---|
| 1164 | }
|
---|
| 1165 | sprintf(suggest + strlen(suggest),
|
---|
| 1166 | "%c",
|
---|
| 1167 | toupper(*szDrive));
|
---|
| 1168 | strcpy(pci->szFileName,szDrive);
|
---|
| 1169 | pci->pszFileName = pci->szFileName;
|
---|
| 1170 | pci->rc.pszIcon = pci->pszFileName;
|
---|
| 1171 | pci->attrFile = FILE_DIRECTORY;
|
---|
| 1172 | strcpy(pci->szDispAttr,"----D-");
|
---|
| 1173 | pci->pszDispAttr = pci->szDispAttr;
|
---|
| 1174 | driveserial[x] = -1;
|
---|
| 1175 | }
|
---|
| 1176 | else
|
---|
| 1177 | FillInRecordFromFSA(hwndCnr,
|
---|
| 1178 | pci,
|
---|
| 1179 | szDrive,
|
---|
| 1180 | &fsa4,
|
---|
| 1181 | TRUE,
|
---|
| 1182 | NULL);
|
---|
| 1183 | }
|
---|
| 1184 | else
|
---|
[167] | 1185 | {
|
---|
[214] | 1186 | strcpy(pci->szFileName,szDrive);
|
---|
| 1187 | pci->pszFileName = pci->szFileName;
|
---|
| 1188 | pci->rc.pszIcon = pci->pszFileName;
|
---|
| 1189 | pci->attrFile = FILE_DIRECTORY;
|
---|
| 1190 | strcpy(pci->szDispAttr,"----D-");
|
---|
| 1191 | pci->pszDispAttr = pci->szDispAttr;
|
---|
| 1192 | }
|
---|
| 1193 | *pci->szFileName = toupper(*pci->szFileName);
|
---|
| 1194 | if (driveflags[x] & DRIVE_CDROM)
|
---|
| 1195 | pci->rc.hptrIcon = hptrCDROM;
|
---|
| 1196 | else
|
---|
| 1197 | pci->rc.hptrIcon = (driveflags[x] & DRIVE_REMOVABLE) ?
|
---|
| 1198 | hptrRemovable :
|
---|
| 1199 | (driveflags[x] & DRIVE_REMOTE) ?
|
---|
| 1200 | hptrRemote :
|
---|
| 1201 | (driveflags[x] & DRIVE_ZIPSTREAM) ?
|
---|
| 1202 | hptrZipstrm : hptrDrive;
|
---|
| 1203 | }
|
---|
| 1204 | else
|
---|
[167] | 1205 | {
|
---|
[214] | 1206 | pci->rc.hptrIcon = hptrDunno;
|
---|
| 1207 | strcpy(pci->szFileName,szDrive);
|
---|
| 1208 | pci->pszFileName = pci->szFileName;
|
---|
| 1209 | pci->rc.pszIcon = pci->pszFileName;
|
---|
| 1210 | pci->attrFile = FILE_DIRECTORY;
|
---|
| 1211 | strcpy(pci->szDispAttr,"----D-");
|
---|
| 1212 | pci->pszDispAttr = pci->szDispAttr;
|
---|
| 1213 | driveserial[x] = -1;
|
---|
| 1214 | }
|
---|
| 1215 | }
|
---|
| 1216 | else
|
---|
[167] | 1217 | {
|
---|
[214] | 1218 | pci->rc.hptrIcon = hptrFloppy;
|
---|
| 1219 | strcpy(pci->szFileName,szDrive);
|
---|
| 1220 | pci->pszFileName = pci->szFileName;
|
---|
| 1221 | pci->rc.pszIcon = pci->pszFileName;
|
---|
| 1222 | pci->attrFile = FILE_DIRECTORY;
|
---|
| 1223 | strcpy(pci->szDispAttr,"----D-");
|
---|
| 1224 | pci->pszDispAttr = pci->szDispAttr;
|
---|
| 1225 | driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOLONGNAMES);
|
---|
| 1226 | driveserial[x] = -1;
|
---|
| 1227 | }
|
---|
| 1228 | pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
|
---|
| 1229 | pci = (PCNRITEM)pci->rc.preccNextRecord; /* next rec */
|
---|
[2] | 1230 | }
|
---|
[167] | 1231 | else if (!(ulDriveMap & (1L << x)))
|
---|
[214] | 1232 | driveflags[x] |= DRIVE_INVALID;
|
---|
[2] | 1233 | }
|
---|
| 1234 | PostMsg(hwndMain,
|
---|
[246] | 1235 | UM_BUILDDRIVEBAR,
|
---|
[214] | 1236 | MPVOID,
|
---|
| 1237 | MPVOID);
|
---|
[2] | 1238 | drivesbuilt = TRUE;
|
---|
| 1239 | /* insert the drives */
|
---|
[167] | 1240 | if (numtoinsert && pciFirst)
|
---|
| 1241 | {
|
---|
[2] | 1242 | RECORDINSERT ri;
|
---|
| 1243 |
|
---|
| 1244 | memset(&ri,0,sizeof(RECORDINSERT));
|
---|
| 1245 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 1246 | ri.pRecordOrder = (PRECORDCORE)CMA_END;
|
---|
| 1247 | ri.pRecordParent = (PRECORDCORE)NULL;
|
---|
| 1248 | ri.zOrder = (ULONG)CMA_TOP;
|
---|
| 1249 | ri.cRecordsInsert = numtoinsert;
|
---|
| 1250 | ri.fInvalidateRecord = FALSE;
|
---|
[167] | 1251 | if (!WinSendMsg(hwndCnr,
|
---|
[214] | 1252 | CM_INSERTRECORD,
|
---|
| 1253 | MPFROMP(pciFirst),
|
---|
| 1254 | MPFROMP(&ri)))
|
---|
[384] | 1255 | Win_Error2(hwndCnr,hwndCnr,pszSrcFile,__LINE__,IDS_CMINSERTERRTEXT);
|
---|
[2] | 1256 | }
|
---|
| 1257 | /* move cursor onto the default drive rather than the first drive */
|
---|
[167] | 1258 | if (!fSwitchTree)
|
---|
| 1259 | {
|
---|
[2] | 1260 | pci = (PCNRITEM)WinSendMsg(hwndCnr,
|
---|
[214] | 1261 | CM_QUERYRECORD,
|
---|
| 1262 | MPVOID,
|
---|
| 1263 | MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
|
---|
[167] | 1264 | while(pci && (INT)pci != -1)
|
---|
| 1265 | {
|
---|
[214] | 1266 | if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum)
|
---|
[167] | 1267 | {
|
---|
[214] | 1268 | WinSendMsg(hwndCnr,
|
---|
| 1269 | CM_SETRECORDEMPHASIS,
|
---|
| 1270 | MPFROMP(pci),
|
---|
| 1271 | MPFROM2SHORT(TRUE,CRA_CURSORED));
|
---|
| 1272 | break;
|
---|
| 1273 | }
|
---|
| 1274 | pci = (PCNRITEM)WinSendMsg(hwndCnr,
|
---|
| 1275 | CM_QUERYRECORD,
|
---|
| 1276 | MPFROMP(pci),
|
---|
| 1277 | MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
|
---|
[2] | 1278 | }
|
---|
| 1279 | }
|
---|
| 1280 |
|
---|
[167] | 1281 | if (hwndParent)
|
---|
[2] | 1282 | WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
|
---|
[214] | 1283 | MAIN_DRIVELIST),
|
---|
| 1284 | LM_DELETEALL,
|
---|
| 1285 | MPVOID,
|
---|
| 1286 | MPVOID);
|
---|
[2] | 1287 |
|
---|
[167] | 1288 | if (fShowEnv)
|
---|
| 1289 | {
|
---|
[2] | 1290 | RECORDINSERT ri;
|
---|
| 1291 |
|
---|
| 1292 | pciParent = WinSendMsg(hwndCnr,
|
---|
[214] | 1293 | CM_ALLOCRECORD,
|
---|
| 1294 | MPFROMLONG(EXTRA_RECORD_BYTES2),
|
---|
| 1295 | MPFROMLONG(1));
|
---|
[167] | 1296 | if (pciParent)
|
---|
| 1297 | {
|
---|
[214] | 1298 | pciParent->flags |= RECFLAGS_ENV;
|
---|
| 1299 | strcpy(pciParent->szFileName,GetPString(IDS_ENVVARSTEXT));
|
---|
| 1300 | pciParent->pszFileName = pciParent->szFileName;
|
---|
| 1301 | pciParent->rc.hptrIcon = hptrEnv;
|
---|
| 1302 | pciParent->rc.pszIcon = pciParent->pszFileName;
|
---|
| 1303 | strcpy(pciParent->szDispAttr,"------");
|
---|
| 1304 | pciParent->pszDispAttr = pciParent->szDispAttr;
|
---|
| 1305 | memset(&ri,0,sizeof(RECORDINSERT));
|
---|
| 1306 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 1307 | ri.pRecordOrder = (PRECORDCORE)CMA_END;
|
---|
| 1308 | ri.pRecordParent = (PRECORDCORE)NULL;
|
---|
| 1309 | ri.zOrder = (ULONG)CMA_TOP;
|
---|
| 1310 | ri.cRecordsInsert = 1;
|
---|
| 1311 | ri.fInvalidateRecord = FALSE;
|
---|
| 1312 | if (WinSendMsg(hwndCnr,
|
---|
| 1313 | CM_INSERTRECORD,
|
---|
| 1314 | MPFROMP(pciParent),
|
---|
| 1315 | MPFROMP(&ri))) {
|
---|
[2] | 1316 |
|
---|
[214] | 1317 | char *p,*pp;
|
---|
[2] | 1318 |
|
---|
[214] | 1319 | p = GetPString(IDS_ENVVARNAMES);
|
---|
| 1320 | while(*p == ' ')
|
---|
| 1321 | p++;
|
---|
| 1322 | while (*p)
|
---|
[167] | 1323 | {
|
---|
[214] | 1324 | *FileSystem = 0;
|
---|
| 1325 | pp = FileSystem;
|
---|
| 1326 | while(*p && *p != ' ')
|
---|
| 1327 | *pp++ = *p++;
|
---|
| 1328 | *pp = 0;
|
---|
| 1329 | while(*p == ' ')
|
---|
| 1330 | p++;
|
---|
| 1331 | if (*FileSystem &&
|
---|
| 1332 | (!stricmp(FileSystem,"LIBPATH") ||
|
---|
| 1333 | getenv(FileSystem)))
|
---|
[167] | 1334 | {
|
---|
[214] | 1335 | pci = WinSendMsg(hwndCnr,
|
---|
| 1336 | CM_ALLOCRECORD,
|
---|
| 1337 | MPFROMLONG(EXTRA_RECORD_BYTES2),
|
---|
| 1338 | MPFROMLONG(1));
|
---|
| 1339 | if (pci)
|
---|
[167] | 1340 | {
|
---|
[214] | 1341 | pci->flags |= RECFLAGS_ENV;
|
---|
| 1342 | sprintf(pci->szFileName,
|
---|
| 1343 | "%%%s%%",
|
---|
| 1344 | FileSystem);
|
---|
| 1345 | pci->pszFileName = pci->szFileName;
|
---|
| 1346 | pci->rc.hptrIcon = hptrEnv;
|
---|
| 1347 | pci->rc.pszIcon = pci->pszFileName;
|
---|
| 1348 | strcpy(pci->szDispAttr,"------");
|
---|
| 1349 | pci->pszDispAttr = pci->szDispAttr;
|
---|
| 1350 | memset(&ri,0,sizeof(RECORDINSERT));
|
---|
| 1351 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 1352 | ri.pRecordOrder = (PRECORDCORE)CMA_END;
|
---|
| 1353 | ri.pRecordParent = (PRECORDCORE)pciParent;
|
---|
| 1354 | ri.zOrder = (ULONG)CMA_TOP;
|
---|
| 1355 | ri.cRecordsInsert = 1;
|
---|
| 1356 | ri.fInvalidateRecord = FALSE;
|
---|
| 1357 | if (!WinSendMsg(hwndCnr,
|
---|
| 1358 | CM_INSERTRECORD,
|
---|
| 1359 | MPFROMP(pci),
|
---|
| 1360 | MPFROMP(&ri))) {
|
---|
[384] | 1361 | Win_Error2(hwndCnr,hwndCnr,pszSrcFile,__LINE__,IDS_CMINSERTERRTEXT);
|
---|
| 1362 | WinSendMsg(hwndCnr,CM_FREERECORD,MPFROMP(&pci),MPFROMSHORT(1));
|
---|
[214] | 1363 | }
|
---|
| 1364 | }
|
---|
| 1365 | }
|
---|
| 1366 | }
|
---|
| 1367 | WinSendMsg(hwndCnr,
|
---|
| 1368 | CM_INVALIDATERECORD,
|
---|
| 1369 | MPFROMP(&pciParent),
|
---|
| 1370 | MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
|
---|
| 1371 | }
|
---|
| 1372 | else
|
---|
| 1373 | WinSendMsg(hwndCnr,
|
---|
| 1374 | CM_FREERECORD,
|
---|
| 1375 | MPFROMP(&pciParent),
|
---|
| 1376 | MPFROMSHORT(1));
|
---|
[2] | 1377 | }
|
---|
| 1378 | }
|
---|
| 1379 |
|
---|
| 1380 | x = 0;
|
---|
| 1381 | pci = (PCNRITEM)WinSendMsg(hwndCnr,
|
---|
[214] | 1382 | CM_QUERYRECORD,
|
---|
| 1383 | MPVOID,
|
---|
| 1384 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
[167] | 1385 | while (pci && (INT)pci != -1)
|
---|
| 1386 | {
|
---|
[2] | 1387 | pciNext = (PCNRITEM)WinSendMsg(hwndCnr,
|
---|
[214] | 1388 | CM_QUERYRECORD,
|
---|
| 1389 | MPFROMP(pci),
|
---|
| 1390 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
[167] | 1391 | if (!(pci->flags & RECFLAGS_ENV))
|
---|
| 1392 | {
|
---|
[214] | 1393 | if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum ||
|
---|
| 1394 | toupper(*pci->szFileName) > 'B')
|
---|
[167] | 1395 | {
|
---|
[214] | 1396 | if (!(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_INVALID) &&
|
---|
| 1397 | !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOPRESCAN) &&
|
---|
| 1398 | (!fNoRemovableScan ||
|
---|
| 1399 | !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE)))
|
---|
[167] | 1400 | {
|
---|
[214] | 1401 | if (!Stubby(hwndCnr,pci))
|
---|
[167] | 1402 | {
|
---|
[214] | 1403 | WinSendMsg(hwndCnr,
|
---|
| 1404 | CM_INVALIDATERECORD,
|
---|
| 1405 | MPFROMP(&pci),
|
---|
| 1406 | MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
|
---|
| 1407 | goto SkipBadRec;
|
---|
| 1408 | }
|
---|
| 1409 | }
|
---|
| 1410 | }
|
---|
| 1411 | else
|
---|
| 1412 | WinSendMsg(hwndCnr,
|
---|
| 1413 | CM_INVALIDATERECORD,
|
---|
| 1414 | MPFROMP(&pci),
|
---|
| 1415 | MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
|
---|
[167] | 1416 |
|
---|
[214] | 1417 | WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
|
---|
| 1418 | MAIN_DRIVELIST),
|
---|
| 1419 | LM_INSERTITEM,
|
---|
| 1420 | MPFROM2SHORT(LIT_SORTASCENDING,0),
|
---|
| 1421 | MPFROMP(pci->szFileName));
|
---|
[2] | 1422 | }
|
---|
| 1423 | SkipBadRec:
|
---|
| 1424 | x++;
|
---|
| 1425 | pci = pciNext;
|
---|
| 1426 | }
|
---|
[167] | 1427 | if (hwndParent)
|
---|
[2] | 1428 | WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
|
---|
[214] | 1429 | MAIN_DRIVELIST),LM_SELECTITEM,MPFROM2SHORT(0,0),
|
---|
| 1430 | MPFROMLONG(TRUE));
|
---|
[2] | 1431 |
|
---|
| 1432 | pci = (PCNRITEM)WinSendMsg(hwndCnr,
|
---|
[214] | 1433 | CM_QUERYRECORD,
|
---|
| 1434 | MPVOID,
|
---|
| 1435 | MPFROM2SHORT(CMA_FIRST,
|
---|
| 1436 | CMA_ITEMORDER));
|
---|
[167] | 1437 | while (pci && (INT)pci != -1)
|
---|
| 1438 | {
|
---|
[2] | 1439 | pciNext = (PCNRITEM)WinSendMsg(hwndCnr,
|
---|
[214] | 1440 | CM_QUERYRECORD,
|
---|
| 1441 | MPFROMP(pci),
|
---|
| 1442 | MPFROM2SHORT(CMA_NEXT,
|
---|
| 1443 | CMA_ITEMORDER));
|
---|
[167] | 1444 | if (pci->flags & RECFLAGS_ENV)
|
---|
| 1445 | {
|
---|
[214] | 1446 | pci = (PCNRITEM)WinSendMsg(hwndCnr,
|
---|
| 1447 | CM_QUERYRECORD,
|
---|
| 1448 | MPFROMP(pci),
|
---|
| 1449 | MPFROM2SHORT(CMA_FIRSTCHILD,
|
---|
| 1450 | CMA_ITEMORDER));
|
---|
| 1451 | while (pci && (INT)pci != -1)
|
---|
[167] | 1452 | {
|
---|
[214] | 1453 | if (pci->flags & RECFLAGS_ENV)
|
---|
| 1454 | FleshEnv(hwndCnr,pci);
|
---|
| 1455 | pci = (PCNRITEM)WinSendMsg(hwndCnr,
|
---|
| 1456 | CM_QUERYRECORD,
|
---|
| 1457 | MPFROMP(pci),
|
---|
| 1458 | MPFROM2SHORT(CMA_NEXT,
|
---|
| 1459 | CMA_ITEMORDER));
|
---|
| 1460 | }
|
---|
| 1461 | break;
|
---|
[2] | 1462 | }
|
---|
| 1463 | pci = (PCNRITEM)WinSendMsg(hwndCnr,
|
---|
[214] | 1464 | CM_QUERYRECORD,
|
---|
| 1465 | MPFROMP(pci),
|
---|
| 1466 | MPFROM2SHORT(CMA_NEXT,
|
---|
| 1467 | CMA_ITEMORDER));
|
---|
[2] | 1468 | }
|
---|
| 1469 |
|
---|
| 1470 | }
|
---|
[167] | 1471 | if (!drivesbuilt && hwndMain)
|
---|
[2] | 1472 | PostMsg(hwndMain,
|
---|
[246] | 1473 | UM_BUILDDRIVEBAR,
|
---|
[214] | 1474 | MPVOID,
|
---|
| 1475 | MPVOID);
|
---|
[2] | 1476 | DosSleep(33L);
|
---|
| 1477 | fDummy = FALSE;
|
---|
| 1478 | DosPostEventSem(CompactSem);
|
---|
| 1479 | {
|
---|
| 1480 | BYTE info;
|
---|
| 1481 | BOOL includesyours = FALSE;
|
---|
| 1482 |
|
---|
[167] | 1483 | if (*suggest ||
|
---|
[214] | 1484 | (!(driveflags[1] & DRIVE_IGNORE) &&
|
---|
| 1485 | fFirstTime))
|
---|
[167] | 1486 | {
|
---|
| 1487 | if (!DosDevConfig(&info,
|
---|
[214] | 1488 | DEVINFO_FLOPPY) &&
|
---|
| 1489 | info == 1)
|
---|
[167] | 1490 | {
|
---|
[214] | 1491 | if (!*suggest)
|
---|
[167] | 1492 | {
|
---|
[214] | 1493 | *suggest = '/';
|
---|
| 1494 | suggest[1] = 0;
|
---|
| 1495 | }
|
---|
| 1496 | else
|
---|
| 1497 | memmove(suggest + 2,suggest + 1,strlen(suggest));
|
---|
| 1498 | suggest[1] = 'B';
|
---|
[2] | 1499 | }
|
---|
| 1500 | }
|
---|
[167] | 1501 | if (*suggest)
|
---|
| 1502 | {
|
---|
| 1503 | for(x = 2;x < 26;x++)
|
---|
| 1504 | {
|
---|
[214] | 1505 | if (driveflags[x] & DRIVE_IGNORE)
|
---|
[167] | 1506 | {
|
---|
[214] | 1507 | includesyours = TRUE;
|
---|
| 1508 | sprintf(suggest + strlen(suggest),
|
---|
| 1509 | "%c",
|
---|
| 1510 | (char)(x + 'A'));
|
---|
| 1511 | }
|
---|
[2] | 1512 | }
|
---|
| 1513 | strcat(suggest," %*");
|
---|
[167] | 1514 | if (saymsg(MB_YESNO | MB_ICONEXCLAMATION,
|
---|
[214] | 1515 | (hwndParent) ? hwndParent : hwndCnr,
|
---|
| 1516 | GetPString(IDS_SUGGESTTITLETEXT),
|
---|
| 1517 | GetPString(IDS_SUGGEST1TEXT),
|
---|
| 1518 | (includesyours) ? GetPString(IDS_SUGGEST2TEXT) : NullStr,
|
---|
| 1519 | suggest) == MBID_YES)
|
---|
[167] | 1520 | {
|
---|
[214] | 1521 | char s[64];
|
---|
[2] | 1522 |
|
---|
[214] | 1523 | sprintf(s, "PARAMETERS=%s", suggest);
|
---|
| 1524 | WinCreateObject(WPProgram,
|
---|
| 1525 | "FM/2",
|
---|
| 1526 | s,
|
---|
| 1527 | FM3Folder,
|
---|
| 1528 | CO_UPDATEIFEXISTS);
|
---|
| 1529 | WinCreateObject(WPProgram,
|
---|
| 1530 | "FM/2 Lite",
|
---|
| 1531 | s,
|
---|
| 1532 | FM3Folder,
|
---|
| 1533 | CO_UPDATEIFEXISTS);
|
---|
| 1534 | WinCreateObject(WPProgram,
|
---|
| 1535 | "Archive Viewer/2",
|
---|
| 1536 | s,
|
---|
| 1537 | FM3Tools,
|
---|
| 1538 | CO_UPDATEIFEXISTS);
|
---|
| 1539 | WinCreateObject(WPProgram,
|
---|
| 1540 | "Dir Sizes",
|
---|
| 1541 | s,
|
---|
| 1542 | FM3Tools,
|
---|
| 1543 | CO_UPDATEIFEXISTS);
|
---|
| 1544 | WinCreateObject(WPProgram,
|
---|
| 1545 | "Visual Tree",
|
---|
| 1546 | s,
|
---|
| 1547 | FM3Tools,
|
---|
| 1548 | CO_UPDATEIFEXISTS);
|
---|
| 1549 | WinCreateObject(WPProgram,
|
---|
| 1550 | "Visual Directory",
|
---|
| 1551 | s,
|
---|
| 1552 | FM3Tools,
|
---|
| 1553 | CO_UPDATEIFEXISTS);
|
---|
| 1554 | WinCreateObject(WPProgram,
|
---|
| 1555 | "Global File Viewer",
|
---|
| 1556 | s,
|
---|
| 1557 | FM3Tools,
|
---|
| 1558 | CO_UPDATEIFEXISTS);
|
---|
| 1559 | WinCreateObject(WPProgram,
|
---|
| 1560 | "Databar",
|
---|
| 1561 | s,
|
---|
| 1562 | FM3Tools,
|
---|
| 1563 | CO_UPDATEIFEXISTS);
|
---|
[2] | 1564 | }
|
---|
| 1565 | }
|
---|
| 1566 | }
|
---|
| 1567 | didonce = TRUE;
|
---|
| 1568 |
|
---|
[167] | 1569 | } // FillTreeCnr
|
---|
| 1570 |
|
---|