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