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