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