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