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