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