| [31] | 1 |  | 
|---|
|  | 2 | /*********************************************************************** | 
|---|
|  | 3 |  | 
|---|
|  | 4 | $Id: filldir.c 1402 2009-03-14 17:17:59Z gyoung $ | 
|---|
|  | 5 |  | 
|---|
|  | 6 | Fill Directory Tree Containers | 
|---|
|  | 7 |  | 
|---|
|  | 8 | Copyright (c) 1993-98 M. Kimes | 
|---|
| [907] | 9 | Copyright (c) 2001, 2008 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 | 
|---|
| [985] | 42 | 29 Feb 08 GKY Use xfree where appropriate | 
|---|
| [1063] | 43 | 07 Jul 08 SHL Use NULL rather than NullStr in FreeCnrItemData | 
|---|
| [1075] | 44 | 16 JUL 08 GKY Use TMP directory for temp files | 
|---|
| [1083] | 45 | 20 Jul 08 JBS Ticket 114: Support user-selectable env. strings in Tree container. | 
|---|
| [1090] | 46 | 21 Jul 08 JBS Ticket 114: Change env var separator from blank to semicolon | 
|---|
| [1104] | 47 | 02 Aug 08 GKY Remove redundant strcpys from inner loop | 
|---|
| [1114] | 48 | 23 Aug 08 GKY Free pszDisplayName when appropriate | 
|---|
| [1154] | 49 | 01 Sep 08 GKY Updated FreeCnrItemData to prevent trap in strrchr if pci->pszFileName is NULL. | 
|---|
|  | 50 | 05 Sep 08 SHL Correct FreeCnrItemData pszDisplayName pointer overlap check | 
|---|
| [1174] | 51 | 08 Sep 08 SHL Remove extra pszLongName logic in FreeCnrItemData | 
|---|
| [1250] | 52 | 18 Oct 08 GKY Scan drives in 4 passes (local, virtual, remote, flagged slow) to speed tree scans | 
|---|
| [1284] | 53 | 19 Nov 08 SHL Correct and sanitize 4 pass scan logic | 
|---|
| [1290] | 54 | 21 Nov 08 SHL FillTreeCnr: ensure any unchecked drives checked in pass 4 | 
|---|
| [1299] | 55 | 24 Nov 08 GKY Add StubyScanThread to treecnr scan/rescan drives all on separate threads | 
|---|
|  | 56 | 24 Nov 08 GKY Replace 4 pass drive scan code with StubyScanThread multithread scan | 
|---|
| [1308] | 57 | 28 Nov 08 SHL FreeCnrItemData: optimize and always NULL pointers | 
|---|
|  | 58 | 28 Nov 08 SHL StubbyScanThread: add else lost in translation | 
|---|
|  | 59 | 30 Nov 08 SHL StubbyScanThread: restore else - we want all drives listed | 
|---|
|  | 60 | 30 Nov 08 SHL FreeCnrItemData: report double free with Runtime_Error | 
|---|
| [1319] | 61 | 04 Dec 08 GKY Use event semaphore to prevent scan of "last" directory container prior to | 
|---|
| [1335] | 62 | tree scan completion; prevents duplicate directory names in tree. | 
|---|
|  | 63 | 10 Dec 08 SHL Integrate exception handler support | 
|---|
| [1358] | 64 | 25 Dec 08 GKY Add code to allow write verify to be turned off on a per drive basis | 
|---|
|  | 65 | 25 Dec 08 GKY Add ProcessDirectoryThread to allow optional recursive drive scan at startup. | 
|---|
| [1395] | 66 | 07 Feb 09 GKY Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error | 
|---|
| [1400] | 67 | 08 Mar 09 GKY Renamed commafmt.h i18nutil.h | 
|---|
| [1402] | 68 | 08 Mar 09 GKY Additional strings move to PCSZs | 
|---|
|  | 69 | 08 Mar 09 GKY Removed variable aurguments from docopyf and unlinkf (not used) | 
|---|
|  | 70 | 14 Mar 09 GKY Prevent execution of UM_SHOWME while drive scan is occuring | 
|---|
| [31] | 71 |  | 
|---|
|  | 72 | ***********************************************************************/ | 
|---|
|  | 73 |  | 
|---|
| [2] | 74 | #include <stdlib.h> | 
|---|
|  | 75 | #include <string.h> | 
|---|
| [1154] | 76 | #include <malloc.h>                     // _msize _heapchk | 
|---|
| [2] | 77 | #include <ctype.h> | 
|---|
| [1335] | 78 | // #include <process.h>                 // _beginthread | 
|---|
| [763] | 79 |  | 
|---|
| [907] | 80 | #define INCL_DOS | 
|---|
|  | 81 | #define INCL_WIN | 
|---|
|  | 82 | #define INCL_DOSERRORS | 
|---|
|  | 83 | #define INCL_LONGLONG | 
|---|
|  | 84 |  | 
|---|
| [1182] | 85 | #include "fm3dll.h" | 
|---|
| [1223] | 86 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc. | 
|---|
| [1207] | 87 | #include "draglist.h"                   // Data declaration(s) | 
|---|
|  | 88 | #include "treecnr.h"                    // Data declaration(s) | 
|---|
|  | 89 | #include "info.h"                       // Data declaration(s) | 
|---|
|  | 90 | #include "newview.h"                    // Data declaration(s) | 
|---|
| [907] | 91 | #include "fm3str.h" | 
|---|
|  | 92 | #include "filldir.h" | 
|---|
|  | 93 | #include "errutil.h"                    // Dos_Error... | 
|---|
|  | 94 | #include "strutil.h"                    // GetPString | 
|---|
| [1078] | 95 | #include "misc.h"                       // GetTidForWindow | 
|---|
|  | 96 | #include "fortify.h"                    // 06 May 08 SHL | 
|---|
| [1083] | 97 | #include "notebook.h"                   // INI file fields | 
|---|
| [1159] | 98 | #include "flesh.h"                      // FleshEnv, Stubby | 
|---|
|  | 99 | #include "update.h"                     // SelectDriveIcon | 
|---|
| [1182] | 100 | #include "valid.h"                      // CheckDrive | 
|---|
|  | 101 | #include "filter.h"                     // Filter | 
|---|
|  | 102 | #include "subj.h"                       // Subject | 
|---|
|  | 103 | #include "copyf.h"                      // unlinkf | 
|---|
|  | 104 | #include "literal.h"                    // wildcard | 
|---|
| [1400] | 105 | #include "i18nutil.h"                   // CommaFmtULL | 
|---|
| [1182] | 106 | #include "wrappers.h"                   // xDosFindNext | 
|---|
| [1207] | 107 | #include "init.h"                       // GetTidForWindow | 
|---|
| [1308] | 108 | #include "common.h"                     // IncrThreadUsage | 
|---|
| [1335] | 109 | #include "excputil.h"                   // xbeginthread | 
|---|
| [2] | 110 |  | 
|---|
| [1299] | 111 | VOID StubbyScanThread(VOID * arg); | 
|---|
|  | 112 |  | 
|---|
| [1207] | 113 | // Data definitions | 
|---|
| [359] | 114 | static PSZ pszSrcFile = __FILE__; | 
|---|
| [1207] | 115 | static BOOL fFirstTime; | 
|---|
| [359] | 116 |  | 
|---|
| [1207] | 117 | #pragma data_seg(GLOBAL1) | 
|---|
|  | 118 | HPOINTER hptrEnv; | 
|---|
|  | 119 | HPOINTER hptrHidden; | 
|---|
|  | 120 | HPOINTER hptrReadonly; | 
|---|
|  | 121 | HPOINTER hptrSystem; | 
|---|
|  | 122 |  | 
|---|
|  | 123 | #pragma data_seg(GLOBAL2) | 
|---|
| [1402] | 124 | PCSZ FM3Tools   = "<FM3_Tools>"; | 
|---|
|  | 125 | PCSZ WPProgram  = "WPProgram"; | 
|---|
| [1308] | 126 | volatile INT StubbyScanCount; | 
|---|
| [1354] | 127 | volatile INT ProcessDirCount; | 
|---|
| [1207] | 128 |  | 
|---|
| [1299] | 129 | typedef struct { | 
|---|
|  | 130 | PCNRITEM    pci; | 
|---|
| [1308] | 131 | HWND        hwndCnr;                  // hwnd you want the message posted to | 
|---|
| [1299] | 132 | HWND        hwndDrivesList; | 
|---|
|  | 133 | BOOL        RamDrive; | 
|---|
|  | 134 | } | 
|---|
|  | 135 | STUBBYSCAN; | 
|---|
|  | 136 |  | 
|---|
| [751] | 137 | /** | 
|---|
|  | 138 | * Return display string given standard file attribute mask | 
|---|
|  | 139 | * @param fileAttr attribute mask in FILEFINDBUF format | 
|---|
|  | 140 | * @return fixed length string for display | 
|---|
|  | 141 | */ | 
|---|
|  | 142 |  | 
|---|
|  | 143 | const PSZ FileAttrToString(ULONG fileAttr) | 
|---|
|  | 144 | { | 
|---|
|  | 145 | // From os2win.h | 
|---|
|  | 146 | // FILE_ATTRIBUTE_READONLY    0x00000001 | 
|---|
|  | 147 | // FILE_ATTRIBUTE_HIDDEN      0x00000002 | 
|---|
|  | 148 | // FILE_ATTRIBUTE_SYSTEM      0x00000004 | 
|---|
|  | 149 | //                            0x00000008 | 
|---|
|  | 150 | // FILE_ATTRIBUTE_DIRECTORY   0x00000010 | 
|---|
|  | 151 | // FILE_ATTRIBUTE_ARCHIVE     0x00000020 | 
|---|
|  | 152 |  | 
|---|
|  | 153 | static CHAR *apszAttrString[] = { | 
|---|
|  | 154 | // RHSDA | 
|---|
|  | 155 | "-----", | 
|---|
|  | 156 | "R----", | 
|---|
|  | 157 | "-H---", | 
|---|
|  | 158 | "RH---", | 
|---|
|  | 159 | "--S--", | 
|---|
|  | 160 | "R-S--", | 
|---|
|  | 161 | "-HS--", | 
|---|
|  | 162 | "RHS--", | 
|---|
|  | 163 | "---D-", | 
|---|
|  | 164 | "R--D-", | 
|---|
|  | 165 | "-H-D-", | 
|---|
|  | 166 | "RH-D-", | 
|---|
|  | 167 | "--SD-", | 
|---|
|  | 168 | "R-SD-", | 
|---|
|  | 169 | "-HSD-", | 
|---|
|  | 170 | "RHSD-", | 
|---|
|  | 171 | "----A", | 
|---|
|  | 172 | "R---A", | 
|---|
|  | 173 | "-H--A", | 
|---|
|  | 174 | "RH--A", | 
|---|
|  | 175 | "--S-A", | 
|---|
|  | 176 | "R-S-A", | 
|---|
|  | 177 | "-HS-A", | 
|---|
|  | 178 | "RHS-A", | 
|---|
|  | 179 | "---DA", | 
|---|
|  | 180 | "R--DA", | 
|---|
|  | 181 | "-H-DA", | 
|---|
|  | 182 | "RH-DA", | 
|---|
|  | 183 | "--SDA", | 
|---|
|  | 184 | "R-SDA", | 
|---|
|  | 185 | "-HSDA", | 
|---|
|  | 186 | "RHSDA" | 
|---|
|  | 187 | }; | 
|---|
|  | 188 |  | 
|---|
|  | 189 | fileAttr = ((fileAttr & 0x30) >> 1) | (fileAttr & 7); // Drop don't care bit from index | 
|---|
|  | 190 |  | 
|---|
|  | 191 | return apszAttrString[fileAttr]; | 
|---|
|  | 192 |  | 
|---|
|  | 193 | } | 
|---|
|  | 194 |  | 
|---|
| [1299] | 195 | VOID StubbyScanThread(VOID * arg) | 
|---|
|  | 196 | { | 
|---|
|  | 197 | STUBBYSCAN *StubbyScan; | 
|---|
|  | 198 | HAB thab; | 
|---|
|  | 199 | HMQ hmq = (HMQ) 0; | 
|---|
|  | 200 | BOOL ret; | 
|---|
|  | 201 |  | 
|---|
|  | 202 | DosError(FERR_DISABLEHARDERR); | 
|---|
|  | 203 |  | 
|---|
|  | 204 | # ifdef FORTIFY | 
|---|
|  | 205 | Fortify_EnterScope(); | 
|---|
|  | 206 | #  endif | 
|---|
|  | 207 |  | 
|---|
| [1308] | 208 | StubbyScan = (STUBBYSCAN *)arg; | 
|---|
|  | 209 | if (StubbyScan && StubbyScan->pci && StubbyScan->pci->pszFileName && StubbyScan->hwndCnr) { | 
|---|
| [1299] | 210 | thab = WinInitialize(0); | 
|---|
|  | 211 | if (thab) { | 
|---|
|  | 212 | hmq = WinCreateMsgQueue(thab, 0); | 
|---|
|  | 213 | if (hmq) { | 
|---|
| [1354] | 214 | StubbyScanCount++; | 
|---|
| [1308] | 215 | IncrThreadUsage(); | 
|---|
|  | 216 | priority_normal(); | 
|---|
| [1354] | 217 | ret = Stubby(StubbyScan->hwndCnr, StubbyScan->pci); | 
|---|
|  | 218 | //DbgMsg(pszSrcFile, __LINE__, "Stubby %i ", ret); | 
|---|
|  | 219 | if (ret == 1) { | 
|---|
|  | 220 | if (WinIsWindow((HAB)0, StubbyScan->hwndCnr)) { | 
|---|
| [1308] | 221 | WinSendMsg(StubbyScan->hwndCnr, | 
|---|
|  | 222 | CM_INVALIDATERECORD, | 
|---|
|  | 223 | MPFROMP(&StubbyScan->pci), | 
|---|
| [1347] | 224 | MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION)); | 
|---|
| [1354] | 225 | if (fRScanLocal) { | 
|---|
|  | 226 | if (!(driveflags[toupper(*StubbyScan->pci->pszFileName) - 'A'] & | 
|---|
|  | 227 | ((fRScanNoWrite ? 0 : DRIVE_NOTWRITEABLE) | | 
|---|
|  | 228 | (fRScanRemote ? 0 : DRIVE_REMOTE) | | 
|---|
|  | 229 | (fRScanSlow ? 0 : DRIVE_SLOW) | | 
|---|
|  | 230 | (fRScanVirtual ? 0 : DRIVE_VIRTUAL))) | 
|---|
|  | 231 | && fInitialDriveScan) { | 
|---|
|  | 232 | WinSendMsg(StubbyScan->hwndCnr, CM_EXPANDTREE, MPFROMP(StubbyScan->pci), MPVOID); | 
|---|
|  | 233 | //DbgMsg(pszSrcFile, __LINE__, "expanded %x %s", StubbyScan->hwndCnr, StubbyScan->pci->pszFileName); | 
|---|
|  | 234 | WinSendMsg(StubbyScan->hwndCnr, CM_COLLAPSETREE, MPFROMP(StubbyScan->pci), MPVOID); | 
|---|
|  | 235 | } | 
|---|
|  | 236 | } | 
|---|
|  | 237 | else  if ((fRScanRemote && (driveflags[toupper(*StubbyScan->pci->pszFileName) - 'A'] & | 
|---|
|  | 238 | DRIVE_REMOTE)) || | 
|---|
|  | 239 | (fRScanVirtual && (driveflags[toupper(*StubbyScan->pci->pszFileName) - 'A'] & | 
|---|
|  | 240 | DRIVE_VIRTUAL)) && fInitialDriveScan) { | 
|---|
|  | 241 | if (!(driveflags[toupper(*StubbyScan->pci->pszFileName) - 'A'] & | 
|---|
|  | 242 | ((fRScanNoWrite ? NULL : DRIVE_NOTWRITEABLE) | | 
|---|
|  | 243 | (fRScanSlow ? NULL : DRIVE_SLOW)))) { | 
|---|
|  | 244 | WinSendMsg(StubbyScan->hwndCnr, CM_EXPANDTREE, MPFROMP(StubbyScan->pci), MPVOID); | 
|---|
|  | 245 | //DbgMsg(pszSrcFile, __LINE__, "expanded %x %s", StubbyScan->hwndCnr, StubbyScan->pci->pszFileName); | 
|---|
|  | 246 | WinSendMsg(StubbyScan->hwndCnr, CM_COLLAPSETREE, MPFROMP(StubbyScan->pci), MPVOID); | 
|---|
|  | 247 | } | 
|---|
|  | 248 | } | 
|---|
| [1347] | 249 | } | 
|---|
| [1354] | 250 | } | 
|---|
| [1308] | 251 | if (WinIsWindow((HAB)0, StubbyScan->hwndDrivesList)) { | 
|---|
|  | 252 | WinSendMsg(StubbyScan->hwndDrivesList, | 
|---|
|  | 253 | LM_INSERTITEM, | 
|---|
|  | 254 | MPFROM2SHORT(LIT_SORTASCENDING, 0), | 
|---|
|  | 255 | MPFROMP(StubbyScan->pci->pszFileName)); | 
|---|
| [1402] | 256 | } | 
|---|
|  | 257 | StubbyScanCount--; | 
|---|
| [1354] | 258 | /* if (StubbyScanCount == 0) { | 
|---|
|  | 259 | if (fInitialDriveScan) { | 
|---|
|  | 260 | WinShowWindow(StubbyScan->hwndCnr, TRUE); | 
|---|
|  | 261 | WinShowWindow(StubbyScan->hwndDrivesList, TRUE); | 
|---|
|  | 262 | } | 
|---|
|  | 263 | fInitialDriveScan = FALSE; | 
|---|
|  | 264 | }*/ | 
|---|
| [1308] | 265 | WinDestroyMsgQueue(hmq); | 
|---|
| [1299] | 266 | } | 
|---|
|  | 267 | DecrThreadUsage(); | 
|---|
|  | 268 | WinTerminate(thab); | 
|---|
|  | 269 | } | 
|---|
|  | 270 | free(StubbyScan); | 
|---|
|  | 271 | } // if StubbyScan | 
|---|
|  | 272 | # ifdef FORTIFY | 
|---|
|  | 273 | Fortify_LeaveScope(); | 
|---|
|  | 274 | #  endif | 
|---|
|  | 275 |  | 
|---|
| [1335] | 276 | // _endthread();                      // 10 Dec 08 SHL | 
|---|
| [1299] | 277 | } | 
|---|
|  | 278 |  | 
|---|
| [1354] | 279 | VOID ProcessDirectoryThread(VOID * arg) | 
|---|
|  | 280 | { | 
|---|
|  | 281 | PROCESSDIR *ProcessDir; | 
|---|
|  | 282 | HAB thab; | 
|---|
|  | 283 | HMQ hmq = (HMQ) 0; | 
|---|
|  | 284 | //BOOL ret; | 
|---|
|  | 285 |  | 
|---|
|  | 286 | DosError(FERR_DISABLEHARDERR); | 
|---|
|  | 287 |  | 
|---|
|  | 288 | # ifdef FORTIFY | 
|---|
|  | 289 | Fortify_EnterScope(); | 
|---|
|  | 290 | #  endif | 
|---|
|  | 291 |  | 
|---|
|  | 292 | ProcessDir = (PROCESSDIR *)arg; | 
|---|
|  | 293 | if (ProcessDir && ProcessDir->pciParent && ProcessDir->pciParent->pszFileName && ProcessDir->hwndCnr) { | 
|---|
|  | 294 | thab = WinInitialize(0); | 
|---|
|  | 295 | if (thab) { | 
|---|
|  | 296 | hmq = WinCreateMsgQueue(thab, 0); | 
|---|
|  | 297 | if (hmq) { | 
|---|
|  | 298 | ProcessDirCount ++; | 
|---|
|  | 299 | IncrThreadUsage(); | 
|---|
|  | 300 | priority_normal(); | 
|---|
|  | 301 | ProcessDirectory(ProcessDir->hwndCnr, | 
|---|
|  | 302 | ProcessDir->pciParent, | 
|---|
|  | 303 | ProcessDir->szDirBase, | 
|---|
|  | 304 | ProcessDir->filestoo, | 
|---|
|  | 305 | ProcessDir->recurse, | 
|---|
|  | 306 | ProcessDir->partial, | 
|---|
|  | 307 | ProcessDir->stopflag, | 
|---|
|  | 308 | ProcessDir->dcd,                       // Optional | 
|---|
|  | 309 | ProcessDir->pulTotalFiles,     // Optional | 
|---|
|  | 310 | ProcessDir->pullTotalBytes);   // Optional | 
|---|
|  | 311 | ProcessDirCount --; | 
|---|
|  | 312 | WinDestroyMsgQueue(hmq); | 
|---|
|  | 313 | } | 
|---|
|  | 314 | DecrThreadUsage(); | 
|---|
|  | 315 | WinTerminate(thab); | 
|---|
|  | 316 | } | 
|---|
|  | 317 | free(ProcessDir); | 
|---|
|  | 318 | } // if ProcessDir | 
|---|
|  | 319 | # ifdef FORTIFY | 
|---|
|  | 320 | Fortify_LeaveScope(); | 
|---|
|  | 321 | #  endif | 
|---|
|  | 322 |  | 
|---|
|  | 323 | // _endthread();                      // 10 Dec 08 SHL | 
|---|
|  | 324 | } | 
|---|
|  | 325 |  | 
|---|
| [214] | 326 | static HPOINTER IDFile(PSZ p) | 
|---|
| [90] | 327 | { | 
|---|
| [2] | 328 | HPOINTER hptr; | 
|---|
| [551] | 329 | ULONG cmp; | 
|---|
| [572] | 330 | CHAR cmps[5]; | 
|---|
| [2] | 331 |  | 
|---|
| [551] | 332 | p = strrchr(p, '.'); | 
|---|
| [572] | 333 | if (p && !p[5]) { | 
|---|
| [214] | 334 | cmps[0] = '.'; | 
|---|
|  | 335 | cmps[1] = toupper(p[1]); | 
|---|
|  | 336 | cmps[2] = toupper(p[2]); | 
|---|
|  | 337 | cmps[3] = toupper(p[3]); | 
|---|
| [572] | 338 | cmps[4] = toupper(p[4]); | 
|---|
| [214] | 339 |  | 
|---|
| [551] | 340 | cmp = *(ULONG *) cmps; | 
|---|
| [214] | 341 |  | 
|---|
| [1398] | 342 | if (cmp == *(ULONG *) PCSZ_DOTEXE || cmp == *(ULONG *) PCSZ_DOTCMD || | 
|---|
|  | 343 | cmp == *(ULONG *) PCSZ_DOTBAT || cmp == *(ULONG *) PCSZ_DOTCOM || | 
|---|
|  | 344 | cmp == *(ULONG *) PCSZ_DOTBTM) | 
|---|
| [214] | 345 | hptr = hptrApp; | 
|---|
| [551] | 346 | else if (cmp == *(ULONG *) ".ZIP" || cmp == *(ULONG *) ".LZH" || | 
|---|
|  | 347 | cmp == *(ULONG *) ".ARJ" || cmp == *(ULONG *) ".ARC" || | 
|---|
| [552] | 348 | cmp == *(ULONG *) ".ZOO" || cmp == *(ULONG *) ".RAR" || | 
|---|
|  | 349 | cmp == *(ULONG *) ".TAR" || cmp == *(ULONG *) ".TGZ" || | 
|---|
| [1398] | 350 | cmp == *(ULONG *) ".GZ"  || cmp == *(ULONG *) ".Z"   || | 
|---|
| [552] | 351 | cmp == *(ULONG *) ".CAB" || cmp == *(ULONG *) ".BZ2") | 
|---|
| [214] | 352 | hptr = hptrArc; | 
|---|
| [1398] | 353 | else if (cmp == *(ULONG *) PCSZ_DOTBMP  || | 
|---|
|  | 354 | cmp == *(ULONG *) PCSZ_DOTICO  || | 
|---|
|  | 355 | cmp == *(ULONG *) PCSZ_DOTPTR  || | 
|---|
|  | 356 | cmp == *(ULONG *) PCSZ_DOTJPEG || | 
|---|
|  | 357 | cmp == *(ULONG *) PCSZ_DOTJPG  || | 
|---|
|  | 358 | cmp == *(ULONG *) ".GIF" || | 
|---|
| [551] | 359 | cmp == *(ULONG *) ".TIF" || cmp == *(ULONG *) ".PCX" || | 
|---|
| [552] | 360 | cmp == *(ULONG *) ".TGA" || cmp == *(ULONG *) ".XBM" || | 
|---|
|  | 361 | cmp == *(ULONG *) ".PNG" || cmp == *(ULONG *) ".PSD" || | 
|---|
|  | 362 | cmp == *(ULONG *) ".LGO" || cmp == *(ULONG *) ".EPS" || | 
|---|
|  | 363 | cmp == *(ULONG *) ".RLE" || cmp == *(ULONG *) ".RAS" || | 
|---|
|  | 364 | cmp == *(ULONG *) ".PLC" || cmp == *(ULONG *) ".MSP" || | 
|---|
|  | 365 | cmp == *(ULONG *) ".IFF" || cmp == *(ULONG *) ".FIT" || | 
|---|
|  | 366 | cmp == *(ULONG *) ".DCX" || cmp == *(ULONG *) ".MAC" || | 
|---|
|  | 367 | cmp == *(ULONG *) ".SFF" || cmp == *(ULONG *) ".SGI" || | 
|---|
|  | 368 | cmp == *(ULONG *) ".XWD" || cmp == *(ULONG *) ".XPM" || | 
|---|
|  | 369 | cmp == *(ULONG *) ".WPG" || cmp == *(ULONG *) ".CUR" || | 
|---|
|  | 370 | cmp == *(ULONG *) ".PNM" || cmp == *(ULONG *) ".PPM" || | 
|---|
|  | 371 | cmp == *(ULONG *) ".PGM" || cmp == *(ULONG *) ".PBM") | 
|---|
| [214] | 372 | hptr = hptrArt; | 
|---|
|  | 373 | else | 
|---|
| [551] | 374 | hptr = (HPOINTER) 0; | 
|---|
| [214] | 375 | } | 
|---|
|  | 376 | else | 
|---|
| [551] | 377 | hptr = (HPOINTER) 0; | 
|---|
| [214] | 378 |  | 
|---|
| [2] | 379 | return hptr; | 
|---|
|  | 380 | } | 
|---|
|  | 381 |  | 
|---|
| [214] | 382 | static BOOL IsDefaultIcon(HPOINTER hptr) | 
|---|
|  | 383 | { | 
|---|
|  | 384 | HPOINTER hptr2; | 
|---|
|  | 385 | HPOINTER hptr3; | 
|---|
|  | 386 | UINT u; | 
|---|
|  | 387 |  | 
|---|
|  | 388 | static HPOINTER hptrPMFile; | 
|---|
|  | 389 | static HPOINTER hptrWPSFile; | 
|---|
|  | 390 |  | 
|---|
| [551] | 391 | if (!hptrPMFile) { | 
|---|
|  | 392 | hptrPMFile = WinQuerySysPointer(HWND_DESKTOP, SPTR_FILE, FALSE); | 
|---|
| [214] | 393 | } | 
|---|
|  | 394 |  | 
|---|
|  | 395 | // try to guess WPS default file icon | 
|---|
| [551] | 396 | hptr2 = (HPOINTER) 0; | 
|---|
|  | 397 | for (u = 0; !hptrWPSFile && u < 10; u++) { | 
|---|
| [214] | 398 | char szFileName[CCHMAXPATH]; | 
|---|
|  | 399 | char *psz; | 
|---|
|  | 400 |  | 
|---|
| [1076] | 401 | if (pTmpDir) { | 
|---|
| [1069] | 402 | psz = pTmpDir; | 
|---|
| [214] | 403 | strcpy(szFileName, psz); | 
|---|
|  | 404 | psz = szFileName + strlen(szFileName) - 1; | 
|---|
| [551] | 405 | if (*psz != '\\') { | 
|---|
| [214] | 406 | psz++; | 
|---|
|  | 407 | *psz++ = '\\'; | 
|---|
|  | 408 | } | 
|---|
|  | 409 | } | 
|---|
|  | 410 | else | 
|---|
|  | 411 | psz = szFileName; | 
|---|
|  | 412 |  | 
|---|
| [551] | 413 | sprintf(psz, "%08x.%03x", rand() & 0xffffffff, rand() & 0xfff); | 
|---|
|  | 414 | if (IsFile(szFileName) != 1) { | 
|---|
|  | 415 | FILE *fp = fopen(szFileName, "w"); | 
|---|
|  | 416 |  | 
|---|
|  | 417 | if (fp) { | 
|---|
| [214] | 418 | fclose(fp); | 
|---|
|  | 419 | hptr3 = WinLoadFileIcon(szFileName, FALSE); | 
|---|
| [1402] | 420 | unlinkf(szFileName); | 
|---|
| [214] | 421 | if (!hptr2) | 
|---|
|  | 422 | hptr2 = hptr3; | 
|---|
| [551] | 423 | else if (hptr3 == hptr3) { | 
|---|
| [214] | 424 | hptrWPSFile = hptr3;          // Got same icon twice | 
|---|
|  | 425 | break; | 
|---|
|  | 426 | } | 
|---|
|  | 427 | } | 
|---|
|  | 428 | } | 
|---|
|  | 429 | DosSleep(rand() % 100); | 
|---|
|  | 430 |  | 
|---|
| [731] | 431 | } // for | 
|---|
| [214] | 432 |  | 
|---|
|  | 433 | return hptr == hptrPMFile || hptr == hptrWPSFile; | 
|---|
|  | 434 |  | 
|---|
| [731] | 435 | } // IsDefaultIcon | 
|---|
| [214] | 436 |  | 
|---|
| [731] | 437 | ULONGLONG FillInRecordFromFFB(HWND hwndCnr, | 
|---|
|  | 438 | PCNRITEM pci, | 
|---|
| [551] | 439 | const PSZ pszDirectory, | 
|---|
| [841] | 440 | const PFILEFINDBUF4L pffb, | 
|---|
| [731] | 441 | const BOOL partial, | 
|---|
| [737] | 442 | DIRCNRDATA *dcd) | 
|---|
| [31] | 443 | { | 
|---|
| [841] | 444 | // fill in a container record from a FILEFINDBUF4L structure | 
|---|
| [2] | 445 |  | 
|---|
| [551] | 446 | CHAR *p; | 
|---|
|  | 447 | HPOINTER hptr; | 
|---|
| [1326] | 448 | ULONG flags; | 
|---|
| [2] | 449 |  | 
|---|
|  | 450 | pci->hwndCnr = hwndCnr; | 
|---|
| [731] | 451 |  | 
|---|
|  | 452 | /* note that we cheat below, and accept the full pathname in pszDirectory | 
|---|
|  | 453 | if !*pffb->achName.  This speeds up and simplifies processing elsewhere | 
|---|
| [167] | 454 | (like in update.c) | 
|---|
| [551] | 455 | */ | 
|---|
| [763] | 456 | if (!*pffb->achName) { | 
|---|
| [773] | 457 | pci->pszFileName = xstrdup(pszDirectory, pszSrcFile, __LINE__); | 
|---|
| [1018] | 458 | //strcpy(pci->pszFileName, pszDirectory); | 
|---|
| [763] | 459 | } | 
|---|
| [731] | 460 | else { | 
|---|
|  | 461 | INT c = strlen(pszDirectory); | 
|---|
|  | 462 | INT c2 = pffb->cchName + 1; | 
|---|
|  | 463 | if (pszDirectory[c - 1] != '\\') | 
|---|
|  | 464 | c2++; | 
|---|
| [773] | 465 | pci->pszFileName = xmalloc(c + c2, pszSrcFile, __LINE__); | 
|---|
| [1078] | 466 | #   ifdef FORTIFY | 
|---|
|  | 467 | { | 
|---|
| [1154] | 468 | if (dcd->type != TREE_FRAME) | 
|---|
| [1078] | 469 | Fortify_ChangeScope(pci->pszFileName, -1); | 
|---|
| [1154] | 470 | else { | 
|---|
| [1078] | 471 | Fortify_SetOwner(pci->pszFileName, 1); | 
|---|
| [1154] | 472 | Fortify_SetScope(pci->pszFileName, 2); | 
|---|
|  | 473 | } | 
|---|
| [1078] | 474 | } | 
|---|
|  | 475 | #   endif | 
|---|
| [731] | 476 | memcpy(pci->pszFileName, pszDirectory, c + 1); | 
|---|
|  | 477 | p = pci->pszFileName + c - 1; | 
|---|
| [167] | 478 | if (*p != '\\') { | 
|---|
| [2] | 479 | p++; | 
|---|
|  | 480 | *p = '\\'; | 
|---|
|  | 481 | } | 
|---|
|  | 482 | p++; | 
|---|
| [551] | 483 | memcpy(p, pffb->achName, pffb->cchName + 1); | 
|---|
| [2] | 484 | } | 
|---|
| [1326] | 485 | flags = driveflags[toupper(*pci->pszFileName) - 'A']; | 
|---|
| [783] | 486 | // load the object's Subject, if required | 
|---|
| [1326] | 487 | // pci->pszSubject = NullStr; dubplicate see below 12-05-08 GKY | 
|---|
| [167] | 488 | if (pffb->cbList > 4L && | 
|---|
|  | 489 | dcd && fLoadSubject && | 
|---|
| [730] | 490 | (isalpha(*pci->pszFileName) && | 
|---|
| [1326] | 491 | !(flags & DRIVE_NOLOADSUBJS))) | 
|---|
| [731] | 492 | { | 
|---|
| [551] | 493 | APIRET rc; | 
|---|
|  | 494 | EAOP2 eaop; | 
|---|
| [2] | 495 | PGEA2LIST pgealist; | 
|---|
|  | 496 | PFEA2LIST pfealist; | 
|---|
| [551] | 497 | PGEA2 pgea; | 
|---|
|  | 498 | PFEA2 pfea; | 
|---|
|  | 499 | CHAR *value; | 
|---|
| [2] | 500 |  | 
|---|
| [551] | 501 | pgealist = xmallocz(sizeof(GEA2LIST) + 32, pszSrcFile, __LINE__); | 
|---|
| [359] | 502 | if (pgealist) { | 
|---|
| [2] | 503 | pgea = &pgealist->list[0]; | 
|---|
| [551] | 504 | strcpy(pgea->szName, SUBJECT); | 
|---|
| [2] | 505 | pgea->cbName = strlen(pgea->szName); | 
|---|
| [188] | 506 | pgea->oNextEntryOffset = 0; | 
|---|
| [2] | 507 | pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName); | 
|---|
| [551] | 508 | pfealist = xmallocz(1532, pszSrcFile, __LINE__); | 
|---|
| [359] | 509 | if (pfealist) { | 
|---|
| [214] | 510 | pfealist->cbList = 1024; | 
|---|
|  | 511 | eaop.fpGEA2List = pgealist; | 
|---|
|  | 512 | eaop.fpFEA2List = pfealist; | 
|---|
|  | 513 | eaop.oError = 0; | 
|---|
| [730] | 514 | rc = DosQueryPathInfo(pci->pszFileName, FIL_QUERYEASFROMLIST, | 
|---|
| [551] | 515 | (PVOID) & eaop, (ULONG) sizeof(EAOP2)); | 
|---|
| [214] | 516 | if (!rc) { | 
|---|
|  | 517 | pfea = &eaop.fpFEA2List->list[0]; | 
|---|
|  | 518 | value = pfea->szName + pfea->cbName + 1; | 
|---|
|  | 519 | value[pfea->cbValue] = 0; | 
|---|
| [551] | 520 | if (*(USHORT *) value == EAT_ASCII) | 
|---|
| [730] | 521 | pci->pszSubject = xstrdup(value + (sizeof(USHORT) * 2), pszSrcFile, __LINE__); | 
|---|
| [214] | 522 | } | 
|---|
| [1039] | 523 | free(pfealist); | 
|---|
| [2] | 524 | } | 
|---|
| [1039] | 525 | free(pgealist); | 
|---|
| [2] | 526 | } | 
|---|
|  | 527 | } | 
|---|
| [731] | 528 | if (!pci->pszSubject) | 
|---|
| [751] | 529 | pci->pszSubject = NullStr; | 
|---|
| [731] | 530 |  | 
|---|
| [783] | 531 | // load the object's longname | 
|---|
| [1063] | 532 | pci->pszLongName = NULL; | 
|---|
| [282] | 533 | if (fLoadLongnames && | 
|---|
|  | 534 | dcd && | 
|---|
|  | 535 | pffb->cbList > 4L && | 
|---|
| [730] | 536 | isalpha(*pci->pszFileName) && | 
|---|
| [1326] | 537 | ~flags & DRIVE_NOLONGNAMES && | 
|---|
|  | 538 | ~flags & DRIVE_NOLOADLONGS) | 
|---|
| [731] | 539 | { | 
|---|
| [551] | 540 | APIRET rc; | 
|---|
|  | 541 | EAOP2 eaop; | 
|---|
| [2] | 542 | PGEA2LIST pgealist; | 
|---|
|  | 543 | PFEA2LIST pfealist; | 
|---|
| [551] | 544 | PGEA2 pgea; | 
|---|
|  | 545 | PFEA2 pfea; | 
|---|
|  | 546 | CHAR *value; | 
|---|
| [2] | 547 |  | 
|---|
| [551] | 548 | pgealist = xmallocz(sizeof(GEA2LIST) + 32, pszSrcFile, __LINE__); | 
|---|
| [359] | 549 | if (pgealist) { | 
|---|
| [2] | 550 | pgea = &pgealist->list[0]; | 
|---|
| [551] | 551 | strcpy(pgea->szName, LONGNAME); | 
|---|
| [2] | 552 | pgea->cbName = strlen(pgea->szName); | 
|---|
| [188] | 553 | pgea->oNextEntryOffset = 0; | 
|---|
| [2] | 554 | pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName); | 
|---|
| [551] | 555 | pfealist = xmallocz(1532, pszSrcFile, __LINE__); | 
|---|
| [167] | 556 | if (pfealist) { | 
|---|
| [214] | 557 | pfealist->cbList = 1024; | 
|---|
|  | 558 | eaop.fpGEA2List = pgealist; | 
|---|
|  | 559 | eaop.fpFEA2List = pfealist; | 
|---|
|  | 560 | eaop.oError = 0; | 
|---|
| [730] | 561 | rc = DosQueryPathInfo(pci->pszFileName, FIL_QUERYEASFROMLIST, | 
|---|
| [551] | 562 | (PVOID) & eaop, (ULONG) sizeof(EAOP2)); | 
|---|
|  | 563 | if (!rc) { | 
|---|
| [214] | 564 | pfea = &eaop.fpFEA2List->list[0]; | 
|---|
|  | 565 | value = pfea->szName + pfea->cbName + 1; | 
|---|
|  | 566 | value[pfea->cbValue] = 0; | 
|---|
| [1078] | 567 | if (*(USHORT *) value == EAT_ASCII) { | 
|---|
| [762] | 568 | pci->pszLongName = xstrdup(value + (sizeof(USHORT) * 2), pszSrcFile, __LINE__); | 
|---|
| [1078] | 569 | #           ifdef FORTIFY | 
|---|
| [1154] | 570 | { | 
|---|
|  | 571 | unsigned tid = GetTidForWindow(hwndCnr); | 
|---|
|  | 572 | if (tid == 1) | 
|---|
|  | 573 | Fortify_ChangeScope(pci->pszLongName, -1); | 
|---|
|  | 574 | else | 
|---|
|  | 575 | Fortify_SetOwner(pci->pszLongName, 1); | 
|---|
|  | 576 | } | 
|---|
| [1078] | 577 | #           endif | 
|---|
|  | 578 | } | 
|---|
| [214] | 579 | } | 
|---|
| [1039] | 580 | free(pfealist); | 
|---|
| [2] | 581 | } | 
|---|
| [1039] | 582 | free(pgealist); | 
|---|
| [2] | 583 | } | 
|---|
|  | 584 | } | 
|---|
| [762] | 585 | if (!pci->pszLongName) | 
|---|
|  | 586 | pci->pszLongName = NullStr; | 
|---|
| [731] | 587 |  | 
|---|
| [783] | 588 | // do anything required to case of filename | 
|---|
| [167] | 589 | if (fForceUpper) | 
|---|
| [730] | 590 | strupr(pci->pszFileName); | 
|---|
| [167] | 591 | else if (fForceLower) | 
|---|
| [730] | 592 | strlwr(pci->pszFileName); | 
|---|
| [2] | 593 |  | 
|---|
| [783] | 594 | // get an icon to use with it | 
|---|
| [551] | 595 | if (pffb->attrFile & FILE_DIRECTORY) { | 
|---|
| [214] | 596 | // is directory | 
|---|
|  | 597 | if (fNoIconsDirs || | 
|---|
| [1326] | 598 | (flags & DRIVE_NOLOADICONS) || | 
|---|
| [730] | 599 | !isalpha(*pci->pszFileName)) { | 
|---|
| [551] | 600 | hptr = (HPOINTER) 0; | 
|---|
| [214] | 601 | } | 
|---|
|  | 602 | else | 
|---|
| [730] | 603 | hptr = WinLoadFileIcon(pci->pszFileName, FALSE); | 
|---|
| [2] | 604 | } | 
|---|
| [551] | 605 | else { | 
|---|
| [214] | 606 | // is file | 
|---|
|  | 607 | if (fNoIconsFiles || | 
|---|
| [1326] | 608 | (flags & DRIVE_NOLOADICONS) || | 
|---|
| [730] | 609 | !isalpha(*pci->pszFileName)) { | 
|---|
| [551] | 610 | hptr = (HPOINTER) 0; | 
|---|
| [167] | 611 | } | 
|---|
| [42] | 612 | else | 
|---|
| [730] | 613 | hptr = WinLoadFileIcon(pci->pszFileName, FALSE); | 
|---|
| [167] | 614 |  | 
|---|
| [214] | 615 | if (!hptr || IsDefaultIcon(hptr)) | 
|---|
| [730] | 616 | hptr = IDFile(pci->pszFileName); | 
|---|
| [2] | 617 | } | 
|---|
| [214] | 618 |  | 
|---|
| [551] | 619 | if (!hptr) { | 
|---|
| [214] | 620 | hptr = pffb->attrFile & FILE_DIRECTORY ? | 
|---|
| [1335] | 621 | hptrDir : pffb->attrFile & FILE_SYSTEM ? | 
|---|
|  | 622 | hptrSystem : pffb->attrFile & FILE_HIDDEN ? | 
|---|
|  | 623 | hptrHidden : pffb->attrFile & FILE_READONLY ? | 
|---|
| [1326] | 624 | hptrReadonly : hptrFile; | 
|---|
| [167] | 625 | } | 
|---|
| [2] | 626 |  | 
|---|
| [737] | 627 | // Tell container what part of pathname to display | 
|---|
| [551] | 628 | if (partial) { | 
|---|
| [730] | 629 | p = strrchr(pci->pszFileName, '\\'); | 
|---|
| [551] | 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 | (!(pffb->attrFile & FILE_DIRECTORY) || !*(p + 1))) { | 
|---|
| [2] | 639 | p++; | 
|---|
| [167] | 640 | } | 
|---|
|  | 641 | if (!*p) | 
|---|
| [730] | 642 | p = pci->pszFileName; | 
|---|
| [2] | 643 | } | 
|---|
|  | 644 | else | 
|---|
| [730] | 645 | p = pci->pszFileName; | 
|---|
| [737] | 646 | pci->pszDisplayName = p; | 
|---|
|  | 647 |  | 
|---|
| [856] | 648 | //comma format the file size for large file support | 
|---|
| [859] | 649 | { | 
|---|
| [1078] | 650 | CHAR szBuf[30]; | 
|---|
| [856] | 651 | CommaFmtULL(szBuf, sizeof(szBuf), pffb->cbFile, ' '); | 
|---|
|  | 652 | pci->pszFmtFileSize = xstrdup(szBuf, pszSrcFile, __LINE__); | 
|---|
| [1078] | 653 | #   ifdef FORTIFY | 
|---|
|  | 654 | { | 
|---|
|  | 655 | unsigned tid = GetTidForWindow(hwndCnr); | 
|---|
|  | 656 | if (tid == 1) | 
|---|
|  | 657 | Fortify_ChangeScope(pci->pszFmtFileSize, -1); | 
|---|
|  | 658 | else | 
|---|
|  | 659 | Fortify_SetOwner(pci->pszFmtFileSize, 1); | 
|---|
|  | 660 | } | 
|---|
|  | 661 | #   endif | 
|---|
| [856] | 662 | } | 
|---|
|  | 663 |  | 
|---|
| [783] | 664 | // now fill the darned thing in... | 
|---|
| [551] | 665 | pci->date.day = pffb->fdateLastWrite.day; | 
|---|
|  | 666 | pci->date.month = pffb->fdateLastWrite.month; | 
|---|
|  | 667 | pci->date.year = pffb->fdateLastWrite.year + 1980; | 
|---|
|  | 668 | pci->time.seconds = pffb->ftimeLastWrite.twosecs * 2; | 
|---|
|  | 669 | pci->time.minutes = pffb->ftimeLastWrite.minutes; | 
|---|
|  | 670 | pci->time.hours = pffb->ftimeLastWrite.hours; | 
|---|
|  | 671 | pci->ladate.day = pffb->fdateLastAccess.day; | 
|---|
|  | 672 | pci->ladate.month = pffb->fdateLastAccess.month; | 
|---|
|  | 673 | pci->ladate.year = pffb->fdateLastAccess.year + 1980; | 
|---|
| [2] | 674 | pci->latime.seconds = pffb->ftimeLastAccess.twosecs * 2; | 
|---|
|  | 675 | pci->latime.minutes = pffb->ftimeLastAccess.minutes; | 
|---|
| [551] | 676 | pci->latime.hours = pffb->ftimeLastAccess.hours; | 
|---|
|  | 677 | pci->crdate.day = pffb->fdateCreation.day; | 
|---|
|  | 678 | pci->crdate.month = pffb->fdateCreation.month; | 
|---|
|  | 679 | pci->crdate.year = pffb->fdateCreation.year + 1980; | 
|---|
| [2] | 680 | pci->crtime.seconds = pffb->ftimeCreation.twosecs * 2; | 
|---|
|  | 681 | pci->crtime.minutes = pffb->ftimeCreation.minutes; | 
|---|
| [551] | 682 | pci->crtime.hours = pffb->ftimeCreation.hours; | 
|---|
|  | 683 | pci->easize = CBLIST_TO_EASIZE(pffb->cbList); | 
|---|
|  | 684 | pci->cbFile = pffb->cbFile; | 
|---|
|  | 685 | pci->attrFile = pffb->attrFile; | 
|---|
| [751] | 686 | pci->pszDispAttr = FileAttrToString(pci->attrFile); | 
|---|
| [739] | 687 | pci->rc.pszIcon = pci->pszDisplayName; | 
|---|
| [551] | 688 | pci->rc.hptrIcon = hptr; | 
|---|
| [2] | 689 |  | 
|---|
| [783] | 690 | // check to see if record should be visible | 
|---|
| [167] | 691 | if (dcd && (*dcd->mask.szMask || dcd->mask.antiattr || | 
|---|
| [551] | 692 | ((dcd->mask.attrFile & | 
|---|
|  | 693 | (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) | 
|---|
|  | 694 | != | 
|---|
|  | 695 | (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)))) | 
|---|
| [167] | 696 | { | 
|---|
| [551] | 697 | if (*dcd->mask.szMask || dcd->mask.antiattr) { | 
|---|
|  | 698 | if (!Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) | 
|---|
| [214] | 699 | pci->rc.flRecordAttr |= CRA_FILTERED; | 
|---|
| [2] | 700 | } | 
|---|
| [551] | 701 | else if ((!(dcd->mask.attrFile & FILE_HIDDEN) && | 
|---|
|  | 702 | (pci->attrFile & FILE_HIDDEN)) || | 
|---|
|  | 703 | (!(dcd->mask.attrFile & FILE_SYSTEM) && | 
|---|
|  | 704 | (pci->attrFile & FILE_SYSTEM)) || | 
|---|
|  | 705 | (!(dcd->mask.attrFile & FILE_READONLY) && | 
|---|
|  | 706 | (pci->attrFile & FILE_READONLY)) || | 
|---|
|  | 707 | (!(dcd->mask.attrFile & FILE_ARCHIVED) && | 
|---|
|  | 708 | (pci->attrFile & FILE_ARCHIVED))) { | 
|---|
| [2] | 709 | pci->rc.flRecordAttr |= CRA_FILTERED; | 
|---|
| [167] | 710 | } | 
|---|
| [2] | 711 | } | 
|---|
|  | 712 |  | 
|---|
|  | 713 | return pffb->cbFile + pci->easize; | 
|---|
|  | 714 |  | 
|---|
| [731] | 715 | } // FillInRecordFromFFB | 
|---|
| [2] | 716 |  | 
|---|
| [1154] | 717 | ULONGLONG FillInRecordFromFSA(HWND hwndCnr, | 
|---|
|  | 718 | PCNRITEM pci, | 
|---|
| [907] | 719 | const PSZ pszFileName, | 
|---|
|  | 720 | const PFILESTATUS4L pfsa4, | 
|---|
| [1154] | 721 | const BOOL partial, | 
|---|
|  | 722 | DIRCNRDATA *dcd)  // Optional | 
|---|
| [31] | 723 | { | 
|---|
| [551] | 724 | HPOINTER hptr; | 
|---|
| [731] | 725 | CHAR *p; | 
|---|
| [1326] | 726 | ULONG flags; | 
|---|
| [2] | 727 |  | 
|---|
| [841] | 728 | // fill in a container record from a FILESTATUS4L structure | 
|---|
| [2] | 729 |  | 
|---|
|  | 730 | pci->hwndCnr = hwndCnr; | 
|---|
| [773] | 731 | pci->pszFileName = xstrdup(pszFileName, pszSrcFile, __LINE__); | 
|---|
| [1099] | 732 | //strcpy(pci->pszFileName, pszFileName); | 
|---|
| [1326] | 733 | flags = driveflags[toupper(*pci->pszFileName) - 'A']; | 
|---|
| [783] | 734 | // load the object's Subject, if required | 
|---|
| [1326] | 735 | //pci->pszSubject = NullStr; | 
|---|
| [841] | 736 | if (pfsa4->cbList > 4 && | 
|---|
| [167] | 737 | dcd && | 
|---|
|  | 738 | fLoadSubject && | 
|---|
| [730] | 739 | (!isalpha(*pci->pszFileName) || | 
|---|
| [1326] | 740 | !(flags & DRIVE_NOLOADSUBJS))) | 
|---|
| [731] | 741 | { | 
|---|
| [551] | 742 | APIRET rc; | 
|---|
|  | 743 | EAOP2 eaop; | 
|---|
| [2] | 744 | PGEA2LIST pgealist; | 
|---|
|  | 745 | PFEA2LIST pfealist; | 
|---|
| [551] | 746 | PGEA2 pgea; | 
|---|
|  | 747 | PFEA2 pfea; | 
|---|
|  | 748 | CHAR *value; | 
|---|
| [2] | 749 |  | 
|---|
| [551] | 750 | pgealist = xmallocz(sizeof(GEA2LIST) + 32, pszSrcFile, __LINE__); | 
|---|
| [167] | 751 | if (pgealist) { | 
|---|
| [2] | 752 | pgea = &pgealist->list[0]; | 
|---|
| [551] | 753 | strcpy(pgea->szName, SUBJECT); | 
|---|
| [2] | 754 | pgea->cbName = strlen(pgea->szName); | 
|---|
| [188] | 755 | pgea->oNextEntryOffset = 0; | 
|---|
| [2] | 756 | pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName); | 
|---|
| [551] | 757 | pfealist = xmallocz(1532, pszSrcFile, __LINE__); | 
|---|
| [167] | 758 | if (pfealist) { | 
|---|
| [214] | 759 | pfealist->cbList = 1024; | 
|---|
|  | 760 | eaop.fpGEA2List = pgealist; | 
|---|
|  | 761 | eaop.fpFEA2List = pfealist; | 
|---|
|  | 762 | eaop.oError = 0; | 
|---|
| [730] | 763 | rc = DosQueryPathInfo(pci->pszFileName, FIL_QUERYEASFROMLIST, | 
|---|
| [551] | 764 | (PVOID) & eaop, (ULONG) sizeof(EAOP2)); | 
|---|
| [214] | 765 | if (!rc) { | 
|---|
|  | 766 | pfea = &eaop.fpFEA2List->list[0]; | 
|---|
|  | 767 | value = pfea->szName + pfea->cbName + 1; | 
|---|
|  | 768 | value[pfea->cbValue] = 0; | 
|---|
| [551] | 769 | if (*(USHORT *) value == EAT_ASCII) | 
|---|
| [731] | 770 | pci->pszSubject = xstrdup(value + (sizeof(USHORT) * 2), pszSrcFile, __LINE__); | 
|---|
| [214] | 771 | } | 
|---|
| [1039] | 772 | free(pfealist); | 
|---|
| [2] | 773 | } | 
|---|
| [1039] | 774 | free(pgealist); | 
|---|
| [2] | 775 | } | 
|---|
|  | 776 | } | 
|---|
| [731] | 777 | if (!pci->pszSubject) | 
|---|
| [751] | 778 | pci->pszSubject = NullStr; | 
|---|
| [731] | 779 |  | 
|---|
| [1063] | 780 | pci->pszLongName = NULL; | 
|---|
| [282] | 781 | if (fLoadLongnames && | 
|---|
| [167] | 782 | dcd && | 
|---|
| [282] | 783 | pfsa4->cbList > 4L && | 
|---|
| [730] | 784 | isalpha(*pci->pszFileName) && | 
|---|
| [1326] | 785 | ~flags & DRIVE_NOLONGNAMES && | 
|---|
|  | 786 | ~flags & DRIVE_NOLOADLONGS) | 
|---|
| [731] | 787 | { | 
|---|
| [551] | 788 | APIRET rc; | 
|---|
|  | 789 | EAOP2 eaop; | 
|---|
| [2] | 790 | PGEA2LIST pgealist; | 
|---|
|  | 791 | PFEA2LIST pfealist; | 
|---|
| [551] | 792 | PGEA2 pgea; | 
|---|
|  | 793 | PFEA2 pfea; | 
|---|
|  | 794 | CHAR *value; | 
|---|
| [2] | 795 |  | 
|---|
| [551] | 796 | pgealist = xmallocz(sizeof(GEA2LIST) + 32, pszSrcFile, __LINE__); | 
|---|
| [167] | 797 | if (pgealist) { | 
|---|
| [2] | 798 | pgea = &pgealist->list[0]; | 
|---|
| [551] | 799 | strcpy(pgea->szName, LONGNAME); | 
|---|
| [2] | 800 | pgea->cbName = strlen(pgea->szName); | 
|---|
| [188] | 801 | pgea->oNextEntryOffset = 0; | 
|---|
| [2] | 802 | pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName); | 
|---|
| [551] | 803 | pfealist = xmallocz(1532, pszSrcFile, __LINE__); | 
|---|
| [167] | 804 | if (pfealist) { | 
|---|
| [214] | 805 | pfealist->cbList = 1024; | 
|---|
|  | 806 | eaop.fpGEA2List = pgealist; | 
|---|
|  | 807 | eaop.fpFEA2List = pfealist; | 
|---|
|  | 808 | eaop.oError = 0; | 
|---|
| [730] | 809 | rc = DosQueryPathInfo(pci->pszFileName, FIL_QUERYEASFROMLIST, | 
|---|
| [551] | 810 | (PVOID) & eaop, (ULONG) sizeof(EAOP2)); | 
|---|
| [214] | 811 | if (!rc) { | 
|---|
|  | 812 | pfea = &eaop.fpFEA2List->list[0]; | 
|---|
| [731] | 813 | value = pfea->szName + pfea->cbName + 1;      // Point at EA value | 
|---|
| [1174] | 814 | value[pfea->cbValue] = 0;     // Terminate | 
|---|
| [731] | 815 | if (*(USHORT *) value == EAT_ASCII) { | 
|---|
| [1174] | 816 | p = value + sizeof(USHORT) * 2;     // Point at value string | 
|---|
| [762] | 817 | pci->pszLongName = xstrdup(p, pszSrcFile, __LINE__); | 
|---|
| [731] | 818 | } | 
|---|
| [214] | 819 | } | 
|---|
| [1039] | 820 | free(pfealist); | 
|---|
| [2] | 821 | } | 
|---|
| [1039] | 822 | free(pgealist); | 
|---|
| [2] | 823 | } | 
|---|
|  | 824 | } | 
|---|
| [762] | 825 | if (!pci->pszLongName) | 
|---|
|  | 826 | pci->pszLongName = NullStr; | 
|---|
| [731] | 827 |  | 
|---|
| [167] | 828 | if (fForceUpper) | 
|---|
| [730] | 829 | strupr(pci->pszFileName); | 
|---|
| [167] | 830 | else if (fForceLower) | 
|---|
| [730] | 831 | strlwr(pci->pszFileName); | 
|---|
| [2] | 832 |  | 
|---|
| [551] | 833 | if (pfsa4->attrFile & FILE_DIRECTORY) { | 
|---|
| [214] | 834 | if (fNoIconsDirs || | 
|---|
| [1326] | 835 | (flags & DRIVE_NOLOADICONS) || | 
|---|
| [730] | 836 | !isalpha(*pci->pszFileName)) { | 
|---|
| [551] | 837 | hptr = (HPOINTER) 0; | 
|---|
| [214] | 838 | } | 
|---|
|  | 839 | else | 
|---|
| [730] | 840 | hptr = WinLoadFileIcon(pci->pszFileName, FALSE); | 
|---|
| [2] | 841 | } | 
|---|
| [551] | 842 | else { | 
|---|
| [214] | 843 | if (fNoIconsFiles || | 
|---|
| [1326] | 844 | (flags & DRIVE_NOLOADICONS) || | 
|---|
| [730] | 845 | !isalpha(*pci->pszFileName)) { | 
|---|
|  | 846 | hptr = IDFile(pci->pszFileName); | 
|---|
| [2] | 847 | } | 
|---|
| [214] | 848 | else | 
|---|
| [730] | 849 | hptr = WinLoadFileIcon(pci->pszFileName, FALSE); | 
|---|
| [2] | 850 | } | 
|---|
| [551] | 851 | if (!hptr) { | 
|---|
| [214] | 852 | hptr = pfsa4->attrFile & FILE_DIRECTORY ? | 
|---|
| [551] | 853 | hptrDir : | 
|---|
|  | 854 | pfsa4->attrFile & FILE_SYSTEM ? | 
|---|
|  | 855 | hptrSystem : | 
|---|
|  | 856 | pfsa4->attrFile & FILE_HIDDEN ? | 
|---|
|  | 857 | hptrHidden : pfsa4->attrFile & FILE_READONLY ? hptrReadonly : hptrFile; | 
|---|
| [214] | 858 | } | 
|---|
| [2] | 859 |  | 
|---|
| [737] | 860 | // Tell container what part of pathname to display | 
|---|
| [551] | 861 | if (partial) { | 
|---|
| [730] | 862 | p = strrchr(pci->pszFileName, '\\'); | 
|---|
| [167] | 863 | if (!p) { | 
|---|
| [730] | 864 | p = strrchr(pci->pszFileName, ':'); | 
|---|
| [167] | 865 | if (!p) | 
|---|
| [730] | 866 | p = pci->pszFileName; | 
|---|
| [2] | 867 | else | 
|---|
| [214] | 868 | p++; | 
|---|
| [2] | 869 | } | 
|---|
| [167] | 870 | else if ((dcd && dcd->type == TREE_FRAME) || | 
|---|
| [551] | 871 | !(pfsa4->attrFile & FILE_DIRECTORY) || !*(p + 1)) | 
|---|
| [2] | 872 | p++; | 
|---|
| [167] | 873 | if (!*p) | 
|---|
| [730] | 874 | p = pci->pszFileName; | 
|---|
| [2] | 875 | } | 
|---|
|  | 876 | else | 
|---|
| [730] | 877 | p = pci->pszFileName; | 
|---|
| [737] | 878 | pci->pszDisplayName = p; | 
|---|
|  | 879 |  | 
|---|
| [856] | 880 | //comma format the file size for large file support | 
|---|
| [859] | 881 | { | 
|---|
| [1154] | 882 | CHAR szBuf[30]; | 
|---|
| [856] | 883 | CommaFmtULL(szBuf, sizeof(szBuf), pfsa4->cbFile, ' '); | 
|---|
|  | 884 | pci->pszFmtFileSize = xstrdup(szBuf, pszSrcFile, __LINE__); | 
|---|
| [1154] | 885 | #   ifdef FORTIFY | 
|---|
|  | 886 | { | 
|---|
|  | 887 | if (dcd && dcd->type == TREE_FRAME) { | 
|---|
|  | 888 | // Will be freed in TreeCnrWndProc WM_DESTROY | 
|---|
|  | 889 | // Fortify_SetOwner(pci->pszFmtFileSize, 1); | 
|---|
|  | 890 | Fortify_SetScope(pci->pszFmtFileSize, 2); | 
|---|
|  | 891 | } | 
|---|
|  | 892 | } | 
|---|
|  | 893 | #   endif | 
|---|
| [856] | 894 | } | 
|---|
| [551] | 895 | pci->date.day = pfsa4->fdateLastWrite.day; | 
|---|
|  | 896 | pci->date.month = pfsa4->fdateLastWrite.month; | 
|---|
|  | 897 | pci->date.year = pfsa4->fdateLastWrite.year + 1980; | 
|---|
|  | 898 | pci->time.seconds = pfsa4->ftimeLastWrite.twosecs * 2; | 
|---|
|  | 899 | pci->time.minutes = pfsa4->ftimeLastWrite.minutes; | 
|---|
|  | 900 | pci->time.hours = pfsa4->ftimeLastWrite.hours; | 
|---|
|  | 901 | pci->ladate.day = pfsa4->fdateLastAccess.day; | 
|---|
|  | 902 | pci->ladate.month = pfsa4->fdateLastAccess.month; | 
|---|
|  | 903 | pci->ladate.year = pfsa4->fdateLastAccess.year + 1980; | 
|---|
| [2] | 904 | pci->latime.seconds = pfsa4->ftimeLastAccess.twosecs * 2; | 
|---|
|  | 905 | pci->latime.minutes = pfsa4->ftimeLastAccess.minutes; | 
|---|
| [551] | 906 | pci->latime.hours = pfsa4->ftimeLastAccess.hours; | 
|---|
|  | 907 | pci->crdate.day = pfsa4->fdateCreation.day; | 
|---|
|  | 908 | pci->crdate.month = pfsa4->fdateCreation.month; | 
|---|
|  | 909 | pci->crdate.year = pfsa4->fdateCreation.year + 1980; | 
|---|
| [2] | 910 | pci->crtime.seconds = pfsa4->ftimeCreation.twosecs * 2; | 
|---|
|  | 911 | pci->crtime.minutes = pfsa4->ftimeCreation.minutes; | 
|---|
| [551] | 912 | pci->crtime.hours = pfsa4->ftimeCreation.hours; | 
|---|
|  | 913 | pci->easize = CBLIST_TO_EASIZE(pfsa4->cbList); | 
|---|
|  | 914 | pci->cbFile = pfsa4->cbFile; | 
|---|
|  | 915 | pci->attrFile = pfsa4->attrFile; | 
|---|
| [751] | 916 | pci->pszDispAttr = FileAttrToString(pci->attrFile); | 
|---|
| [739] | 917 | pci->rc.pszIcon = pci->pszDisplayName; | 
|---|
| [551] | 918 | pci->rc.hptrIcon = hptr; | 
|---|
| [2] | 919 |  | 
|---|
| [167] | 920 | if (dcd && | 
|---|
|  | 921 | (*dcd->mask.szMask || dcd->mask.antiattr || | 
|---|
|  | 922 | ((dcd->mask.attrFile & | 
|---|
| [551] | 923 | (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) != | 
|---|
|  | 924 | (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)))) { | 
|---|
|  | 925 | if (*dcd->mask.szMask || dcd->mask.antiattr) { | 
|---|
|  | 926 | if (!Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) | 
|---|
| [214] | 927 | pci->rc.flRecordAttr |= CRA_FILTERED; | 
|---|
| [2] | 928 | } | 
|---|
| [167] | 929 | else if ((!(dcd->mask.attrFile & FILE_HIDDEN) && | 
|---|
| [214] | 930 | (pci->attrFile & FILE_HIDDEN)) || | 
|---|
|  | 931 | (!(dcd->mask.attrFile & FILE_SYSTEM) && | 
|---|
|  | 932 | (pci->attrFile & FILE_SYSTEM)) || | 
|---|
|  | 933 | (!(dcd->mask.attrFile & FILE_READONLY) && | 
|---|
|  | 934 | (pci->attrFile & FILE_READONLY)) || | 
|---|
|  | 935 | (!(dcd->mask.attrFile & FILE_ARCHIVED) && | 
|---|
|  | 936 | (pci->attrFile & FILE_ARCHIVED))) | 
|---|
| [2] | 937 | pci->rc.flRecordAttr |= CRA_FILTERED; | 
|---|
|  | 938 | } | 
|---|
|  | 939 |  | 
|---|
|  | 940 | return pfsa4->cbFile + pci->easize; | 
|---|
|  | 941 |  | 
|---|
| [731] | 942 | } // FillInRecordFromFSA | 
|---|
| [2] | 943 |  | 
|---|
| [737] | 944 | VOID ProcessDirectory(const HWND hwndCnr, | 
|---|
|  | 945 | const PCNRITEM pciParent, | 
|---|
|  | 946 | const CHAR *szDirBase, | 
|---|
|  | 947 | const BOOL filestoo, | 
|---|
|  | 948 | const BOOL recurse, | 
|---|
|  | 949 | const BOOL partial, | 
|---|
|  | 950 | CHAR *stopflag, | 
|---|
|  | 951 | DIRCNRDATA *dcd,  // Optional | 
|---|
|  | 952 | ULONG *pulTotalFiles,     // Optional | 
|---|
| [167] | 953 | PULONGLONG pullTotalBytes)        // Optional | 
|---|
| [31] | 954 | { | 
|---|
| [2] | 955 | /* put all the directories (and files if filestoo is TRUE) from a | 
|---|
|  | 956 | * directory into the container.  recurse through subdirectories if | 
|---|
|  | 957 | * recurse is TRUE. | 
|---|
|  | 958 | */ | 
|---|
|  | 959 |  | 
|---|
| [551] | 960 | PSZ pszFileSpec; | 
|---|
|  | 961 | INT t; | 
|---|
| [841] | 962 | PFILEFINDBUF4L paffbFound; | 
|---|
|  | 963 | PFILEFINDBUF4L *papffbSelected; | 
|---|
|  | 964 | PFILEFINDBUF4L pffbFile; | 
|---|
|  | 965 | PFILEFINDBUF4L paffbTotal = NULL; | 
|---|
|  | 966 | PFILEFINDBUF4L paffbTemp; | 
|---|
| [551] | 967 | HDIR hdir = HDIR_CREATE; | 
|---|
| [783] | 968 | ULONG ulFindCnt; | 
|---|
|  | 969 | ULONG ulFindMax; | 
|---|
|  | 970 | ULONG ulSelCnt; | 
|---|
| [551] | 971 | ULONG ulTotal = 0; | 
|---|
|  | 972 | ULONGLONG ullBytes; | 
|---|
|  | 973 | ULONGLONG ullTotalBytes; | 
|---|
|  | 974 | ULONG ulReturnFiles = 0; | 
|---|
|  | 975 | ULONGLONG ullReturnBytes = 0; | 
|---|
|  | 976 | PCH pchEndPath; | 
|---|
|  | 977 | APIRET rc; | 
|---|
|  | 978 | PCNRITEM pci; | 
|---|
|  | 979 | PCNRITEM pciFirst; | 
|---|
|  | 980 | RECORDINSERT ri; | 
|---|
|  | 981 | BOOL ok = TRUE; | 
|---|
| [783] | 982 | ULONG ulBufBytes; | 
|---|
|  | 983 | ULONG x; | 
|---|
| [2] | 984 |  | 
|---|
| [551] | 985 | if (isalpha(*szDirBase) && szDirBase[1] == ':' && szDirBase[2] == '\\') { | 
|---|
| [167] | 986 | if ((driveflags[toupper(*szDirBase) - 'A'] & DRIVE_REMOTE) && fRemoteBug) | 
|---|
| [1174] | 987 | ulFindMax = 1;                    // file system gets confused | 
|---|
| [167] | 988 | else if (driveflags[toupper(*szDirBase) - 'A'] & DRIVE_ZIPSTREAM) | 
|---|
| [783] | 989 | ulFindMax = min(FilesToGet, 225); // anything more is wasted | 
|---|
| [2] | 990 | else | 
|---|
| [783] | 991 | ulFindMax = FilesToGet;           // full-out | 
|---|
| [2] | 992 | } | 
|---|
| [924] | 993 | else | 
|---|
| [783] | 994 | ulFindMax = FilesToGet; | 
|---|
| [924] | 995 |  | 
|---|
| [167] | 996 | if (OS2ver[0] == 20 && OS2ver[1] < 30) | 
|---|
| [841] | 997 | ulFindMax = min(ulFindMax, (65535 / sizeof(FILEFINDBUF4L))); | 
|---|
| [2] | 998 |  | 
|---|
| [841] | 999 | ulBufBytes = ulFindMax * sizeof(FILEFINDBUF4L); | 
|---|
| [783] | 1000 |  | 
|---|
| [551] | 1001 | pszFileSpec = xmalloc(CCHMAXPATH + 2, pszSrcFile, __LINE__); | 
|---|
| [783] | 1002 | paffbFound = xmalloc(ulBufBytes, pszSrcFile, __LINE__); | 
|---|
| [841] | 1003 | papffbSelected = xmalloc(sizeof(PFILEFINDBUF4L) * ulFindMax, pszSrcFile, __LINE__); | 
|---|
| [783] | 1004 |  | 
|---|
| [167] | 1005 | if (paffbFound && papffbSelected && pszFileSpec) { | 
|---|
| [2] | 1006 | t = strlen(szDirBase); | 
|---|
| [551] | 1007 | memcpy(pszFileSpec, szDirBase, t + 1); | 
|---|
| [42] | 1008 | pchEndPath = pszFileSpec + t; | 
|---|
| [167] | 1009 | if (*(pchEndPath - 1) != '\\') { | 
|---|
| [551] | 1010 | memcpy(pchEndPath, "\\", 2); | 
|---|
| [2] | 1011 | pchEndPath++; | 
|---|
|  | 1012 | } | 
|---|
| [551] | 1013 | memcpy(pchEndPath, "*", 2); | 
|---|
| [2] | 1014 | DosError(FERR_DISABLEHARDERR); | 
|---|
| [783] | 1015 | ulFindCnt = ulFindMax; | 
|---|
| [838] | 1016 | rc = xDosFindFirst(pszFileSpec, | 
|---|
|  | 1017 | &hdir, | 
|---|
|  | 1018 | FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | | 
|---|
|  | 1019 | FILE_SYSTEM | FILE_HIDDEN | | 
|---|
|  | 1020 | (filestoo ? FILE_DIRECTORY : MUST_HAVE_DIRECTORY), | 
|---|
|  | 1021 | paffbFound, | 
|---|
|  | 1022 | ulBufBytes, | 
|---|
|  | 1023 | &ulFindCnt, | 
|---|
| [841] | 1024 | FIL_QUERYEASIZEL); | 
|---|
| [2] | 1025 | priority_normal(); | 
|---|
| [924] | 1026 | *pchEndPath = 0;                    // Chop off wildcard | 
|---|
| [551] | 1027 | if (!rc) { | 
|---|
| [783] | 1028 | do { | 
|---|
| [214] | 1029 | /* | 
|---|
|  | 1030 | * remove . and .. from list if present | 
|---|
|  | 1031 | * also counter file system bugs that sometimes | 
|---|
|  | 1032 | * allows normal files to slip through when | 
|---|
|  | 1033 | * only directories should appear (only a few | 
|---|
|  | 1034 | * network file systems exhibit such a problem). | 
|---|
|  | 1035 | */ | 
|---|
| [2] | 1036 |  | 
|---|
| [214] | 1037 | if (stopflag && *stopflag) | 
|---|
|  | 1038 | goto Abort; | 
|---|
| [783] | 1039 | pffbFile = paffbFound; | 
|---|
|  | 1040 | ulSelCnt = 0; | 
|---|
|  | 1041 | for (;;) { | 
|---|
| [214] | 1042 | if (!*pffbFile->achName || | 
|---|
| [783] | 1043 | (!filestoo && ~pffbFile->attrFile & FILE_DIRECTORY) || | 
|---|
|  | 1044 | (pffbFile->attrFile & FILE_DIRECTORY && | 
|---|
| [534] | 1045 | pffbFile->achName[0] == '.' && | 
|---|
|  | 1046 | (!pffbFile->achName[1] || | 
|---|
| [551] | 1047 | (pffbFile->achName[1] == '.' && !pffbFile->achName[2])))) { | 
|---|
| [783] | 1048 | // ulFindCnt--;             // Got . or .. or file to be skipped | 
|---|
| [174] | 1049 | } | 
|---|
| [214] | 1050 | else | 
|---|
| [783] | 1051 | papffbSelected[ulSelCnt++] = pffbFile;      // Remember selected file | 
|---|
| [551] | 1052 | if (!pffbFile->oNextEntryOffset) { | 
|---|
| [783] | 1053 | // ulFindCnt = ulSelCnt;    // Remember number selected | 
|---|
| [214] | 1054 | break; | 
|---|
|  | 1055 | } | 
|---|
| [841] | 1056 | pffbFile = (PFILEFINDBUF4L)((PBYTE)pffbFile + pffbFile->oNextEntryOffset); | 
|---|
| [763] | 1057 | } // for | 
|---|
| [783] | 1058 | if (ulSelCnt) { | 
|---|
|  | 1059 | // One or more entries selected | 
|---|
| [214] | 1060 | if (stopflag && *stopflag) | 
|---|
|  | 1061 | goto Abort; | 
|---|
| [1335] | 1062 | if (fSyncUpdates) { | 
|---|
| [214] | 1063 | pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD, | 
|---|
| [783] | 1064 | MPFROMLONG(EXTRA_RECORD_BYTES), | 
|---|
|  | 1065 | MPFROMLONG(ulSelCnt)); | 
|---|
| [359] | 1066 | if (!pciFirst) { | 
|---|
| [1395] | 1067 | Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
|  | 1068 | GetPString(IDS_CMALLOCRECERRTEXT)); | 
|---|
| [359] | 1069 | ok = FALSE; | 
|---|
|  | 1070 | ullTotalBytes = 0; | 
|---|
|  | 1071 | } | 
|---|
|  | 1072 | else { | 
|---|
| [907] | 1073 | // 04 Jan 08 SHL fixme like comp.c to handle less than ulSelCnt records | 
|---|
| [214] | 1074 | pci = pciFirst; | 
|---|
|  | 1075 | ullTotalBytes = 0; | 
|---|
| [783] | 1076 | // Insert selected in container | 
|---|
|  | 1077 | for (x = 0; x < ulSelCnt; x++) { | 
|---|
|  | 1078 | pffbFile = papffbSelected[x]; | 
|---|
| [551] | 1079 | ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec, | 
|---|
|  | 1080 | pffbFile, partial, dcd); | 
|---|
|  | 1081 | pci = (PCNRITEM) pci->rc.preccNextRecord; | 
|---|
| [214] | 1082 | ullTotalBytes += ullBytes; | 
|---|
| [731] | 1083 | } // for | 
|---|
| [783] | 1084 | memset(&ri, 0, sizeof(RECORDINSERT)); | 
|---|
|  | 1085 | ri.cb = sizeof(RECORDINSERT); | 
|---|
|  | 1086 | ri.pRecordOrder = (PRECORDCORE) CMA_END; | 
|---|
|  | 1087 | ri.pRecordParent = (PRECORDCORE) pciParent; | 
|---|
|  | 1088 | ri.zOrder = (ULONG) CMA_TOP; | 
|---|
|  | 1089 | ri.cRecordsInsert = ulSelCnt; | 
|---|
| [1316] | 1090 | ri.fInvalidateRecord = TRUE; | 
|---|
|  | 1091 | // !fSyncUpdates && dcd && dcd->type == DIR_FRAME ? FALSE : TRUE; //fSyncUpdates always TRUE 12-1-08 GKY | 
|---|
| [783] | 1092 | if (!WinSendMsg(hwndCnr, | 
|---|
|  | 1093 | CM_INSERTRECORD, | 
|---|
|  | 1094 | MPFROMP(pciFirst), MPFROMP(&ri))) { | 
|---|
|  | 1095 | DosSleep(10);           // Give GUI time to work | 
|---|
|  | 1096 | WinSetFocus(HWND_DESKTOP, hwndCnr); | 
|---|
| [214] | 1097 | if (!WinSendMsg(hwndCnr, | 
|---|
|  | 1098 | CM_INSERTRECORD, | 
|---|
| [551] | 1099 | MPFROMP(pciFirst), MPFROMP(&ri))) { | 
|---|
| [1395] | 1100 | Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
|  | 1101 | GetPString(IDS_CMINSERTERRTEXT)); | 
|---|
| [783] | 1102 | ok = FALSE; | 
|---|
|  | 1103 | ullTotalBytes = 0; | 
|---|
|  | 1104 | if (WinIsWindow((HAB) 0, hwndCnr)) | 
|---|
| [1335] | 1105 | FreeCnrItemList(hwndCnr, pciFirst); | 
|---|
| [214] | 1106 | } | 
|---|
| [783] | 1107 | // } | 
|---|
| [214] | 1108 | } | 
|---|
|  | 1109 | } | 
|---|
| [551] | 1110 | if (ok) { | 
|---|
| [214] | 1111 | ullReturnBytes += ullTotalBytes; | 
|---|
| [783] | 1112 | ulReturnFiles += ulSelCnt; | 
|---|
| [1335] | 1113 | } | 
|---|
| [783] | 1114 | } // if sync updates | 
|---|
| [551] | 1115 | else { | 
|---|
| [783] | 1116 | // Append newly selected entries to aggregate list | 
|---|
| [359] | 1117 | paffbTemp = xrealloc(paffbTotal, | 
|---|
| [841] | 1118 | sizeof(FILEFINDBUF4L) * (ulSelCnt + ulTotal), | 
|---|
| [551] | 1119 | pszSrcFile, __LINE__); | 
|---|
|  | 1120 | if (paffbTemp) { | 
|---|
| [783] | 1121 | // 13 Aug 07 SHL fixme to optimize copy | 
|---|
| [214] | 1122 | paffbTotal = paffbTemp; | 
|---|
| [783] | 1123 | for (x = 0; x < ulSelCnt; x++) | 
|---|
| [214] | 1124 | paffbTotal[x + ulTotal] = *papffbSelected[x]; | 
|---|
| [783] | 1125 | ulTotal += ulSelCnt; | 
|---|
| [214] | 1126 | } | 
|---|
| [551] | 1127 | else { | 
|---|
| [214] | 1128 | saymsg(MB_ENTER, | 
|---|
|  | 1129 | HWND_DESKTOP, | 
|---|
| [551] | 1130 | GetPString(IDS_ERRORTEXT), GetPString(IDS_OUTOFMEMORY)); | 
|---|
| [214] | 1131 | break; | 
|---|
|  | 1132 | } | 
|---|
|  | 1133 | } | 
|---|
| [783] | 1134 | } // if entries selected | 
|---|
| [214] | 1135 | if (stopflag && *stopflag) | 
|---|
| [551] | 1136 | goto Abort; | 
|---|
| [214] | 1137 | DosError(FERR_DISABLEHARDERR); | 
|---|
| [783] | 1138 | ulFindCnt = ulFindMax; | 
|---|
| [850] | 1139 | rc = xDosFindNext(hdir, paffbFound, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZEL); | 
|---|
| [214] | 1140 | priority_normal(); | 
|---|
|  | 1141 | if (rc) | 
|---|
|  | 1142 | DosError(FERR_DISABLEHARDERR); | 
|---|
| [783] | 1143 | } while (!rc); | 
|---|
|  | 1144 |  | 
|---|
| [2] | 1145 | DosFindClose(hdir); | 
|---|
| [1009] | 1146 | xfree(paffbFound, pszSrcFile, __LINE__); | 
|---|
| [985] | 1147 | paffbFound = NULL; | 
|---|
| [1009] | 1148 | xfree(papffbSelected, pszSrcFile, __LINE__); | 
|---|
| [985] | 1149 | papffbSelected = NULL; | 
|---|
| [2] | 1150 |  | 
|---|
| [551] | 1151 | if (ulTotal && paffbTotal) { | 
|---|
| [167] | 1152 |  | 
|---|
| [214] | 1153 | if (stopflag && *stopflag) | 
|---|
|  | 1154 | goto Abort; | 
|---|
| [167] | 1155 |  | 
|---|
| [214] | 1156 | pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD, | 
|---|
| [783] | 1157 | MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(ulTotal)); | 
|---|
| [359] | 1158 | if (!pciFirst) { | 
|---|
| [1395] | 1159 | Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
|  | 1160 | GetPString(IDS_CMALLOCRECERRTEXT)); | 
|---|
| [359] | 1161 | ok = FALSE; | 
|---|
|  | 1162 | ullTotalBytes = 0; | 
|---|
|  | 1163 | } | 
|---|
|  | 1164 | else { | 
|---|
| [907] | 1165 | // 04 Jan 08 SHL fixme like comp.c to handle less than ulSelCnt records | 
|---|
| [214] | 1166 | pci = pciFirst; | 
|---|
|  | 1167 | ullTotalBytes = 0; | 
|---|
| [783] | 1168 | pffbFile = paffbTotal; | 
|---|
|  | 1169 | for (x = 0; x < ulTotal; x++) { | 
|---|
| [551] | 1170 | ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec, | 
|---|
|  | 1171 | pffbFile, partial, dcd); | 
|---|
|  | 1172 | pci = (PCNRITEM) pci->rc.preccNextRecord; | 
|---|
| [214] | 1173 | ullTotalBytes += ullBytes; | 
|---|
| [783] | 1174 | // Can not use offset since we have merged lists - this should be equivalent | 
|---|
| [841] | 1175 | pffbFile = (PFILEFINDBUF4L)((PBYTE)pffbFile + sizeof(FILEFINDBUF4L)); | 
|---|
| [214] | 1176 | } | 
|---|
| [551] | 1177 | if (ulTotal) { | 
|---|
|  | 1178 | memset(&ri, 0, sizeof(RECORDINSERT)); | 
|---|
|  | 1179 | ri.cb = sizeof(RECORDINSERT); | 
|---|
|  | 1180 | ri.pRecordOrder = (PRECORDCORE) CMA_END; | 
|---|
|  | 1181 | ri.pRecordParent = (PRECORDCORE) pciParent; | 
|---|
|  | 1182 | ri.zOrder = (ULONG) CMA_TOP; | 
|---|
|  | 1183 | ri.cRecordsInsert = ulTotal; | 
|---|
|  | 1184 | ri.fInvalidateRecord = (!fSyncUpdates && dcd && | 
|---|
|  | 1185 | dcd->type == DIR_FRAME) ? FALSE : TRUE; | 
|---|
|  | 1186 | if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, | 
|---|
|  | 1187 | MPFROMP(pciFirst), MPFROMP(&ri))) { | 
|---|
| [783] | 1188 | DosSleep(10);             // Give GUI time to work | 
|---|
| [551] | 1189 | WinSetFocus(HWND_DESKTOP, hwndCnr); | 
|---|
|  | 1190 | if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, | 
|---|
|  | 1191 | MPFROMP(pciFirst), MPFROMP(&ri))) { | 
|---|
| [1395] | 1192 | Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
|  | 1193 | GetPString(IDS_CMINSERTERRTEXT)); | 
|---|
| [214] | 1194 | ok = FALSE; | 
|---|
|  | 1195 | ullTotalBytes = 0; | 
|---|
| [751] | 1196 | if (WinIsWindow((HAB) 0, hwndCnr)) | 
|---|
| [1335] | 1197 | FreeCnrItemList(hwndCnr, pciFirst); | 
|---|
| [214] | 1198 | } | 
|---|
|  | 1199 | } | 
|---|
|  | 1200 | } | 
|---|
|  | 1201 | } | 
|---|
| [551] | 1202 | if (ok) { | 
|---|
| [214] | 1203 | ullReturnBytes += ullTotalBytes; | 
|---|
| [783] | 1204 | ulReturnFiles += ulFindCnt; | 
|---|
| [214] | 1205 | } | 
|---|
| [2] | 1206 | } | 
|---|
|  | 1207 | } | 
|---|
|  | 1208 |  | 
|---|
| [924] | 1209 | /** | 
|---|
|  | 1210 | * DosFind for subdirectories of a read-only directory on a FAT volume | 
|---|
|  | 1211 | * returns path not found if there are no subdirectories | 
|---|
|  | 1212 | * FAT FS seems to ignore . and .. in this case | 
|---|
|  | 1213 | * Map to no more files | 
|---|
|  | 1214 | * We could verify that directory is marked read-only, it's probably not | 
|---|
|  | 1215 | * worth the extra code since we do verify 2 out of 3 prerequisites | 
|---|
|  | 1216 | * 15 Jan 08 SHL | 
|---|
|  | 1217 | */ | 
|---|
|  | 1218 | if (rc == ERROR_PATH_NOT_FOUND && !filestoo) { | 
|---|
|  | 1219 | ULONG ulDriveType = 0; | 
|---|
|  | 1220 | CHAR szFSType[CCHMAXPATH]; | 
|---|
|  | 1221 | INT removable = CheckDrive(*pszFileSpec, szFSType, &ulDriveType); | 
|---|
|  | 1222 | if (removable != -1 && strcmp(szFSType, "FAT") == 0) | 
|---|
|  | 1223 | rc = ERROR_NO_MORE_FILES; | 
|---|
|  | 1224 | } | 
|---|
|  | 1225 |  | 
|---|
| [783] | 1226 | if (rc && rc != ERROR_NO_MORE_FILES) { | 
|---|
|  | 1227 | Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
|  | 1228 | GetPString(IDS_CANTFINDDIRTEXT), pszFileSpec); | 
|---|
|  | 1229 | } | 
|---|
|  | 1230 |  | 
|---|
| [167] | 1231 | if (!fSyncUpdates && dcd && dcd->type == DIR_FRAME) | 
|---|
| [551] | 1232 | WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPVOID, | 
|---|
|  | 1233 | MPFROM2SHORT(0, CMA_ERASE)); | 
|---|
| [2] | 1234 | } | 
|---|
|  | 1235 | Abort: | 
|---|
| [1009] | 1236 | xfree(paffbTotal, pszSrcFile, __LINE__); | 
|---|
|  | 1237 | xfree(pszFileSpec, pszSrcFile, __LINE__); | 
|---|
|  | 1238 | xfree(paffbFound, pszSrcFile, __LINE__); | 
|---|
|  | 1239 | xfree(papffbSelected, pszSrcFile, __LINE__); | 
|---|
| [783] | 1240 |  | 
|---|
| [551] | 1241 | if (recurse) { | 
|---|
| [2] | 1242 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent), | 
|---|
| [214] | 1243 | MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER)); | 
|---|
| [762] | 1244 | while (pci && (INT)pci != -1) { | 
|---|
| [1354] | 1245 | if ((pci->attrFile & FILE_DIRECTORY)) | 
|---|
| [1402] | 1246 | //if (fInitialDriveScan) | 
|---|
| [1354] | 1247 | Stubby(hwndCnr, pci); | 
|---|
| [1402] | 1248 | /*else { | 
|---|
| [1354] | 1249 | while (StubbyScanCount != 0) | 
|---|
|  | 1250 | DosSleep(50); | 
|---|
|  | 1251 | Stubby(hwndCnr, pci); | 
|---|
| [1402] | 1252 | } */ | 
|---|
| [1354] | 1253 | //Stubby(hwndCnr, pci); | 
|---|
| [2] | 1254 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci), | 
|---|
| [214] | 1255 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); | 
|---|
| [2] | 1256 | } | 
|---|
|  | 1257 | } | 
|---|
|  | 1258 |  | 
|---|
| [167] | 1259 | if (pulTotalFiles) | 
|---|
|  | 1260 | *pulTotalFiles = ulReturnFiles; | 
|---|
| [2] | 1261 |  | 
|---|
| [167] | 1262 | if (pullTotalBytes) | 
|---|
|  | 1263 | *pullTotalBytes = ullReturnBytes; | 
|---|
| [2] | 1264 |  | 
|---|
| [731] | 1265 | } // ProcessDirectory | 
|---|
| [167] | 1266 |  | 
|---|
|  | 1267 | VOID FillDirCnr(HWND hwndCnr, | 
|---|
| [551] | 1268 | CHAR * pszDirectory, | 
|---|
| [924] | 1269 | DIRCNRDATA * dcd, | 
|---|
|  | 1270 | PULONGLONG pullTotalBytes) | 
|---|
| [90] | 1271 | { | 
|---|
| [167] | 1272 | ProcessDirectory(hwndCnr, | 
|---|
| [924] | 1273 | (PCNRITEM)NULL, | 
|---|
| [167] | 1274 | pszDirectory, | 
|---|
| [737] | 1275 | TRUE,                // filestoo | 
|---|
|  | 1276 | FALSE,               // recurse | 
|---|
|  | 1277 | TRUE,                // partial | 
|---|
|  | 1278 | dcd ? &dcd->stopflag : NULL, | 
|---|
|  | 1279 | dcd, | 
|---|
| [924] | 1280 | NULL,                // total files | 
|---|
| [737] | 1281 | pullTotalBytes); | 
|---|
| [2] | 1282 | DosPostEventSem(CompactSem); | 
|---|
|  | 1283 |  | 
|---|
| [762] | 1284 | #if 0 // fixme to be gone or to be configurable | 
|---|
| [751] | 1285 | { | 
|---|
|  | 1286 | int state = _heapchk(); | 
|---|
|  | 1287 | if (state != _HEAPOK) | 
|---|
|  | 1288 | Runtime_Error(pszSrcFile, __LINE__, "heap corrupted %d", state); | 
|---|
| [763] | 1289 | else | 
|---|
|  | 1290 | DbgMsg(pszSrcFile, __LINE__, "_memavl %u", _memavl()); | 
|---|
| [751] | 1291 | } | 
|---|
|  | 1292 | #endif | 
|---|
|  | 1293 |  | 
|---|
| [731] | 1294 | } // FillDirCnr | 
|---|
| [2] | 1295 |  | 
|---|
| [551] | 1296 | VOID FillTreeCnr(HWND hwndCnr, HWND hwndParent) | 
|---|
| [90] | 1297 | { | 
|---|
| [924] | 1298 | ULONG ulCurDriveNum, ulDriveMap, numtoinsert = 0; | 
|---|
|  | 1299 | ULONG ulDriveType; | 
|---|
| [551] | 1300 | PCNRITEM pci, pciFirst = NULL, pciNext, pciParent = NULL; | 
|---|
|  | 1301 | INT x, removable; | 
|---|
| [731] | 1302 | CHAR suggest[32]; | 
|---|
| [739] | 1303 | CHAR szDrive[] = " :\\"; | 
|---|
| [924] | 1304 | CHAR szFSType[CCHMAXPATH]; | 
|---|
| [841] | 1305 | FILESTATUS4L fsa4; | 
|---|
| [551] | 1306 | APIRET rc; | 
|---|
|  | 1307 | BOOL drivesbuilt = FALSE; | 
|---|
| [739] | 1308 | ULONG startdrive = 3; | 
|---|
| [2] | 1309 | static BOOL didonce = FALSE; | 
|---|
|  | 1310 |  | 
|---|
|  | 1311 | fDummy = TRUE; | 
|---|
|  | 1312 | *suggest = 0; | 
|---|
| [689] | 1313 | for (x = 0; x < 26; x++) { | 
|---|
| [2] | 1314 | driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS | | 
|---|
| [214] | 1315 | DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS | | 
|---|
| [1354] | 1316 | DRIVE_INCLUDEFILES | DRIVE_SLOW | DRIVE_NOSTATS | | 
|---|
|  | 1317 | DRIVE_WRITEVERIFYOFF); | 
|---|
| [689] | 1318 | } | 
|---|
| [551] | 1319 | memset(driveserial, -1, sizeof(driveserial)); | 
|---|
| [739] | 1320 |  | 
|---|
|  | 1321 | DosError(FERR_DISABLEHARDERR); | 
|---|
|  | 1322 | if (!DosQuerySysInfo(QSV_BOOT_DRIVE, | 
|---|
|  | 1323 | QSV_BOOT_DRIVE, | 
|---|
|  | 1324 | (PVOID) &startdrive, | 
|---|
|  | 1325 | (ULONG) sizeof(ULONG)) && | 
|---|
|  | 1326 | startdrive) | 
|---|
| [2] | 1327 | { | 
|---|
| [739] | 1328 | driveflags[startdrive - 1] |= DRIVE_BOOT; | 
|---|
|  | 1329 | } | 
|---|
| [2] | 1330 |  | 
|---|
|  | 1331 | DosError(FERR_DISABLEHARDERR); | 
|---|
| [731] | 1332 | rc = DosQCurDisk(&ulCurDriveNum, &ulDriveMap); | 
|---|
| [551] | 1333 | if (rc) { | 
|---|
| [2] | 1334 | Dos_Error(MB_CANCEL, | 
|---|
| [214] | 1335 | rc, | 
|---|
|  | 1336 | HWND_DESKTOP, | 
|---|
| [1395] | 1337 | pszSrcFile, __LINE__, PCSZ_FILLDIRQCURERRTEXT); | 
|---|
| [2] | 1338 | exit(0); | 
|---|
|  | 1339 | } | 
|---|
| [739] | 1340 |  | 
|---|
| [731] | 1341 | // Calc number of drive items to create | 
|---|
| [689] | 1342 | for (x = 0; x < 26; x++) { | 
|---|
| [167] | 1343 | if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) | 
|---|
| [2] | 1344 | numtoinsert++; | 
|---|
| [689] | 1345 | } | 
|---|
| [739] | 1346 |  | 
|---|
| [689] | 1347 | if (numtoinsert) { | 
|---|
| [2] | 1348 | pciFirst = WinSendMsg(hwndCnr, | 
|---|
| [214] | 1349 | CM_ALLOCRECORD, | 
|---|
| [751] | 1350 | MPFROMLONG(EXTRA_RECORD_BYTES), | 
|---|
| [551] | 1351 | MPFROMLONG((ULONG) numtoinsert)); | 
|---|
| [689] | 1352 | } | 
|---|
| [739] | 1353 |  | 
|---|
| [359] | 1354 | if (!pciFirst) { | 
|---|
| [1395] | 1355 | Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, GetPString(IDS_CMALLOCRECERRTEXT)); | 
|---|
| [907] | 1356 | // 04 Jan 08 SHL fixme not just up and die | 
|---|
| [359] | 1357 | exit(0); | 
|---|
|  | 1358 | } | 
|---|
| [689] | 1359 |  | 
|---|
| [907] | 1360 | // 04 Jan 08 SHL fixme like comp.c to handle less than ulSelCnt records | 
|---|
| [739] | 1361 | pci = pciFirst; | 
|---|
|  | 1362 | for (x = 0; x < 26; x++) { | 
|---|
|  | 1363 | if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) { | 
|---|
| [2] | 1364 |  | 
|---|
| [739] | 1365 | CHAR s[80]; | 
|---|
|  | 1366 | ULONG flags = 0; | 
|---|
| [1328] | 1367 | ULONG size = sizeof(ULONG); | 
|---|
| [2] | 1368 |  | 
|---|
| [739] | 1369 | *szDrive = (CHAR)x + 'A';         // Build path spec | 
|---|
| [731] | 1370 |  | 
|---|
| [739] | 1371 | sprintf(s, "%c.DriveFlags", toupper(*szDrive)); | 
|---|
| [1328] | 1372 | if (PrfQueryProfileData(fmprof, appname, s, &flags, &size)) { | 
|---|
| [739] | 1373 | driveflags[toupper(*szDrive) - 'A'] |= flags; | 
|---|
|  | 1374 | } | 
|---|
| [2] | 1375 |  | 
|---|
| [739] | 1376 | if (x > 1) { | 
|---|
|  | 1377 | // Hard drive (2..N) | 
|---|
|  | 1378 | if (!(driveflags[x] & DRIVE_NOPRESCAN)) { | 
|---|
| [924] | 1379 | *szFSType = 0; | 
|---|
|  | 1380 | ulDriveType = 0; | 
|---|
|  | 1381 | removable = CheckDrive(*szDrive, szFSType, &ulDriveType); | 
|---|
| [739] | 1382 | driveserial[x] = -1; | 
|---|
|  | 1383 | if (removable != -1) { | 
|---|
|  | 1384 | struct { | 
|---|
|  | 1385 | ULONG serial; | 
|---|
|  | 1386 | CHAR volumelength; | 
|---|
|  | 1387 | CHAR volumelabel[CCHMAXPATH]; | 
|---|
|  | 1388 | } volser; | 
|---|
| [2] | 1389 |  | 
|---|
| [739] | 1390 | DosError(FERR_DISABLEHARDERR); | 
|---|
|  | 1391 | if (!DosQueryFSInfo((ULONG) x, | 
|---|
|  | 1392 | FSIL_VOLSER, &volser, sizeof(volser))) { | 
|---|
|  | 1393 | driveserial[x] = volser.serial; | 
|---|
| [731] | 1394 | } | 
|---|
| [739] | 1395 | } | 
|---|
|  | 1396 | else | 
|---|
|  | 1397 | driveflags[x] |= DRIVE_INVALID; | 
|---|
| [731] | 1398 |  | 
|---|
| [841] | 1399 | memset(&fsa4, 0, sizeof(FILESTATUS4L)); | 
|---|
| [739] | 1400 | driveflags[x] |= removable == -1 || removable == 1 ? | 
|---|
|  | 1401 | DRIVE_REMOVABLE : 0; | 
|---|
| [924] | 1402 | if (ulDriveType & DRIVE_REMOTE) | 
|---|
| [739] | 1403 | driveflags[x] |= DRIVE_REMOTE; | 
|---|
| [924] | 1404 | if (!stricmp(szFSType,RAMFS)) { | 
|---|
| [739] | 1405 | driveflags[x] |= DRIVE_RAMDISK; | 
|---|
|  | 1406 | driveflags[x] &= ~DRIVE_REMOTE; | 
|---|
|  | 1407 | } | 
|---|
| [924] | 1408 | if (!stricmp(szFSType,NDFS32)) { | 
|---|
| [739] | 1409 | driveflags[x] |= DRIVE_VIRTUAL; | 
|---|
|  | 1410 | driveflags[x] &= ~DRIVE_REMOTE; | 
|---|
|  | 1411 | } | 
|---|
| [924] | 1412 | if (!stricmp(szFSType,NTFS)) | 
|---|
| [739] | 1413 | driveflags[x] |= DRIVE_NOTWRITEABLE; | 
|---|
| [924] | 1414 | if (strcmp(szFSType, HPFS) && | 
|---|
|  | 1415 | strcmp(szFSType, JFS) && | 
|---|
|  | 1416 | strcmp(szFSType, ISOFS) && | 
|---|
|  | 1417 | strcmp(szFSType, CDFS) && | 
|---|
|  | 1418 | strcmp(szFSType, FAT32) && | 
|---|
|  | 1419 | strcmp(szFSType, NDFS32) && | 
|---|
|  | 1420 | strcmp(szFSType, RAMFS) && | 
|---|
| [1347] | 1421 | strcmp(szFSType, NTFS) && | 
|---|
| [924] | 1422 | strcmp(szFSType, HPFS386)) { | 
|---|
| [739] | 1423 | driveflags[x] |= DRIVE_NOLONGNAMES; | 
|---|
|  | 1424 | } | 
|---|
| [534] | 1425 |  | 
|---|
| [924] | 1426 | if (!strcmp(szFSType, CDFS) || !strcmp(szFSType,ISOFS)) { | 
|---|
| [739] | 1427 | removable = 1; | 
|---|
| [1347] | 1428 | driveflags[x] |= DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE | DRIVE_CDROM; | 
|---|
| [739] | 1429 | } | 
|---|
| [1347] | 1430 | if (!stricmp(szFSType, CBSIFS)) { | 
|---|
| [739] | 1431 | driveflags[x] |= DRIVE_ZIPSTREAM; | 
|---|
|  | 1432 | driveflags[x] &= ~DRIVE_REMOTE; | 
|---|
| [924] | 1433 | if (ulDriveType & DRIVE_REMOVABLE) | 
|---|
| [739] | 1434 | driveflags[x] |= DRIVE_REMOVABLE; | 
|---|
| [924] | 1435 | if (!(ulDriveType & DRIVE_NOLONGNAMES)) | 
|---|
| [739] | 1436 | driveflags[x] &= ~DRIVE_NOLONGNAMES; | 
|---|
| [1347] | 1437 | } | 
|---|
| [1354] | 1438 | if (!fVerifyOffChecked[x]) { | 
|---|
|  | 1439 | if (driveflags[x] & DRIVE_REMOVABLE) | 
|---|
|  | 1440 | driveflags[x] |= DRIVE_WRITEVERIFYOFF; | 
|---|
| [1355] | 1441 | if (!(driveflags[x] & DRIVE_INVALID)) { | 
|---|
| [1354] | 1442 | CHAR Key[80]; | 
|---|
| [2] | 1443 |  | 
|---|
| [1354] | 1444 | sprintf(Key, "%c.VerifyOffChecked", (CHAR) (x + 'A')); | 
|---|
|  | 1445 | fVerifyOffChecked[x] = TRUE; | 
|---|
|  | 1446 | PrfWriteProfileData(fmprof, appname, Key, &fVerifyOffChecked[x], sizeof(BOOL)); | 
|---|
|  | 1447 | } | 
|---|
|  | 1448 | } | 
|---|
| [739] | 1449 | pci->rc.flRecordAttr |= CRA_RECORDREADONLY; | 
|---|
|  | 1450 | if ((ULONG)(toupper(*szDrive) - '@') == ulCurDriveNum) | 
|---|
|  | 1451 | pci->rc.flRecordAttr |= (CRA_CURSORED | CRA_SELECTED); | 
|---|
| [2] | 1452 |  | 
|---|
| [739] | 1453 | if (removable == 0) { | 
|---|
|  | 1454 | // Fixed volume | 
|---|
|  | 1455 | pci->attrFile |= FILE_DIRECTORY; | 
|---|
|  | 1456 | DosError(FERR_DISABLEHARDERR); | 
|---|
|  | 1457 | rc = DosQueryPathInfo(szDrive, | 
|---|
| [841] | 1458 | FIL_QUERYEASIZEL, | 
|---|
|  | 1459 | &fsa4, (ULONG) sizeof(FILESTATUS4L)); | 
|---|
| [739] | 1460 | // ERROR_BAD_NET_RSP = 58 | 
|---|
|  | 1461 | if (rc == 58) { | 
|---|
| [214] | 1462 | DosError(FERR_DISABLEHARDERR); | 
|---|
|  | 1463 | rc = DosQueryPathInfo(szDrive, | 
|---|
| [841] | 1464 | FIL_STANDARDL, | 
|---|
| [847] | 1465 | &fsa4, (ULONG) sizeof(FILESTATUS4L)); | 
|---|
| [739] | 1466 | fsa4.cbList = 0; | 
|---|
|  | 1467 | } | 
|---|
|  | 1468 | if (rc && !didonce) { | 
|---|
|  | 1469 | // Guess drive letter | 
|---|
|  | 1470 | if (!*suggest) { | 
|---|
|  | 1471 | *suggest = '/'; | 
|---|
|  | 1472 | suggest[1] = 0; | 
|---|
| [214] | 1473 | } | 
|---|
| [739] | 1474 | sprintf(suggest + strlen(suggest), "%c" , toupper(*szDrive)); | 
|---|
| [773] | 1475 | pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__); | 
|---|
| [739] | 1476 | pci->pszDisplayName = pci->pszFileName; | 
|---|
|  | 1477 | pci->rc.pszIcon = pci->pszDisplayName; | 
|---|
| [214] | 1478 | pci->attrFile = FILE_DIRECTORY; | 
|---|
| [751] | 1479 | pci->pszDispAttr = FileAttrToString(pci->attrFile); | 
|---|
| [739] | 1480 | driveserial[x] = -1; | 
|---|
| [731] | 1481 | } | 
|---|
| [739] | 1482 | else | 
|---|
|  | 1483 | FillInRecordFromFSA(hwndCnr, pci, szDrive, &fsa4, TRUE, NULL); | 
|---|
| [214] | 1484 | } | 
|---|
| [551] | 1485 | else { | 
|---|
| [739] | 1486 | // Removable volume | 
|---|
| [773] | 1487 | pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__); | 
|---|
| [739] | 1488 | pci->pszDisplayName = pci->pszFileName; | 
|---|
|  | 1489 | pci->rc.pszIcon = pci->pszDisplayName; | 
|---|
| [214] | 1490 | pci->attrFile = FILE_DIRECTORY; | 
|---|
| [751] | 1491 | pci->pszDispAttr = FileAttrToString(pci->attrFile); | 
|---|
| [214] | 1492 | } | 
|---|
| [1284] | 1493 | SelectDriveIcon(pci); | 
|---|
| [1250] | 1494 | #         ifdef FORTIFY | 
|---|
|  | 1495 | // Will be freed by TreeCnrWndProc WM_DESTROY | 
|---|
|  | 1496 | Fortify_SetScope(pci->pszFileName, 2); | 
|---|
|  | 1497 | #         endif | 
|---|
| [214] | 1498 | } | 
|---|
| [1284] | 1499 | else { | 
|---|
| [739] | 1500 | pci->rc.hptrIcon = hptrDunno; | 
|---|
| [773] | 1501 | pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__); | 
|---|
| [1154] | 1502 | #         ifdef FORTIFY | 
|---|
|  | 1503 | // Will be freed by TreeCnrWndProc WM_DESTROY | 
|---|
|  | 1504 | Fortify_SetScope(pci->pszFileName, 2); | 
|---|
|  | 1505 | #         endif | 
|---|
| [739] | 1506 | pci->pszDisplayName = pci->pszFileName; | 
|---|
| [214] | 1507 | pci->rc.pszIcon = pci->pszFileName; | 
|---|
|  | 1508 | pci->attrFile = FILE_DIRECTORY; | 
|---|
| [751] | 1509 | pci->pszDispAttr = FileAttrToString(pci->attrFile); | 
|---|
| [214] | 1510 | driveserial[x] = -1; | 
|---|
|  | 1511 | } | 
|---|
| [2] | 1512 | } | 
|---|
| [739] | 1513 | else { | 
|---|
|  | 1514 | // diskette drive (A or B) | 
|---|
|  | 1515 | pci->rc.hptrIcon = hptrFloppy; | 
|---|
| [773] | 1516 | pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__); | 
|---|
| [739] | 1517 | pci->pszDisplayName = pci->pszFileName; | 
|---|
|  | 1518 | pci->rc.pszIcon = pci->pszDisplayName; | 
|---|
|  | 1519 | pci->attrFile = FILE_DIRECTORY; | 
|---|
| [751] | 1520 | pci->pszDispAttr = FileAttrToString(pci->attrFile); | 
|---|
| [739] | 1521 | driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOLONGNAMES); | 
|---|
|  | 1522 | driveserial[x] = -1; | 
|---|
|  | 1523 | } | 
|---|
|  | 1524 | pci->rc.flRecordAttr |= CRA_RECORDREADONLY; | 
|---|
| [783] | 1525 | pci = (PCNRITEM) pci->rc.preccNextRecord; // next rec | 
|---|
| [739] | 1526 | } | 
|---|
|  | 1527 | else if (!(ulDriveMap & (1L << x))) | 
|---|
|  | 1528 | driveflags[x] |= DRIVE_INVALID; | 
|---|
|  | 1529 | } // for drives | 
|---|
| [689] | 1530 |  | 
|---|
| [739] | 1531 | PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID); | 
|---|
|  | 1532 | drivesbuilt = TRUE; | 
|---|
| [2] | 1533 |  | 
|---|
| [783] | 1534 | // insert the drives | 
|---|
| [739] | 1535 | if (numtoinsert && pciFirst) { | 
|---|
|  | 1536 | RECORDINSERT ri; | 
|---|
|  | 1537 |  | 
|---|
|  | 1538 | memset(&ri, 0, sizeof(RECORDINSERT)); | 
|---|
|  | 1539 | ri.cb = sizeof(RECORDINSERT); | 
|---|
|  | 1540 | ri.pRecordOrder = (PRECORDCORE) CMA_END; | 
|---|
|  | 1541 | ri.pRecordParent = (PRECORDCORE) NULL; | 
|---|
|  | 1542 | ri.zOrder = (ULONG) CMA_TOP; | 
|---|
|  | 1543 | ri.cRecordsInsert = numtoinsert; | 
|---|
|  | 1544 | ri.fInvalidateRecord = FALSE; | 
|---|
|  | 1545 | if (!WinSendMsg(hwndCnr, | 
|---|
|  | 1546 | CM_INSERTRECORD, MPFROMP(pciFirst), MPFROMP(&ri))) | 
|---|
|  | 1547 | { | 
|---|
| [1395] | 1548 | Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
|  | 1549 | GetPString(IDS_CMINSERTERRTEXT)); | 
|---|
| [2] | 1550 | } | 
|---|
| [739] | 1551 | } | 
|---|
| [689] | 1552 |  | 
|---|
| [783] | 1553 | // move cursor onto the default drive rather than the first drive | 
|---|
| [739] | 1554 | if (!fSwitchTree) { | 
|---|
|  | 1555 | pci = (PCNRITEM) WinSendMsg(hwndCnr, | 
|---|
|  | 1556 | CM_QUERYRECORD, | 
|---|
|  | 1557 | MPVOID, | 
|---|
|  | 1558 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | 
|---|
| [762] | 1559 | while (pci && (INT)pci != -1) { | 
|---|
| [739] | 1560 | if ((ULONG) (toupper(*pci->pszFileName) - '@') == ulCurDriveNum) { | 
|---|
|  | 1561 | WinSendMsg(hwndCnr, | 
|---|
|  | 1562 | CM_SETRECORDEMPHASIS, | 
|---|
|  | 1563 | MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED)); | 
|---|
|  | 1564 | break; | 
|---|
|  | 1565 | } | 
|---|
| [551] | 1566 | pci = (PCNRITEM) WinSendMsg(hwndCnr, | 
|---|
|  | 1567 | CM_QUERYRECORD, | 
|---|
| [739] | 1568 | MPFROMP(pci), | 
|---|
|  | 1569 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); | 
|---|
| [2] | 1570 | } | 
|---|
| [739] | 1571 | } | 
|---|
| [2] | 1572 |  | 
|---|
| [739] | 1573 | if (hwndParent) { | 
|---|
|  | 1574 | WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent, QW_PARENT), | 
|---|
|  | 1575 | MAIN_DRIVELIST), | 
|---|
|  | 1576 | LM_DELETEALL, MPVOID, MPVOID); | 
|---|
|  | 1577 | } | 
|---|
| [2] | 1578 |  | 
|---|
| [739] | 1579 | if (fShowEnv) { | 
|---|
|  | 1580 | RECORDINSERT ri; | 
|---|
| [2] | 1581 |  | 
|---|
| [739] | 1582 | pciParent = WinSendMsg(hwndCnr, | 
|---|
|  | 1583 | CM_ALLOCRECORD, | 
|---|
| [751] | 1584 | MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(1)); | 
|---|
| [739] | 1585 | if (pciParent) { | 
|---|
|  | 1586 | pciParent->flags |= RECFLAGS_ENV; | 
|---|
| [773] | 1587 | pciParent->pszFileName = xstrdup(GetPString(IDS_ENVVARSTEXT), pszSrcFile, __LINE__); | 
|---|
| [763] | 1588 | pciParent->pszDisplayName = pciParent->pszFileName;       // 03 Aug 07 SHL | 
|---|
| [739] | 1589 | pciParent->rc.hptrIcon = hptrEnv; | 
|---|
|  | 1590 | pciParent->rc.pszIcon = pciParent->pszFileName; | 
|---|
| [751] | 1591 | pciParent->pszDispAttr = FileAttrToString(0); | 
|---|
| [739] | 1592 | memset(&ri, 0, sizeof(RECORDINSERT)); | 
|---|
|  | 1593 | ri.cb = sizeof(RECORDINSERT); | 
|---|
|  | 1594 | ri.pRecordOrder = (PRECORDCORE) CMA_END; | 
|---|
|  | 1595 | ri.pRecordParent = (PRECORDCORE) NULL; | 
|---|
|  | 1596 | ri.zOrder = (ULONG) CMA_TOP; | 
|---|
|  | 1597 | ri.cRecordsInsert = 1; | 
|---|
|  | 1598 | ri.fInvalidateRecord = FALSE; | 
|---|
|  | 1599 | if (WinSendMsg(hwndCnr, | 
|---|
|  | 1600 | CM_INSERTRECORD, MPFROMP(pciParent), MPFROMP(&ri))) { | 
|---|
| [2] | 1601 |  | 
|---|
| [739] | 1602 | char *p, *pp; | 
|---|
| [2] | 1603 |  | 
|---|
| [1154] | 1604 | p = pszTreeEnvVarList; | 
|---|
| [1090] | 1605 | while (*p == ';') | 
|---|
| [739] | 1606 | p++; | 
|---|
|  | 1607 | while (*p) { | 
|---|
| [924] | 1608 | *szFSType = 0; | 
|---|
|  | 1609 | pp = szFSType; | 
|---|
| [1090] | 1610 | while (*p && *p != ';') | 
|---|
| [739] | 1611 | *pp++ = *p++; | 
|---|
|  | 1612 | *pp = 0; | 
|---|
| [1090] | 1613 | while (*p == ';') | 
|---|
| [214] | 1614 | p++; | 
|---|
| [924] | 1615 | if (*szFSType && | 
|---|
| [1400] | 1616 | (!stricmp(szFSType, PCSZ_LIBPATH) || getenv(szFSType))) { | 
|---|
| [739] | 1617 | pci = WinSendMsg(hwndCnr, | 
|---|
|  | 1618 | CM_ALLOCRECORD, | 
|---|
| [751] | 1619 | MPFROMLONG(EXTRA_RECORD_BYTES), | 
|---|
| [739] | 1620 | MPFROMLONG(1)); | 
|---|
|  | 1621 | if (pci) { | 
|---|
|  | 1622 | CHAR fname[CCHMAXPATH]; | 
|---|
|  | 1623 | pci->flags |= RECFLAGS_ENV; | 
|---|
| [924] | 1624 | sprintf(fname, "%%%s%%", szFSType); | 
|---|
| [739] | 1625 | pci->pszFileName = xstrdup(fname, pszSrcFile, __LINE__); | 
|---|
|  | 1626 | pci->rc.hptrIcon = hptrEnv; | 
|---|
|  | 1627 | pci->rc.pszIcon = pci->pszFileName; | 
|---|
| [751] | 1628 | pci->pszDispAttr = FileAttrToString(0); | 
|---|
| [739] | 1629 | memset(&ri, 0, sizeof(RECORDINSERT)); | 
|---|
|  | 1630 | ri.cb = sizeof(RECORDINSERT); | 
|---|
|  | 1631 | ri.pRecordOrder = (PRECORDCORE) CMA_END; | 
|---|
|  | 1632 | ri.pRecordParent = (PRECORDCORE) pciParent; | 
|---|
|  | 1633 | ri.zOrder = (ULONG) CMA_TOP; | 
|---|
|  | 1634 | ri.cRecordsInsert = 1; | 
|---|
|  | 1635 | ri.fInvalidateRecord = FALSE; | 
|---|
|  | 1636 | if (!WinSendMsg(hwndCnr, | 
|---|
|  | 1637 | CM_INSERTRECORD, | 
|---|
|  | 1638 | MPFROMP(pci), MPFROMP(&ri))) { | 
|---|
| [1395] | 1639 | Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
|  | 1640 | GetPString(IDS_CMINSERTERRTEXT)); | 
|---|
| [751] | 1641 | FreeCnrItem(hwndCnr, pci); | 
|---|
| [214] | 1642 | } | 
|---|
|  | 1643 | } | 
|---|
|  | 1644 | } | 
|---|
|  | 1645 | } | 
|---|
| [739] | 1646 | WinSendMsg(hwndCnr, | 
|---|
|  | 1647 | CM_INVALIDATERECORD, | 
|---|
|  | 1648 | MPFROMP(&pciParent), | 
|---|
|  | 1649 | MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION)); | 
|---|
| [2] | 1650 | } | 
|---|
| [739] | 1651 | else | 
|---|
| [751] | 1652 | FreeCnrItem(hwndCnr, pciParent); | 
|---|
| [739] | 1653 | } | 
|---|
|  | 1654 | } // if show env | 
|---|
| [1299] | 1655 | { | 
|---|
| [1335] | 1656 | STUBBYSCAN *stubbyScan; | 
|---|
| [1299] | 1657 | HWND hwndDrivesList = WinWindowFromID(WinQueryWindow(hwndParent, QW_PARENT), | 
|---|
| [1335] | 1658 | MAIN_DRIVELIST); | 
|---|
| [1299] | 1659 |  | 
|---|
| [1250] | 1660 | pci = (PCNRITEM) WinSendMsg(hwndCnr, | 
|---|
| [1308] | 1661 | CM_QUERYRECORD, | 
|---|
|  | 1662 | MPVOID, | 
|---|
| [1402] | 1663 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | 
|---|
| [1317] | 1664 | StubbyScanCount ++; | 
|---|
| [1250] | 1665 | while (pci && (INT)pci != -1) { | 
|---|
| [1335] | 1666 | stubbyScan = xmallocz(sizeof(STUBBYSCAN), pszSrcFile, __LINE__); | 
|---|
|  | 1667 | if (!stubbyScan) | 
|---|
| [1308] | 1668 | break; | 
|---|
| [1335] | 1669 | stubbyScan->pci = pci; | 
|---|
|  | 1670 | stubbyScan->hwndCnr = hwndCnr; | 
|---|
|  | 1671 | stubbyScan->hwndDrivesList = hwndDrivesList; | 
|---|
|  | 1672 | stubbyScan->RamDrive = FALSE; | 
|---|
| [1250] | 1673 | pciNext = (PCNRITEM) WinSendMsg(hwndCnr, | 
|---|
| [1308] | 1674 | CM_QUERYRECORD, | 
|---|
|  | 1675 | MPFROMP(pci), | 
|---|
|  | 1676 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); | 
|---|
| [1284] | 1677 | if (~pci->flags & RECFLAGS_ENV) { | 
|---|
| [1308] | 1678 | ULONG drvNum = toupper(*pci->pszFileName) - 'A';        // 0..25 | 
|---|
|  | 1679 | if (drvNum == ulCurDriveNum || drvNum >= 2) { | 
|---|
|  | 1680 | ULONG flags = driveflags[drvNum];     // Speed up | 
|---|
|  | 1681 | if (~flags & DRIVE_INVALID && | 
|---|
|  | 1682 | ~flags & DRIVE_NOPRESCAN && | 
|---|
| [1402] | 1683 | (!fNoRemovableScan || ~flags & DRIVE_REMOVABLE)) //&& !fDrivetoSkip[drvNum]) | 
|---|
| [1308] | 1684 | { | 
|---|
|  | 1685 | if (DRIVE_RAMDISK) | 
|---|
| [1335] | 1686 | stubbyScan->RamDrive = TRUE; | 
|---|
|  | 1687 | if (xbeginthread(StubbyScanThread, | 
|---|
|  | 1688 | 65536, | 
|---|
|  | 1689 | stubbyScan, | 
|---|
|  | 1690 | pszSrcFile, | 
|---|
|  | 1691 | __LINE__) == -1) | 
|---|
|  | 1692 | { | 
|---|
|  | 1693 | xfree(stubbyScan, pszSrcFile, __LINE__); | 
|---|
|  | 1694 | } | 
|---|
| [1308] | 1695 | } // if drive for scanning | 
|---|
|  | 1696 | else | 
|---|
|  | 1697 | WinSendMsg(hwndDrivesList, | 
|---|
|  | 1698 | LM_INSERTITEM, | 
|---|
|  | 1699 | MPFROM2SHORT(LIT_SORTASCENDING, 0), | 
|---|
|  | 1700 | MPFROMP(pci->pszFileName)); | 
|---|
|  | 1701 | } | 
|---|
|  | 1702 | else { | 
|---|
|  | 1703 | WinSendMsg(hwndCnr, | 
|---|
|  | 1704 | CM_INVALIDATERECORD, | 
|---|
|  | 1705 | MPFROMP(&pci), | 
|---|
|  | 1706 | MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION)); | 
|---|
|  | 1707 | WinSendMsg(hwndDrivesList, | 
|---|
|  | 1708 | LM_INSERTITEM, | 
|---|
|  | 1709 | MPFROM2SHORT(LIT_SORTASCENDING, 0), | 
|---|
|  | 1710 | MPFROMP(pci->pszFileName)); | 
|---|
| [1335] | 1711 | } | 
|---|
| [1402] | 1712 | //fDrivetoSkip[drvNum] = FALSE; | 
|---|
| [739] | 1713 | } | 
|---|
| [1250] | 1714 | pci = pciNext; | 
|---|
|  | 1715 | } // while | 
|---|
| [1326] | 1716 | StubbyScanCount--; | 
|---|
| [1299] | 1717 | } | 
|---|
| [739] | 1718 | if (hwndParent) | 
|---|
|  | 1719 | WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent, QW_PARENT), | 
|---|
|  | 1720 | MAIN_DRIVELIST), LM_SELECTITEM, | 
|---|
|  | 1721 | MPFROM2SHORT(0, 0), MPFROMLONG(TRUE)); | 
|---|
| [2] | 1722 |  | 
|---|
| [739] | 1723 | pci = (PCNRITEM) WinSendMsg(hwndCnr, | 
|---|
|  | 1724 | CM_QUERYRECORD, | 
|---|
|  | 1725 | MPVOID, | 
|---|
|  | 1726 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | 
|---|
| [762] | 1727 | while (pci && (INT)pci != -1) { | 
|---|
| [739] | 1728 | pciNext = (PCNRITEM) WinSendMsg(hwndCnr, | 
|---|
| [551] | 1729 | CM_QUERYRECORD, | 
|---|
|  | 1730 | MPFROMP(pci), | 
|---|
| [739] | 1731 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); | 
|---|
|  | 1732 | if (pci->flags & RECFLAGS_ENV) { | 
|---|
| [551] | 1733 | pci = (PCNRITEM) WinSendMsg(hwndCnr, | 
|---|
|  | 1734 | CM_QUERYRECORD, | 
|---|
|  | 1735 | MPFROMP(pci), | 
|---|
| [739] | 1736 | MPFROM2SHORT(CMA_FIRSTCHILD, | 
|---|
|  | 1737 | CMA_ITEMORDER)); | 
|---|
| [762] | 1738 | while (pci && (INT)pci != -1) { | 
|---|
| [739] | 1739 | if (pci->flags & RECFLAGS_ENV) | 
|---|
|  | 1740 | FleshEnv(hwndCnr, pci); | 
|---|
|  | 1741 | pci = (PCNRITEM) WinSendMsg(hwndCnr, | 
|---|
|  | 1742 | CM_QUERYRECORD, | 
|---|
|  | 1743 | MPFROMP(pci), | 
|---|
|  | 1744 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); | 
|---|
|  | 1745 | } | 
|---|
|  | 1746 | break; | 
|---|
| [2] | 1747 | } | 
|---|
| [739] | 1748 | pci = (PCNRITEM) WinSendMsg(hwndCnr, | 
|---|
|  | 1749 | CM_QUERYRECORD, | 
|---|
|  | 1750 | MPFROMP(pci), | 
|---|
|  | 1751 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); | 
|---|
|  | 1752 | } | 
|---|
| [2] | 1753 |  | 
|---|
| [167] | 1754 | if (!drivesbuilt && hwndMain) | 
|---|
| [551] | 1755 | PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID); | 
|---|
| [783] | 1756 | DosSleep(16);                         // 05 Aug 07 GKY 33 | 
|---|
| [2] | 1757 | fDummy = FALSE; | 
|---|
|  | 1758 | DosPostEventSem(CompactSem); | 
|---|
| [739] | 1759 |  | 
|---|
| [2] | 1760 | { | 
|---|
|  | 1761 | BYTE info; | 
|---|
|  | 1762 | BOOL includesyours = FALSE; | 
|---|
|  | 1763 |  | 
|---|
| [917] | 1764 | // 10 Jan 08 SHL fixme to understand fFirstTime | 
|---|
| [551] | 1765 | if (*suggest || (!(driveflags[1] & DRIVE_IGNORE) && fFirstTime)) { | 
|---|
|  | 1766 | if (!DosDevConfig(&info, DEVINFO_FLOPPY) && info == 1) { | 
|---|
|  | 1767 | if (!*suggest) { | 
|---|
| [214] | 1768 | *suggest = '/'; | 
|---|
|  | 1769 | suggest[1] = 0; | 
|---|
|  | 1770 | } | 
|---|
|  | 1771 | else | 
|---|
| [551] | 1772 | memmove(suggest + 2, suggest + 1, strlen(suggest)); | 
|---|
| [214] | 1773 | suggest[1] = 'B'; | 
|---|
| [2] | 1774 | } | 
|---|
|  | 1775 | } | 
|---|
| [551] | 1776 | if (*suggest) { | 
|---|
|  | 1777 | for (x = 2; x < 26; x++) { | 
|---|
|  | 1778 | if (driveflags[x] & DRIVE_IGNORE) { | 
|---|
| [214] | 1779 | includesyours = TRUE; | 
|---|
| [551] | 1780 | sprintf(suggest + strlen(suggest), "%c", (char)(x + 'A')); | 
|---|
| [214] | 1781 | } | 
|---|
| [2] | 1782 | } | 
|---|
| [551] | 1783 | strcat(suggest, " %*"); | 
|---|
| [167] | 1784 | if (saymsg(MB_YESNO | MB_ICONEXCLAMATION, | 
|---|
| [214] | 1785 | (hwndParent) ? hwndParent : hwndCnr, | 
|---|
|  | 1786 | GetPString(IDS_SUGGESTTITLETEXT), | 
|---|
|  | 1787 | GetPString(IDS_SUGGEST1TEXT), | 
|---|
|  | 1788 | (includesyours) ? GetPString(IDS_SUGGEST2TEXT) : NullStr, | 
|---|
| [551] | 1789 | suggest) == MBID_YES) { | 
|---|
| [214] | 1790 | char s[64]; | 
|---|
| [2] | 1791 |  | 
|---|
| [214] | 1792 | sprintf(s, "PARAMETERS=%s", suggest); | 
|---|
| [551] | 1793 | WinCreateObject(WPProgram, "FM/2", s, FM3Folder, CO_UPDATEIFEXISTS); | 
|---|
| [214] | 1794 | WinCreateObject(WPProgram, | 
|---|
| [551] | 1795 | "FM/2 Lite", s, FM3Folder, CO_UPDATEIFEXISTS); | 
|---|
| [214] | 1796 | WinCreateObject(WPProgram, | 
|---|
| [551] | 1797 | "Archive Viewer/2", s, FM3Tools, CO_UPDATEIFEXISTS); | 
|---|
| [214] | 1798 | WinCreateObject(WPProgram, | 
|---|
| [551] | 1799 | "Dir Sizes", s, FM3Tools, CO_UPDATEIFEXISTS); | 
|---|
| [214] | 1800 | WinCreateObject(WPProgram, | 
|---|
| [551] | 1801 | "Visual Tree", s, FM3Tools, CO_UPDATEIFEXISTS); | 
|---|
| [214] | 1802 | WinCreateObject(WPProgram, | 
|---|
| [551] | 1803 | "Visual Directory", s, FM3Tools, CO_UPDATEIFEXISTS); | 
|---|
| [214] | 1804 | WinCreateObject(WPProgram, | 
|---|
| [551] | 1805 | "Global File Viewer", s, FM3Tools, CO_UPDATEIFEXISTS); | 
|---|
|  | 1806 | WinCreateObject(WPProgram, "Databar", s, FM3Tools, CO_UPDATEIFEXISTS); | 
|---|
| [2] | 1807 | } | 
|---|
|  | 1808 | } | 
|---|
|  | 1809 | } | 
|---|
|  | 1810 | didonce = TRUE; | 
|---|
| [1354] | 1811 | if (fInitialDriveScan) { | 
|---|
|  | 1812 | HWND hwndDrivesList = WinWindowFromID(WinQueryWindow(hwndParent, QW_PARENT), | 
|---|
|  | 1813 | MAIN_DRIVELIST); | 
|---|
|  | 1814 | while (StubbyScanCount != 0 || ProcessDirCount != 0) | 
|---|
|  | 1815 | DosSleep(50); | 
|---|
|  | 1816 | WinShowWindow(hwndCnr, TRUE); | 
|---|
|  | 1817 | WinShowWindow(hwndDrivesList, TRUE); | 
|---|
|  | 1818 | fInitialDriveScan = FALSE; | 
|---|
|  | 1819 | } | 
|---|
| [731] | 1820 | } // FillTreeCnr | 
|---|
| [743] | 1821 |  | 
|---|
|  | 1822 |  | 
|---|
|  | 1823 | /** | 
|---|
|  | 1824 | * Empty all records from a container and free associated storage and | 
|---|
|  | 1825 | * Free up field infos | 
|---|
|  | 1826 | */ | 
|---|
|  | 1827 |  | 
|---|
|  | 1828 | VOID EmptyCnr(HWND hwnd) | 
|---|
|  | 1829 | { | 
|---|
|  | 1830 | PFIELDINFO pfi; | 
|---|
|  | 1831 |  | 
|---|
| [762] | 1832 | #if 0 // fixme to be gone or to be configurable | 
|---|
| [751] | 1833 | { | 
|---|
|  | 1834 | int state = _heapchk(); | 
|---|
|  | 1835 | if (state != _HEAPOK) | 
|---|
|  | 1836 | Runtime_Error(pszSrcFile, __LINE__, "heap corrupted %d", state); | 
|---|
|  | 1837 | } | 
|---|
|  | 1838 | #endif | 
|---|
|  | 1839 |  | 
|---|
| [743] | 1840 | // Remove all records | 
|---|
|  | 1841 | RemoveCnrItems(hwnd, NULL, 0, CMA_FREE); | 
|---|
|  | 1842 |  | 
|---|
|  | 1843 | // Remove field info descriptors | 
|---|
|  | 1844 | pfi = (PFIELDINFO) WinSendMsg(hwnd, CM_QUERYDETAILFIELDINFO, MPVOID, | 
|---|
|  | 1845 | MPFROMSHORT(CMA_FIRST)); | 
|---|
| [745] | 1846 | if (pfi && | 
|---|
|  | 1847 | (INT)WinSendMsg(hwnd, CM_REMOVEDETAILFIELDINFO, MPVOID, | 
|---|
|  | 1848 | MPFROM2SHORT(0, CMA_FREE)) == -1) { | 
|---|
|  | 1849 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_REMOVEDETAILFIELDINFO hwnd %x", hwnd); | 
|---|
|  | 1850 | } | 
|---|
| [743] | 1851 | } | 
|---|
|  | 1852 |  | 
|---|
|  | 1853 | /** | 
|---|
|  | 1854 | * Free storage associated with container item | 
|---|
|  | 1855 | */ | 
|---|
|  | 1856 |  | 
|---|
| [751] | 1857 | VOID FreeCnrItemData(PCNRITEM pci) | 
|---|
| [743] | 1858 | { | 
|---|
| [1308] | 1859 | if (pci->pszSubject) { | 
|---|
|  | 1860 | if (pci->pszSubject != NullStr) | 
|---|
|  | 1861 | free(pci->pszSubject); | 
|---|
| [1174] | 1862 | pci->pszSubject = NULL;             // Catch illegal references | 
|---|
| [762] | 1863 | } | 
|---|
| [743] | 1864 |  | 
|---|
| [1174] | 1865 | // 08 Sep 08 SHL Remove excess logic | 
|---|
| [1308] | 1866 | if (pci->pszLongName) { | 
|---|
|  | 1867 | if (pci->pszLongName != NullStr) | 
|---|
|  | 1868 | free(pci->pszLongName); | 
|---|
| [1174] | 1869 | pci->pszLongName = NULL;            // Catch illegal references | 
|---|
| [762] | 1870 | } | 
|---|
| [1154] | 1871 |  | 
|---|
|  | 1872 | // Bypass free if pszDisplayName points into pszFileName buffer | 
|---|
|  | 1873 | // 05 Sep 08 SHL Correct pointer overlap compare logic | 
|---|
| [1308] | 1874 | if (pci->pszDisplayName) { | 
|---|
|  | 1875 | if (pci->pszDisplayName != NullStr) { | 
|---|
|  | 1876 | if (!pci->pszFileName || | 
|---|
|  | 1877 | pci->pszDisplayName < pci->pszFileName || | 
|---|
|  | 1878 | pci->pszDisplayName >= pci->pszFileName + _msize(pci->pszFileName)) | 
|---|
|  | 1879 | { | 
|---|
|  | 1880 | free(pci->pszDisplayName); | 
|---|
|  | 1881 | } | 
|---|
| [1154] | 1882 | } | 
|---|
| [1308] | 1883 | pci->pszDisplayName = NULL;         // Catch illegal references | 
|---|
| [1154] | 1884 | } | 
|---|
| [1113] | 1885 |  | 
|---|
| [1308] | 1886 | if (!pci->pszFileName) | 
|---|
|  | 1887 | Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting free %p data twice", pci); | 
|---|
|  | 1888 | else { | 
|---|
|  | 1889 | if (pci->pszFileName != NullStr) | 
|---|
|  | 1890 | free(pci->pszFileName); | 
|---|
|  | 1891 | pci->pszFileName = NULL;            // Catch illegal references | 
|---|
|  | 1892 | } | 
|---|
|  | 1893 |  | 
|---|
| [1299] | 1894 | // 08 Sep 08 SHL Remove excess logic | 
|---|
| [1308] | 1895 | if (pci->pszLongName) { | 
|---|
|  | 1896 | if (pci->pszLongName != NullStr) | 
|---|
|  | 1897 | free(pci->pszLongName); | 
|---|
| [1299] | 1898 | pci->pszLongName = NULL;            // Catch illegal references | 
|---|
|  | 1899 | } | 
|---|
| [1174] | 1900 |  | 
|---|
| [1308] | 1901 | if (pci->pszFmtFileSize) { | 
|---|
|  | 1902 | if (pci->pszFmtFileSize != NullStr) | 
|---|
|  | 1903 | free(pci->pszFmtFileSize); | 
|---|
| [1174] | 1904 | pci->pszFmtFileSize = NULL;         // Catch illegal references | 
|---|
| [857] | 1905 | } | 
|---|
| [743] | 1906 | } | 
|---|
|  | 1907 |  | 
|---|
|  | 1908 | /** | 
|---|
| [762] | 1909 | * Free single container item and associated storage | 
|---|
| [743] | 1910 | */ | 
|---|
|  | 1911 |  | 
|---|
| [762] | 1912 | VOID FreeCnrItem(HWND hwnd, PCNRITEM pci) | 
|---|
| [743] | 1913 | { | 
|---|
| [745] | 1914 | // DbgMsg(pszSrcFile, __LINE__, "FreeCnrItem hwnd %x pci %p", hwnd, pci); | 
|---|
|  | 1915 |  | 
|---|
| [743] | 1916 | FreeCnrItemData(pci); | 
|---|
|  | 1917 |  | 
|---|
| [762] | 1918 | if (!WinSendMsg(hwnd, CM_FREERECORD, MPFROMP(&pci), MPFROMSHORT(1))) { | 
|---|
| [773] | 1919 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
|  | 1920 | "CM_FREERECORD hwnd %x pci %p file %s", | 
|---|
| [783] | 1921 | hwnd, pci, | 
|---|
| [773] | 1922 | pci && pci->pszFileName ? pci->pszFileName : "n/a"); | 
|---|
| [743] | 1923 | } | 
|---|
|  | 1924 | } | 
|---|
|  | 1925 |  | 
|---|
|  | 1926 | /** | 
|---|
| [751] | 1927 | * Free container item list and associated storage | 
|---|
| [743] | 1928 | */ | 
|---|
|  | 1929 |  | 
|---|
| [751] | 1930 | VOID FreeCnrItemList(HWND hwnd, PCNRITEM pciFirst) | 
|---|
| [743] | 1931 | { | 
|---|
| [751] | 1932 | PCNRITEM pci = pciFirst; | 
|---|
|  | 1933 | PCNRITEM pciNext; | 
|---|
| [762] | 1934 | USHORT usCount; | 
|---|
| [751] | 1935 |  | 
|---|
| [762] | 1936 | for (usCount = 0; pci; usCount++) { | 
|---|
| [751] | 1937 | pciNext = (PCNRITEM) pci->rc.preccNextRecord; | 
|---|
| [762] | 1938 | FreeCnrItemData(pci); | 
|---|
| [751] | 1939 | pci = pciNext; | 
|---|
|  | 1940 | } | 
|---|
| [762] | 1941 |  | 
|---|
|  | 1942 | if (usCount) { | 
|---|
|  | 1943 | if (!WinSendMsg(hwnd, CM_FREERECORD, MPFROMP(&pci), MPFROMSHORT(usCount))) { | 
|---|
|  | 1944 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_FREERECORD hwnd %x pci %p cnt %u", hwnd, pci, usCount); | 
|---|
|  | 1945 | } | 
|---|
|  | 1946 | } | 
|---|
| [751] | 1947 | } | 
|---|
|  | 1948 |  | 
|---|
|  | 1949 | /** | 
|---|
|  | 1950 | * Remove item(s) from container and free associated storage if requested | 
|---|
| [762] | 1951 | * @param pciFirst points to first item to remove or NULL to remove all | 
|---|
|  | 1952 | * @param usCnt is remove count or 0 to remove all | 
|---|
| [751] | 1953 | * @returns count of items remaining in container or -1 if error | 
|---|
|  | 1954 | */ | 
|---|
|  | 1955 |  | 
|---|
| [762] | 1956 | INT RemoveCnrItems(HWND hwnd, PCNRITEM pciFirst, USHORT usCnt, USHORT usFlags) | 
|---|
| [751] | 1957 | { | 
|---|
| [762] | 1958 | INT remaining = usCnt; | 
|---|
|  | 1959 | PCNRITEM pci; | 
|---|
| [751] | 1960 |  | 
|---|
| [762] | 1961 | if ((usCnt && !pciFirst) || (!usCnt && pciFirst)) { | 
|---|
|  | 1962 | Runtime_Error(pszSrcFile, __LINE__, "pciFirst %p usCnt %u mismatch", pciFirst, usCnt); | 
|---|
| [751] | 1963 | remaining = -1; | 
|---|
| [762] | 1964 | } | 
|---|
|  | 1965 | else { | 
|---|
|  | 1966 | // Free our buffers if free requested | 
|---|
|  | 1967 | if (usFlags & CMA_FREE) { | 
|---|
|  | 1968 | if (pciFirst) | 
|---|
|  | 1969 | pci = pciFirst; | 
|---|
|  | 1970 | else { | 
|---|
| [743] | 1971 | pci = (PCNRITEM)WinSendMsg(hwnd, CM_QUERYRECORD, MPVOID, | 
|---|
| [744] | 1972 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | 
|---|
| [762] | 1973 | if ((INT)pci == -1) { | 
|---|
| [744] | 1974 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_QUERYRECORD"); | 
|---|
| [751] | 1975 | remaining = -1; | 
|---|
| [762] | 1976 | pci = NULL; | 
|---|
|  | 1977 | } | 
|---|
|  | 1978 | } | 
|---|
|  | 1979 | while (pci) { | 
|---|
| [850] | 1980 | // 12 Sep 07 SHL dwg drivebar crash testing - ticket# ??? | 
|---|
| [1174] | 1981 | static PCNRITEM pciLast;        // 12 Sep 07 SHL | 
|---|
| [907] | 1982 | ULONG ulSize = sizeof(*pci); | 
|---|
|  | 1983 | ULONG ulAttr; | 
|---|
| [850] | 1984 | APIRET apiret = DosQueryMem((PVOID)pci, &ulSize, &ulAttr); | 
|---|
|  | 1985 | if (apiret) | 
|---|
| [907] | 1986 | Dos_Error(MB_ENTER, apiret, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| [850] | 1987 | "DosQueryMem failed pci %p pciLast %p", pci, pciLast); | 
|---|
| [1308] | 1988 | FreeCnrItemData(pci); | 
|---|
| [850] | 1989 | pciLast = pci; | 
|---|
| [762] | 1990 | pci = (PCNRITEM)pci->rc.preccNextRecord; | 
|---|
|  | 1991 | if (remaining && --remaining == 0) | 
|---|
| [744] | 1992 | break; | 
|---|
| [762] | 1993 | } | 
|---|
| [743] | 1994 | } | 
|---|
|  | 1995 | } | 
|---|
| [745] | 1996 |  | 
|---|
| [762] | 1997 | // DbgMsg(pszSrcFile, __LINE__, "RemoveCnrItems %p %u %s", pci, usCnt, pci->pszFileName); | 
|---|
| [743] | 1998 |  | 
|---|
| [762] | 1999 | if (remaining != - 1) { | 
|---|
|  | 2000 | remaining = (INT)WinSendMsg(hwnd, CM_REMOVERECORD, MPFROMP(&pciFirst), MPFROM2SHORT(usCnt, usFlags)); | 
|---|
| [751] | 2001 | if (remaining == -1) { | 
|---|
| [762] | 2002 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_REMOVERECORD hwnd %x pci %p cnt %u", hwnd, pciFirst, usCnt); | 
|---|
| [743] | 2003 | } | 
|---|
|  | 2004 | } | 
|---|
| [762] | 2005 |  | 
|---|
| [751] | 2006 | return remaining; | 
|---|
| [743] | 2007 | } | 
|---|
|  | 2008 |  | 
|---|
| [783] | 2009 | #pragma alloc_text(FILLDIR,FillInRecordFromFFB,FillInRecordFromFSA,IDFile) | 
|---|
| [1299] | 2010 | #pragma alloc_text(FILLDIR1,ProcessDirectory,FillDirCnr,FillTreeCnr,FileAttrToString,StubbyScanThread) | 
|---|
| [783] | 2011 | #pragma alloc_text(EMPTYCNR,EmptyCnr,FreeCnrItemData,FreeCnrItem,FreeCnrItemList,RemoveCnrItems) | 
|---|
|  | 2012 |  | 
|---|