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