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