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