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