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