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