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