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