[145] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: flesh.c 1505 2010-04-11 22:29:56Z gyoung $
|
---|
| 5 |
|
---|
| 6 | Flesh
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1498] | 9 | Copyright (c) 2005, 2010 Steven H. Levine
|
---|
[145] | 10 |
|
---|
| 11 | 24 May 05 SHL Rework Win_Error usage
|
---|
[166] | 12 | 25 May 05 SHL Rework for ProcessDirectory
|
---|
[284] | 13 | 28 May 05 SHL Clean while reading code
|
---|
| 14 | 24 Oct 05 SHL Delete obsolete code
|
---|
[340] | 15 | 22 Jul 06 SHL Check more run time errors
|
---|
[515] | 16 | 19 Oct 06 SHL Stubby - correct . and .. detect
|
---|
[574] | 17 | 22 Mar 07 GKY Use QWL_USER
|
---|
[751] | 18 | 01 Aug 07 SHL Sync with CNRITEM mods
|
---|
[775] | 19 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
|
---|
[793] | 20 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[985] | 21 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
[1299] | 22 | 24 Nov 08 GKY remove redundant code and minor speed up of Stubby
|
---|
[1358] | 23 | 25 Dec 08 GKY Add ProcessDirectoryThread to allow optional recursive drive scan at startup.
|
---|
| 24 | 25 Dec 08 GKY Add DRIVE_RSCANNED flag to monitor for the first recursive drive scan per session
|
---|
[1471] | 25 | to prevent duplicate directory names in tree following a copy before initial scan.
|
---|
[1400] | 26 | 08 Mar 09 GKY Additional strings move to PCSZs in init.c
|
---|
[1482] | 27 | 13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
|
---|
| 28 | profile calls for user settings that work and are setable in more than one
|
---|
| 29 | miniapp; FM3Str should be used for setting only relavent to FM/2 or that
|
---|
| 30 | aren't user settable; realappname should be used for setting applicable to
|
---|
| 31 | one or more miniapp but not to FM/2
|
---|
[1498] | 32 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
|
---|
[145] | 33 |
|
---|
| 34 | ***********************************************************************/
|
---|
| 35 |
|
---|
[907] | 36 | #include <stdlib.h>
|
---|
| 37 | #include <string.h>
|
---|
| 38 | #include <ctype.h>
|
---|
| 39 |
|
---|
[2] | 40 | #define INCL_DOS
|
---|
| 41 | #define INCL_DOSERRORS
|
---|
| 42 | #define INCL_WIN
|
---|
[907] | 43 | #define INCL_LONGLONG // dircnrs.h
|
---|
[2] | 44 |
|
---|
[1177] | 45 | #include "fm3dll.h"
|
---|
[1207] | 46 | #include "draglist.h" // Data declaration(s)
|
---|
| 47 | #include "notebook.h" // Data declaration(s)
|
---|
| 48 | #include "info.h" // Data declaration(s)
|
---|
| 49 | #include "init.h" // Data declaration(s)
|
---|
| 50 | #include "mainwnd.h" // Data declaration(s)
|
---|
[907] | 51 | #include "fm3str.h"
|
---|
| 52 | #include "filldir.h" // FileAttrToString...
|
---|
| 53 | #include "errutil.h" // Dos_Error...
|
---|
| 54 | #include "strutil.h" // GetPString
|
---|
[1155] | 55 | #include "flesh.h"
|
---|
| 56 | #include "valid.h" // IsValidDir
|
---|
| 57 | #include "misc.h" // LoadLibPath
|
---|
[1177] | 58 | #include "findrec.h" // FindCnrRecord
|
---|
| 59 | #include "notify.h" // Notify
|
---|
| 60 | #include "wrappers.h" // xfree
|
---|
[1354] | 61 | #include "excputil.h" // xbeginthread
|
---|
[2] | 62 |
|
---|
[1207] | 63 | // Data definitions
|
---|
[2] | 64 | #pragma data_seg(DATA1)
|
---|
[340] | 65 |
|
---|
| 66 | static PSZ pszSrcFile = __FILE__;
|
---|
| 67 |
|
---|
[1207] | 68 | #pragma data_seg(GLOBAL1)
|
---|
| 69 | ULONG NoBrokenNotify;
|
---|
| 70 | BOOL fFilesInTree;
|
---|
| 71 |
|
---|
[551] | 72 | BOOL FleshEnv(HWND hwndCnr, PCNRITEM pciParent)
|
---|
[175] | 73 | {
|
---|
[551] | 74 | PCNRITEM pciL;
|
---|
[2] | 75 | DIRCNRDATA *dcd;
|
---|
[551] | 76 | CHAR path[CCHMAXPATH + 12],
|
---|
| 77 | fullpath[CCHMAXPATH + 12], *env, *p, *pp, *var = NULL;
|
---|
[2] | 78 |
|
---|
[551] | 79 | if (!pciParent || (INT) pciParent == -1 || !hwndCnr)
|
---|
[2] | 80 | return FALSE;
|
---|
[574] | 81 | dcd = (DIRCNRDATA *) WinQueryWindowPtr(hwndCnr, QWL_USER);
|
---|
[551] | 82 | if (!dcd)
|
---|
[2] | 83 | return FALSE;
|
---|
| 84 |
|
---|
[730] | 85 | strcpy(path, pciParent->pszFileName + 1);
|
---|
[551] | 86 | if (stricmp(path, GetPString(IDS_ENVVARSTEXT) + 1))
|
---|
| 87 | UnFlesh(hwndCnr, pciParent);
|
---|
| 88 | if (*path) {
|
---|
[2] | 89 | path[strlen(path) - 1] = 0;
|
---|
[1400] | 90 | if (!stricmp(path, PCSZ_LIBPATH)) {
|
---|
[551] | 91 | var = xmalloc(65536, pszSrcFile, __LINE__);
|
---|
| 92 | if (var)
|
---|
| 93 | LoadLibPath(var, 65536);
|
---|
[2] | 94 | env = var;
|
---|
| 95 | }
|
---|
| 96 | else
|
---|
| 97 | env = getenv(path);
|
---|
[551] | 98 | if (env && *env) {
|
---|
[2] | 99 | p = env;
|
---|
[551] | 100 | while (*p) {
|
---|
| 101 | pp = path;
|
---|
| 102 | while (*p == ';')
|
---|
| 103 | p++;
|
---|
| 104 | while (*p && *p != ';') {
|
---|
| 105 | *pp = *p;
|
---|
| 106 | p++;
|
---|
| 107 | pp++;
|
---|
| 108 | }
|
---|
| 109 | *pp = 0;
|
---|
| 110 | if (*path &&
|
---|
| 111 | strcmp(path, ".") &&
|
---|
| 112 | strcmp(path, ".\\") &&
|
---|
| 113 | strcmp(path, "..") &&
|
---|
| 114 | strcmp(path, "..\\") &&
|
---|
| 115 | strncmp(path, ".\\", 2) && strncmp(path, "..\\", 3)) {
|
---|
| 116 | if (!DosQueryPathInfo(path,
|
---|
| 117 | FIL_QUERYFULLNAME,
|
---|
| 118 | fullpath,
|
---|
| 119 | sizeof(fullpath)) && IsValidDir(fullpath)) {
|
---|
| 120 | pciL = FindCnrRecord(hwndCnr,
|
---|
| 121 | fullpath, pciParent, FALSE, FALSE, FALSE);
|
---|
| 122 | if (pciL) {
|
---|
| 123 | while (pciL && pciL != (PCNRITEM) - 1 && pciL != pciParent)
|
---|
| 124 | pciL = WinSendMsg(hwndCnr,
|
---|
| 125 | CM_QUERYRECORD,
|
---|
| 126 | MPFROMP(pciL),
|
---|
| 127 | MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
|
---|
| 128 | }
|
---|
| 129 | if (!pciL) {
|
---|
[2] | 130 |
|
---|
[551] | 131 | RECORDINSERT ri;
|
---|
[2] | 132 |
|
---|
[551] | 133 | pciL = WinSendMsg(hwndCnr,
|
---|
| 134 | CM_ALLOCRECORD,
|
---|
[751] | 135 | MPFROMLONG(EXTRA_RECORD_BYTES),
|
---|
[551] | 136 | MPFROMLONG(1));
|
---|
| 137 | if (pciL) {
|
---|
[730] | 138 | pciL->pszFileName = xstrdup(fullpath, pszSrcFile, __LINE__);
|
---|
[751] | 139 | pciL->rc.pszIcon = pciL->pszFileName;
|
---|
[551] | 140 | if (!fNoIconsDirs &&
|
---|
| 141 | (!isalpha(*fullpath) ||
|
---|
| 142 | !(driveflags[toupper(*fullpath) - 'A'] &
|
---|
| 143 | DRIVE_NOLOADICONS)))
|
---|
| 144 | pciL->rc.hptrIcon = WinLoadFileIcon(fullpath, FALSE);
|
---|
| 145 | if (!pciL->rc.hptrIcon)
|
---|
| 146 | pciL->rc.hptrIcon = hptrDir;
|
---|
| 147 | pciL->attrFile = FILE_DIRECTORY;
|
---|
[751] | 148 | pciL->pszDispAttr = FileAttrToString(pciL->attrFile);
|
---|
[551] | 149 | memset(&ri, 0, sizeof(ri));
|
---|
| 150 | ri.cb = sizeof(ri);
|
---|
| 151 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
| 152 | ri.pRecordParent = (PRECORDCORE) pciParent;
|
---|
| 153 | ri.zOrder = (ULONG) CMA_TOP;
|
---|
| 154 | ri.cRecordsInsert = 1;
|
---|
| 155 | ri.fInvalidateRecord = FALSE;
|
---|
| 156 | if (!WinSendMsg(hwndCnr,
|
---|
| 157 | CM_INSERTRECORD, MPFROMP(pciL), MPFROMP(&ri)))
|
---|
[751] | 158 | FreeCnrItem(hwndCnr, pciL);
|
---|
[551] | 159 | }
|
---|
| 160 | }
|
---|
| 161 | }
|
---|
| 162 | }
|
---|
[2] | 163 | }
|
---|
| 164 | }
|
---|
[1009] | 165 | xfree(var, pszSrcFile, __LINE__);
|
---|
[551] | 166 | pciL = (PCNRITEM) WinSendMsg(hwndCnr,
|
---|
| 167 | CM_QUERYRECORD,
|
---|
| 168 | MPFROMP(pciParent),
|
---|
| 169 | MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
|
---|
| 170 | while (pciL && (INT) pciL != -1) {
|
---|
[2] | 171 | pciL->flags |= (RECFLAGS_NODRAG | RECFLAGS_UNDERENV);
|
---|
| 172 | WinSendMsg(hwndCnr,
|
---|
[551] | 173 | CM_INVALIDATERECORD, MPFROMP(&pciL), MPFROM2SHORT(1, 0));
|
---|
[2] | 174 | pciL = WinSendMsg(hwndCnr,
|
---|
[551] | 175 | CM_QUERYRECORD,
|
---|
| 176 | MPFROMP(pciL), MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
[2] | 177 | }
|
---|
| 178 | }
|
---|
| 179 | return TRUE;
|
---|
| 180 | }
|
---|
| 181 |
|
---|
[551] | 182 | BOOL Flesh(HWND hwndCnr, PCNRITEM pciParent)
|
---|
[166] | 183 | {
|
---|
[551] | 184 | PCNRITEM pciL;
|
---|
[2] | 185 | DIRCNRDATA *dcd;
|
---|
[551] | 186 | BOOL includefiles = fFilesInTree;
|
---|
[2] | 187 |
|
---|
[551] | 188 | if (!pciParent || (INT) pciParent == -1 || !hwndCnr)
|
---|
[2] | 189 | return FALSE;
|
---|
[551] | 190 | pciL = (PCNRITEM) WinSendMsg(hwndCnr,
|
---|
| 191 | CM_QUERYRECORD,
|
---|
| 192 | MPFROMP(pciParent),
|
---|
| 193 | MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
|
---|
[730] | 194 | if (!pciL || !*pciL->pszFileName) {
|
---|
[751] | 195 | if (pciL && (INT) pciL != -1)
|
---|
| 196 | RemoveCnrItems(hwndCnr, pciL, 1, CMA_FREE);
|
---|
[2] | 197 | dcd = INSTDATA(hwndCnr);
|
---|
[166] | 198 | if (dcd && dcd->size != sizeof(DIRCNRDATA))
|
---|
[2] | 199 | dcd = NULL;
|
---|
[730] | 200 | if (driveflags[toupper(*pciParent->pszFileName) - 'A'] &
|
---|
[551] | 201 | DRIVE_INCLUDEFILES)
|
---|
[2] | 202 | includefiles = TRUE;
|
---|
[1354] | 203 | if (fInitialDriveScan) {
|
---|
| 204 | PROCESSDIR *ProcessDir;
|
---|
| 205 |
|
---|
| 206 | ProcessDir = xmallocz(sizeof(PROCESSDIR), pszSrcFile, __LINE__);
|
---|
| 207 | if (!ProcessDir)
|
---|
[1471] | 208 | return FALSE;
|
---|
[1354] | 209 | ProcessDir->hwndCnr = hwndCnr;
|
---|
| 210 | ProcessDir->pciParent = pciParent;
|
---|
| 211 | ProcessDir->szDirBase = pciParent->pszFileName;
|
---|
| 212 | ProcessDir->filestoo = includefiles;
|
---|
| 213 | ProcessDir->recurse = TRUE;
|
---|
| 214 | ProcessDir->partial = TRUE;
|
---|
| 215 | ProcessDir->stopflag = NULL;
|
---|
| 216 | ProcessDir->dcd = dcd;
|
---|
| 217 | ProcessDir->pulTotalFiles = NULL;
|
---|
| 218 | ProcessDir->pullTotalBytes = NULL;
|
---|
| 219 |
|
---|
| 220 | if (xbeginthread(ProcessDirectoryThread,
|
---|
[1471] | 221 | 65536,
|
---|
| 222 | ProcessDir,
|
---|
| 223 | pszSrcFile,
|
---|
| 224 | __LINE__) == -1)
|
---|
[1354] | 225 | {
|
---|
[1471] | 226 | xfree(ProcessDir, pszSrcFile, __LINE__);
|
---|
[1354] | 227 | }
|
---|
| 228 | }
|
---|
[1471] | 229 | else {
|
---|
[1354] | 230 | ProcessDirectory(hwndCnr,
|
---|
[1471] | 231 | pciParent,
|
---|
| 232 | pciParent->pszFileName,
|
---|
| 233 | includefiles, // filestoo
|
---|
| 234 | TRUE, // recurse
|
---|
| 235 | TRUE, // partial
|
---|
| 236 | NULL, // stop flag
|
---|
| 237 | dcd,
|
---|
| 238 | NULL, // total files
|
---|
| 239 | NULL); // total bytes
|
---|
[1354] | 240 | }
|
---|
[2] | 241 | }
|
---|
[1354] | 242 | driveflags[*pciParent->pszFileName - 'A'] |= DRIVE_RSCANNED;
|
---|
[2] | 243 | return TRUE;
|
---|
| 244 | }
|
---|
| 245 |
|
---|
[551] | 246 | BOOL UnFlesh(HWND hwndCnr, PCNRITEM pciParent)
|
---|
[175] | 247 | {
|
---|
[551] | 248 | BOOL ret = FALSE;
|
---|
[2] | 249 | PCNRITEM pciL;
|
---|
| 250 |
|
---|
[175] | 251 | if (!pciParent || !hwndCnr)
|
---|
[2] | 252 | return FALSE;
|
---|
[551] | 253 | for (;;) {
|
---|
| 254 | pciL = (PCNRITEM) WinSendMsg(hwndCnr,
|
---|
| 255 | CM_QUERYRECORD,
|
---|
| 256 | MPFROMP(pciParent),
|
---|
| 257 | MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
|
---|
| 258 | if (pciL && (INT) pciL != -1) {
|
---|
[2] | 259 | ret = TRUE;
|
---|
[751] | 260 | RemoveCnrItems(hwndCnr, pciL, 1, CMA_FREE);
|
---|
[2] | 261 | }
|
---|
| 262 | else
|
---|
| 263 | break;
|
---|
| 264 | }
|
---|
[551] | 265 | if (ret) {
|
---|
[2] | 266 | WinSendMsg(hwndCnr,
|
---|
[551] | 267 | CM_INVALIDATERECORD,
|
---|
| 268 | MPFROMP(&pciParent),
|
---|
| 269 | MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
|
---|
[175] | 270 | }
|
---|
[2] | 271 | return ret;
|
---|
| 272 | }
|
---|
| 273 |
|
---|
[1482] | 274 | #define DDEPTH 64
|
---|
[2] | 275 |
|
---|
[1471] | 276 | /**
|
---|
| 277 | * Fill in drive tree subtree
|
---|
| 278 | * @return TRUE if OK, else FALSE
|
---|
| 279 | */
|
---|
| 280 |
|
---|
[551] | 281 | BOOL Stubby(HWND hwndCnr, PCNRITEM pciParent)
|
---|
[175] | 282 | {
|
---|
[1409] | 283 | /**
|
---|
[2] | 284 | * this code is full of workarounds for screwed up LANs.
|
---|
| 285 | * let's hope all the current LAN programmers fall into
|
---|
| 286 | * a black hole and make way for people who can get it right...
|
---|
| 287 | */
|
---|
| 288 |
|
---|
[1471] | 289 | BOOL ok = FALSE;
|
---|
[847] | 290 | FILEFINDBUF3 ffb[DDEPTH];
|
---|
| 291 | PFILEFINDBUF3 pffb;
|
---|
[551] | 292 | HDIR hDir = HDIR_CREATE;
|
---|
[761] | 293 | ULONG nm, ulM = 1, total = 0, fl = MUST_HAVE_DIRECTORY;
|
---|
[551] | 294 | CHAR str[CCHMAXPATH];
|
---|
| 295 | register INT len;
|
---|
| 296 | APIRET rc, prc;
|
---|
| 297 | BOOL isadir = FALSE, isremote = FALSE, includefiles = fFilesInTree;
|
---|
[1482] | 298 | ULONG ddepth = DDEPTH;
|
---|
[1299] | 299 | ULONG drvNum;
|
---|
| 300 | ULONG flags;
|
---|
[551] | 301 | static BOOL brokenlan = FALSE, isbroken = FALSE;
|
---|
[2] | 302 |
|
---|
[730] | 303 | if (!pciParent || !*pciParent->pszFileName || !hwndCnr)
|
---|
[2] | 304 | return FALSE;
|
---|
| 305 |
|
---|
[730] | 306 | len = strlen(pciParent->pszFileName);
|
---|
| 307 | memcpy(str, pciParent->pszFileName, len + 1);
|
---|
[551] | 308 | if (str[len - 1] != '\\')
|
---|
[2] | 309 | str[len++] = '\\';
|
---|
| 310 | str[len++] = '*';
|
---|
| 311 | str[len] = 0;
|
---|
| 312 |
|
---|
[551] | 313 | if (!isalpha(*str) || str[1] != ':' || str[2] != '\\')
|
---|
[2] | 314 | MakeFullName(str);
|
---|
| 315 |
|
---|
[1299] | 316 | drvNum = toupper(*pciParent->pszFileName) - 'A';
|
---|
| 317 | flags = driveflags[drvNum];
|
---|
[551] | 318 | if (!isalpha(*str) ||
|
---|
| 319 | str[1] != ':' ||
|
---|
[1299] | 320 | str[2] != '\\' || ((flags & DRIVE_IGNORE)))
|
---|
[1471] | 321 | return FALSE; // Not a directory
|
---|
[2] | 322 |
|
---|
[1299] | 323 | if (flags & DRIVE_INCLUDEFILES)
|
---|
[2] | 324 | includefiles = TRUE;
|
---|
| 325 |
|
---|
[1299] | 326 | if (flags & DRIVE_REMOTE)
|
---|
[2] | 327 | isremote = TRUE;
|
---|
| 328 |
|
---|
[551] | 329 | if (isremote) {
|
---|
| 330 | if (fRemoteBug) {
|
---|
| 331 | if (brokenlan) {
|
---|
| 332 | ddepth = (ULONG) - 1;
|
---|
| 333 | ddepth--;
|
---|
[2] | 334 | }
|
---|
[761] | 335 | ulM = 1;
|
---|
[2] | 336 | }
|
---|
| 337 | }
|
---|
[551] | 338 | else if (isbroken)
|
---|
[2] | 339 | ddepth = 14;
|
---|
| 340 |
|
---|
[1482] | 341 | if (!fRemoteBug)
|
---|
| 342 | ulM = (ddepth <= DDEPTH) ? ddepth : 1;
|
---|
[2] | 343 |
|
---|
| 344 | nm = ulM;
|
---|
| 345 |
|
---|
| 346 | DosError(FERR_DISABLEHARDERR);
|
---|
[551] | 347 | if (includefiles)
|
---|
[2] | 348 | fl = FILE_DIRECTORY;
|
---|
[847] | 349 | rc = DosFindFirst(str,
|
---|
| 350 | &hDir,
|
---|
| 351 | FILE_NORMAL | fl |
|
---|
| 352 | FILE_READONLY | FILE_ARCHIVED |
|
---|
| 353 | FILE_SYSTEM | FILE_HIDDEN,
|
---|
| 354 | &ffb, ulM * sizeof(FILEFINDBUF3), &nm, FIL_STANDARD);
|
---|
[761] | 355 | if (ulM == 1 && !rc) {
|
---|
[2] | 356 | do {
|
---|
| 357 | pffb = &ffb[0];
|
---|
[551] | 358 | if (!includefiles && !(pffb->attrFile & FILE_DIRECTORY) && !brokenlan) {
|
---|
| 359 | brokenlan = TRUE;
|
---|
[847] | 360 | ddepth = (ULONG) - 1;
|
---|
[551] | 361 | ddepth--;
|
---|
| 362 | if (!NoBrokenNotify) {
|
---|
| 363 | prc = saymsg(MB_YESNO | MB_ICONEXCLAMATION,
|
---|
| 364 | HWND_DESKTOP,
|
---|
| 365 | GetPString(IDS_LANERRORTITLETEXT),
|
---|
| 366 | GetPString(IDS_LANERRORTEXT));
|
---|
| 367 | if (prc == MBID_NO) {
|
---|
| 368 | saymsg(MB_ENTER,
|
---|
| 369 | HWND_DESKTOP,
|
---|
| 370 | GetPString(IDS_LANERROR2TITLETEXT),
|
---|
| 371 | GetPString(IDS_LANERROR2TEXT));
|
---|
[847] | 372 | NoBrokenNotify = 255;
|
---|
[1505] | 373 | PrfWriteProfileData(fmprof, FM3Str, "NoBrokenNotify",
|
---|
[551] | 374 | &NoBrokenNotify, sizeof(ULONG));
|
---|
| 375 | }
|
---|
| 376 | }
|
---|
| 377 | else {
|
---|
| 378 | NoBrokenNotify--;
|
---|
[1505] | 379 | PrfWriteProfileData(fmprof, FM3Str, "NoBrokenNotify",
|
---|
[551] | 380 | &NoBrokenNotify, sizeof(ULONG));
|
---|
| 381 | }
|
---|
[2] | 382 | }
|
---|
[515] | 383 | if (*pffb->achName &&
|
---|
[551] | 384 | (includefiles || (pffb->attrFile & FILE_DIRECTORY)) &&
|
---|
[515] | 385 | // Skip . and ..
|
---|
[551] | 386 | (pffb->achName[0] != '.' ||
|
---|
[515] | 387 | (pffb->achName[1] &&
|
---|
[551] | 388 | (pffb->achName[1] != '.' || pffb->achName[2])))) {
|
---|
| 389 | DosFindClose(hDir);
|
---|
| 390 | isadir = TRUE;
|
---|
| 391 | goto Interruptus;
|
---|
[2] | 392 | }
|
---|
[761] | 393 | nm = 1;
|
---|
[2] | 394 | DosError(FERR_DISABLEHARDERR);
|
---|
[1482] | 395 | }
|
---|
| 396 | while (++total < ddepth && !(rc = (DosFindNext(hDir,
|
---|
| 397 | &ffb,
|
---|
| 398 | sizeof(FILEFINDBUF3),
|
---|
| 399 | &nm))));
|
---|
| 400 | DosFindClose(hDir);
|
---|
[1471] | 401 | // If drive B:
|
---|
[730] | 402 | if (toupper(*pciParent->pszFileName) > 'B' &&
|
---|
[751] | 403 | (*(pciParent->pszFileName + 1)) == ':' &&
|
---|
[730] | 404 | (*(pciParent->pszFileName + 2)) == '\\' && !(*(pciParent->pszFileName + 3))) {
|
---|
[2] | 405 |
|
---|
| 406 | CHAR s[132];
|
---|
| 407 | sprintf(s,
|
---|
[551] | 408 | GetPString(IDS_NOSUBDIRSTEXT),
|
---|
[730] | 409 | total, toupper(*pciParent->pszFileName));
|
---|
[551] | 410 | if (rc && rc != ERROR_NO_MORE_FILES)
|
---|
| 411 | sprintf(&s[strlen(s)], GetPString(IDS_SEARCHERRORTEXT), rc, str);
|
---|
[847] | 412 | else if (ddepth < 16)
|
---|
[551] | 413 | brokenlan = TRUE;
|
---|
[2] | 414 | Notify(s);
|
---|
| 415 | }
|
---|
| 416 | goto None;
|
---|
| 417 | }
|
---|
| 418 |
|
---|
[551] | 419 | if (!rc) {
|
---|
[2] | 420 | DosFindClose(hDir);
|
---|
[551] | 421 | if (nm) {
|
---|
[1353] | 422 | PBYTE fb = (PBYTE)&ffb[0];
|
---|
[551] | 423 | for (len = 0; len < nm; len++) {
|
---|
[847] | 424 | pffb = (PFILEFINDBUF3) fb;
|
---|
[551] | 425 | if (!includefiles && !(pffb->attrFile & FILE_DIRECTORY)) {
|
---|
| 426 | if (!isbroken) {
|
---|
| 427 | isbroken = TRUE;
|
---|
| 428 | if (!NoBrokenNotify) {
|
---|
| 429 | prc = saymsg(MB_YESNO | MB_ICONEXCLAMATION,
|
---|
| 430 | HWND_DESKTOP,
|
---|
| 431 | GetPString(IDS_FSDERRORTITLETEXT),
|
---|
| 432 | GetPString(IDS_FSDERRORTEXT),
|
---|
[1471] | 433 | isremote ? GetPString(IDS_REMOTETEXT) :
|
---|
| 434 | GetPString(IDS_LOCALTEXT),
|
---|
| 435 | *str);
|
---|
[551] | 436 | if (prc == MBID_NO) {
|
---|
| 437 | saymsg(MB_ENTER,
|
---|
| 438 | HWND_DESKTOP,
|
---|
| 439 | GetPString(IDS_FSDERROR2TITLETEXT),
|
---|
| 440 | GetPString(IDS_FSDERROR2TEXT));
|
---|
[847] | 441 | NoBrokenNotify = 255;
|
---|
[1505] | 442 | PrfWriteProfileData(fmprof, FM3Str, "NoBrokenNotify",
|
---|
[551] | 443 | &NoBrokenNotify, sizeof(ULONG));
|
---|
| 444 | }
|
---|
| 445 | }
|
---|
| 446 | else {
|
---|
| 447 | NoBrokenNotify--;
|
---|
[1505] | 448 | PrfWriteProfileData(fmprof, FM3Str, "NoBrokenNotify",
|
---|
[551] | 449 | &NoBrokenNotify, sizeof(ULONG));
|
---|
| 450 | }
|
---|
| 451 | }
|
---|
| 452 | }
|
---|
| 453 | if (*pffb->achName &&
|
---|
| 454 | (includefiles || (pffb->attrFile & FILE_DIRECTORY)) &&
|
---|
[515] | 455 | // Skip . and ..
|
---|
[551] | 456 | (pffb->achName[0] != '.' || (pffb->achName[1]
|
---|
| 457 | && (pffb->achName[1] != '.'
|
---|
| 458 | || pffb->achName[2])))) {
|
---|
| 459 | isadir = TRUE;
|
---|
| 460 | break;
|
---|
| 461 | }
|
---|
| 462 | fb += pffb->oNextEntryOffset;
|
---|
[1353] | 463 | } // for
|
---|
[2] | 464 |
|
---|
[551] | 465 | Interruptus:
|
---|
[2] | 466 |
|
---|
[551] | 467 | if (isadir) {
|
---|
[2] | 468 |
|
---|
[1471] | 469 | PCNRITEM pci;
|
---|
[2] | 470 |
|
---|
[1471] | 471 | if (WinIsWindow((HAB)0, hwndCnr)) {
|
---|
| 472 | pci = WinSendMsg(hwndCnr,
|
---|
| 473 | CM_ALLOCRECORD,
|
---|
| 474 | MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(1));
|
---|
| 475 | if (!pci) {
|
---|
| 476 | Win_Error(hwndCnr, HWND_DESKTOP, __FILE__, __LINE__,
|
---|
| 477 | GetPString(IDS_RECORDALLOCFAILEDTEXT));
|
---|
| 478 | }
|
---|
| 479 | else {
|
---|
| 480 | RECORDINSERT ri;
|
---|
| 481 | pci->pszFileName = NullStr;
|
---|
| 482 | pci->pszDisplayName = pci->pszFileName;
|
---|
| 483 | pci->rc.pszIcon = pci->pszDisplayName;
|
---|
| 484 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
| 485 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 486 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
| 487 | ri.pRecordParent = (PRECORDCORE) pciParent;
|
---|
| 488 | ri.zOrder = (ULONG) CMA_TOP;
|
---|
| 489 | ri.cRecordsInsert = 1;
|
---|
| 490 | ri.fInvalidateRecord = TRUE;
|
---|
| 491 | //DbgMsg(pszSrcFile, __LINE__, "Stubby %p CM_INSERTRECORD \"%s\" %.255s", hwndCnr, pci->pszFileName, pffb->achName); // 18 Dec 08 SHL fixme debug
|
---|
| 492 | if (!WinSendMsg(hwndCnr,
|
---|
| 493 | CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
|
---|
| 494 | DosSleep(50); //05 Aug 07 GKY 100
|
---|
| 495 | WinSetFocus(HWND_DESKTOP, hwndCnr);
|
---|
| 496 | if (WinIsWindow((HAB)0, hwndCnr)) {
|
---|
| 497 | //DbgMsg(pszSrcFile, __LINE__, "Stubby %p CM_INSERTRECORD %s", hwndCnr, pci->pszFileName); // 18 Dec 08 SHL fixme debug
|
---|
| 498 | if (!WinSendMsg(hwndCnr,
|
---|
| 499 | CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
|
---|
| 500 | Win_Error(hwndCnr, HWND_DESKTOP, __FILE__, __LINE__,
|
---|
| 501 | GetPString(IDS_RECORDINSERTFAILEDTEXT));
|
---|
| 502 | FreeCnrItem(hwndCnr, pci);
|
---|
| 503 | }
|
---|
| 504 | else
|
---|
| 505 | ok = TRUE;
|
---|
| 506 | }
|
---|
| 507 | }
|
---|
| 508 | else
|
---|
| 509 | ok = TRUE;
|
---|
| 510 | }
|
---|
| 511 | }
|
---|
[2] | 512 | }
|
---|
[551] | 513 | else if (toupper(*str) > 'B' && str[1] == ':' && str[2] == '\\' &&
|
---|
| 514 | !str[3]) {
|
---|
[2] | 515 |
|
---|
[551] | 516 | CHAR s[162];
|
---|
[2] | 517 |
|
---|
[551] | 518 | sprintf(s,
|
---|
| 519 | GetPString(IDS_NOSUBDIRS2TEXT),
|
---|
| 520 | nm,
|
---|
[730] | 521 | toupper(*pciParent->pszFileName),
|
---|
[551] | 522 | (isremote) ? GetPString(IDS_NOSUBDIRS3TEXT) : NullStr);
|
---|
| 523 | Notify(s);
|
---|
[2] | 524 | }
|
---|
| 525 | }
|
---|
| 526 | }
|
---|
[551] | 527 | else if (toupper(*str) > 'B' && rc != ERROR_NO_MORE_FILES) {
|
---|
[2] | 528 | CHAR s[CCHMAXPATH + 80];
|
---|
[551] | 529 | sprintf(s, GetPString(IDS_SEARCHERRORTEXT), rc, str);
|
---|
[2] | 530 | Notify(s);
|
---|
| 531 | }
|
---|
| 532 |
|
---|
| 533 | None:
|
---|
| 534 |
|
---|
| 535 | DosError(FERR_DISABLEHARDERR);
|
---|
[1471] | 536 | return ok;
|
---|
[2] | 537 | }
|
---|
[793] | 538 |
|
---|
[1353] | 539 | #pragma alloc_text(FLESH,Flesh,FleshEnv,UnFlesh,Stubby)
|
---|