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