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