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