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