[51] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: update.c 1890 2020-01-30 06:39:42Z stevenhl $
|
---|
| 5 |
|
---|
| 6 | Update Container record/list
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1856] | 9 | Copyright (c) 2003, 2015 Steven H. Levine
|
---|
[51] | 10 |
|
---|
[152] | 11 | 12 Feb 03 SHL Standardize EA math
|
---|
| 12 | 10 Jan 04 SHL Add some intermin large drive error avoidance
|
---|
| 13 | 25 May 05 SHL Rework for ULONGLONG
|
---|
| 14 | 25 May 05 SHL Rework for FillInRecordFromFFB
|
---|
[204] | 15 | 06 Jun 05 SHL Drop unused code
|
---|
[344] | 16 | 22 Jul 06 SHL Use wrappers
|
---|
[557] | 17 | 20 Feb 07 GKY Add SelectDriveIcon()
|
---|
| 18 | 09 Mar 07 GKY Cleanup SelectDriveIcon using "driveflag =" from Steven
|
---|
[751] | 19 | 02 Aug 07 SHL Sync with CNRITEM mods
|
---|
[793] | 20 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[1402] | 21 | 14 Mar 09 GKY Prevent execution of UM_SHOWME while drive scan is occuring
|
---|
[1444] | 22 | 22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning
|
---|
[1856] | 23 | 07 Aug 15 SHL Sync with Flesh/Stubby mods
|
---|
[1876] | 24 | 10 Oct 15 GKY Eliminate some unnecessary Flesh and UnFlesh calls
|
---|
[51] | 25 |
|
---|
| 26 | ***********************************************************************/
|
---|
| 27 |
|
---|
[907] | 28 | #include <stdlib.h>
|
---|
| 29 | #include <string.h>
|
---|
| 30 | #include <ctype.h>
|
---|
| 31 |
|
---|
[2] | 32 | #define INCL_DOS
|
---|
| 33 | #define INCL_WIN
|
---|
[152] | 34 | #define INCL_LONGLONG
|
---|
[2] | 35 |
|
---|
[1189] | 36 | #include "fm3dll.h"
|
---|
[1228] | 37 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
| 38 | #include "update.h"
|
---|
[1214] | 39 | #include "init.h" // Data declaration(s)
|
---|
| 40 | #include "notebook.h" // Data declaration(s)
|
---|
| 41 | #include "info.h" // Data declaration(s)
|
---|
| 42 | #include "newview.h" // Data declarations
|
---|
[907] | 43 | #include "fm3str.h"
|
---|
| 44 | #include "errutil.h" // Dos_Error...
|
---|
| 45 | #include "filldir.h" // FillInRecordFromFFB
|
---|
| 46 | #include "dircnrs.h"
|
---|
[1163] | 47 | #include "flesh.h" // Flesh, Stubby
|
---|
[1189] | 48 | #include "findrec.h" // FindCnrRecord
|
---|
| 49 | #include "valid.h" // IsFullName
|
---|
| 50 | #include "wrappers.h" // xDosFindFirst
|
---|
| 51 | #include "misc.h" // PostMsg
|
---|
[1039] | 52 | #include "fortify.h"
|
---|
[1890] | 53 |
|
---|
| 54 | #ifdef PMPRINTF
|
---|
| 55 | #define _PMPRINTF_ // Enable debug macros
|
---|
[1830] | 56 | #include "PMPRINTF.H"
|
---|
| 57 | #endif
|
---|
[2] | 58 |
|
---|
[344] | 59 | static PSZ pszSrcFile = __FILE__;
|
---|
| 60 |
|
---|
[557] | 61 | HPOINTER SelectDriveIcon(PCNRITEM pci)
|
---|
| 62 | {
|
---|
[730] | 63 | UINT driveflag = driveflags[toupper(*pci->pszFileName) - 'A'];
|
---|
| 64 | *pci->pszFileName = toupper(*pci->pszFileName);
|
---|
[751] | 65 | if (isalpha(*pci->pszFileName) &&
|
---|
| 66 | toupper(*pci->pszFileName) > 'B') {
|
---|
| 67 | if (driveflag & DRIVE_CDROM)
|
---|
[557] | 68 | pci->rc.hptrIcon = hptrCDROM;
|
---|
| 69 | else
|
---|
| 70 | pci->rc.hptrIcon =
|
---|
| 71 | (driveflag & DRIVE_REMOVABLE) ? hptrRemovable
|
---|
[751] | 72 | :(driveflag & DRIVE_VIRTUAL) ? hptrVirtual
|
---|
| 73 | :(driveflag & DRIVE_REMOTE) ? hptrRemote
|
---|
| 74 | :(driveflag & DRIVE_RAMDISK) ? hptrRamdisk
|
---|
[557] | 75 | :(driveflag & DRIVE_ZIPSTREAM) ? hptrZipstrm : hptrDrive;
|
---|
| 76 | }
|
---|
| 77 | else
|
---|
[751] | 78 | pci->rc.hptrIcon = hptrFloppy;
|
---|
| 79 | return pci->rc.hptrIcon;
|
---|
[557] | 80 | }
|
---|
[1611] | 81 |
|
---|
[1673] | 82 | /**
|
---|
| 83 | * Update/add CNRITEM record for filename
|
---|
[1611] | 84 | * Deletes existing CNRITEM if file has disappeared
|
---|
| 85 | * @returns pci pointer to CNRITEM record or NULL if not found or if stale CNRITEM deleted
|
---|
| 86 | */
|
---|
| 87 |
|
---|
| 88 | PCNRITEM UpdateCnrRecord(HWND hwndCnr, CHAR *filename, BOOL partial,
|
---|
| 89 | DIRCNRDATA *dcd)
|
---|
[51] | 90 | {
|
---|
[551] | 91 | PCNRITEM pci;
|
---|
[841] | 92 | FILEFINDBUF4L ffb;
|
---|
[551] | 93 | HDIR hDir = HDIR_CREATE;
|
---|
[751] | 94 | ULONG nm = 1;
|
---|
[551] | 95 | ULONG oldemphasis = 0;
|
---|
| 96 | APIRET status;
|
---|
| 97 |
|
---|
| 98 | if (!filename || !*filename)
|
---|
| 99 | return (PCNRITEM) NULL;
|
---|
| 100 | if (IsFullName(filename)) {
|
---|
| 101 | if (driveflags[toupper(*filename) - 'A'] & DRIVE_NOTWRITEABLE)
|
---|
[1673] | 102 | // ignore non-writeable drives
|
---|
[551] | 103 | return (PCNRITEM) NULL;
|
---|
[2] | 104 | }
|
---|
[838] | 105 | status = xDosFindFirst(filename,
|
---|
| 106 | &hDir,
|
---|
| 107 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
| 108 | FILE_ARCHIVED | FILE_READONLY |
|
---|
| 109 | FILE_HIDDEN | FILE_SYSTEM,
|
---|
[841] | 110 | &ffb, sizeof(ffb), &nm, FIL_QUERYEASIZEL);
|
---|
[551] | 111 | if (!status) {
|
---|
[1673] | 112 | // file exists
|
---|
[2] | 113 | DosFindClose(hDir);
|
---|
[551] | 114 | if (!dcd)
|
---|
[2] | 115 | dcd = INSTDATA(hwndCnr);
|
---|
[551] | 116 | if (dcd->type == ARC_FRAME)
|
---|
| 117 | return (PCNRITEM) NULL;
|
---|
| 118 | if (*dcd->directory) {
|
---|
[2] | 119 |
|
---|
[551] | 120 | CHAR *p, temp;
|
---|
[2] | 121 |
|
---|
[551] | 122 | p = strrchr(filename, '\\');
|
---|
| 123 | if (p) {
|
---|
| 124 | if (p < filename + 3)
|
---|
| 125 | p++;
|
---|
| 126 | temp = *p;
|
---|
| 127 | *p = 0;
|
---|
| 128 | if (stricmp(filename, dcd->directory)) {
|
---|
| 129 | *p = temp;
|
---|
| 130 | return (PCNRITEM) NULL;
|
---|
| 131 | }
|
---|
| 132 | *p = temp;
|
---|
[2] | 133 | }
|
---|
| 134 | else
|
---|
[551] | 135 | return (PCNRITEM) NULL;
|
---|
[2] | 136 | }
|
---|
| 137 | pci = FindCnrRecord(hwndCnr,
|
---|
[551] | 138 | filename, (PCNRITEM) NULL, partial, FALSE, TRUE);
|
---|
| 139 | Update:
|
---|
[1611] | 140 | if (pci) {
|
---|
| 141 | // Check if record needs to be updated
|
---|
[730] | 142 | if ((!fForceUpper && !fForceLower && strcmp(pci->pszFileName, filename)) ||
|
---|
[751] | 143 | pci->cbFile != ffb.cbFile || pci->attrFile != ffb.attrFile ||
|
---|
| 144 | pci->easize != CBLIST_TO_EASIZE(ffb.cbList) || pci->date.day !=
|
---|
| 145 | ffb.fdateLastWrite.day || pci->date.month != ffb.fdateLastWrite.month ||
|
---|
| 146 | pci->date.year != ffb.fdateLastWrite.year + 1980 || pci->time.seconds !=
|
---|
| 147 | ffb.ftimeLastWrite.twosecs * 2 || pci->time.minutes != ffb.ftimeLastWrite.minutes ||
|
---|
| 148 | pci->time.hours != ffb.ftimeLastWrite.hours || pci->ladate.day !=
|
---|
| 149 | ffb.fdateLastAccess.day || pci->ladate.month != ffb.fdateLastAccess.month ||
|
---|
| 150 | pci->ladate.year != ffb.fdateLastAccess.year + 1980 || pci->latime.seconds !=
|
---|
| 151 | ffb.ftimeLastAccess.twosecs * 2 || pci->latime.minutes !=
|
---|
[1611] | 152 | ffb.ftimeLastAccess.minutes || pci->latime.hours != ffb.ftimeLastAccess.hours)
|
---|
| 153 | {
|
---|
| 154 | // Something changed - update
|
---|
| 155 | *ffb.achName = 0; // Tell FillInRecordFromFFB that filename contains full pathname
|
---|
[551] | 156 | ffb.cchName = 0;
|
---|
| 157 | FillInRecordFromFFB(hwndCnr, pci, filename, &ffb, partial, dcd);
|
---|
[751] | 158 | if (strlen(pci->pszFileName) < 4)
|
---|
[1611] | 159 | SelectDriveIcon(pci);
|
---|
[551] | 160 | oldemphasis = pci->rc.flRecordAttr & (CRA_SELECTED | CRA_CURSORED);
|
---|
| 161 | if (oldemphasis)
|
---|
| 162 | WinSendMsg(hwndCnr,
|
---|
| 163 | CM_SETRECORDEMPHASIS,
|
---|
| 164 | MPFROMP(pci), MPFROM2SHORT(FALSE, oldemphasis));
|
---|
| 165 | WinSendMsg(hwndCnr,
|
---|
[1611] | 166 | CM_INVALIDATERECORD, MPFROMP(&pci), MPFROM2SHORT(1, CMA_TEXTCHANGED));
|
---|
[551] | 167 | if (oldemphasis)
|
---|
| 168 | WinSendMsg(hwndCnr,
|
---|
| 169 | CM_SETRECORDEMPHASIS,
|
---|
| 170 | MPFROMP(pci), MPFROM2SHORT(TRUE, oldemphasis));
|
---|
[2] | 171 | }
|
---|
[1673] | 172 | else // existed, unchanged, do nothing but return
|
---|
[551] | 173 | return pci;
|
---|
[2] | 174 | }
|
---|
[1611] | 175 | else {
|
---|
| 176 | // Add record
|
---|
[551] | 177 | if (dcd->type == DIR_FRAME) {
|
---|
[2] | 178 |
|
---|
[551] | 179 | RECORDINSERT ri;
|
---|
| 180 | ULONGLONG ullTotalBytes;
|
---|
[2] | 181 |
|
---|
[551] | 182 | pci = WinSendMsg(hwndCnr,
|
---|
| 183 | CM_ALLOCRECORD,
|
---|
[751] | 184 | MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(1));
|
---|
[551] | 185 | if (pci) {
|
---|
| 186 | *ffb.achName = 0;
|
---|
| 187 | ullTotalBytes = FillInRecordFromFFB(hwndCnr,
|
---|
| 188 | pci,
|
---|
| 189 | filename, &ffb, partial, dcd);
|
---|
[751] | 190 | if (strlen(pci->pszFileName) < 4)
|
---|
| 191 | SelectDriveIcon(pci);
|
---|
[551] | 192 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
| 193 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 194 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
| 195 | ri.pRecordParent = (PRECORDCORE) NULL;
|
---|
| 196 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
[751] | 197 | ri.cRecordsInsert = 1;
|
---|
[551] | 198 | ri.fInvalidateRecord = TRUE;
|
---|
| 199 | if (WinSendMsg(hwndCnr,
|
---|
| 200 | CM_INSERTRECORD,
|
---|
| 201 | MPFROMP(pci), MPFROMP(&ri)) && ullTotalBytes) {
|
---|
| 202 | dcd->ullTotalBytes += ullTotalBytes;
|
---|
| 203 | PostMsg(hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
---|
[1611] | 204 | if (pci->attrFile & FILE_DIRECTORY) {
|
---|
[1856] | 205 | AddFleshWorkRequest(hwndCnr, pci, eStubby);
|
---|
[1611] | 206 | }
|
---|
[551] | 207 | }
|
---|
| 208 | }
|
---|
[2] | 209 | }
|
---|
[551] | 210 | else if (ffb.attrFile & FILE_DIRECTORY) {
|
---|
[2] | 211 |
|
---|
[1673] | 212 | // check all parts and insert as required
|
---|
[551] | 213 | CHAR *p, temp;
|
---|
| 214 | PCNRITEM pciParent = NULL, pciT;
|
---|
[2] | 215 |
|
---|
[551] | 216 | p = strchr(filename, '\\');
|
---|
| 217 | if (p) {
|
---|
| 218 | while (p && *p) {
|
---|
| 219 | if (p < filename + 3)
|
---|
| 220 | p++;
|
---|
| 221 | temp = *p;
|
---|
| 222 | *p = 0;
|
---|
| 223 | pciT = FindCnrRecord(hwndCnr,
|
---|
| 224 | filename, NULL, partial, FALSE, TRUE);
|
---|
| 225 | if (!pciT || (INT) pciT == -1) {
|
---|
| 226 | pci = WinSendMsg(hwndCnr,
|
---|
| 227 | CM_ALLOCRECORD,
|
---|
| 228 | MPFROMLONG(EXTRA_RECORD_BYTES),
|
---|
[751] | 229 | MPFROMLONG(1));
|
---|
[551] | 230 | if (pci) {
|
---|
[2] | 231 |
|
---|
[551] | 232 | RECORDINSERT ri;
|
---|
[2] | 233 |
|
---|
[551] | 234 | *ffb.achName = 0;
|
---|
| 235 | FillInRecordFromFFB(hwndCnr,
|
---|
| 236 | pci, filename, &ffb, partial, dcd);
|
---|
[751] | 237 | if (strlen(pci->pszFileName) < 4)
|
---|
| 238 | SelectDriveIcon(pci);
|
---|
[551] | 239 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
| 240 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 241 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
| 242 | ri.pRecordParent = (PRECORDCORE) pciParent;
|
---|
| 243 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
[751] | 244 | ri.cRecordsInsert = 1;
|
---|
[551] | 245 | ri.fInvalidateRecord = TRUE;
|
---|
| 246 | if (WinSendMsg(hwndCnr,
|
---|
| 247 | CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
|
---|
[1876] | 248 | if (!pci->fleshed)
|
---|
| 249 | AddFleshWorkRequest(hwndCnr, pci, eFlesh);
|
---|
[551] | 250 | *p = temp;
|
---|
| 251 | pci = FindCnrRecord(hwndCnr,
|
---|
| 252 | filename, pciT, partial, FALSE, TRUE);
|
---|
| 253 | if (pci)
|
---|
| 254 | goto Update;
|
---|
| 255 | }
|
---|
| 256 | }
|
---|
| 257 | }
|
---|
| 258 | else {
|
---|
| 259 | pciParent = pciT;
|
---|
[1876] | 260 | if (!(pciT->rc.flRecordAttr & CRA_EXPANDED)) {
|
---|
| 261 | if (!pciT->fleshed)
|
---|
| 262 | AddFleshWorkRequest(hwndCnr, pciT, eFlesh);
|
---|
[551] | 263 | *p = temp;
|
---|
| 264 | pci = FindCnrRecord(hwndCnr,
|
---|
| 265 | filename, pciT, partial, FALSE, TRUE);
|
---|
| 266 | if (pci)
|
---|
| 267 | goto Update;
|
---|
| 268 | }
|
---|
| 269 | }
|
---|
| 270 | *p = temp;
|
---|
| 271 | p = strchr(p + ((temp == '\\') ? 1 : 0), '\\');
|
---|
| 272 | }
|
---|
| 273 | }
|
---|
| 274 | pci = WinSendMsg(hwndCnr,
|
---|
| 275 | CM_ALLOCRECORD,
|
---|
[751] | 276 | MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(1));
|
---|
[551] | 277 | if (pci) {
|
---|
[2] | 278 |
|
---|
[551] | 279 | RECORDINSERT ri;
|
---|
| 280 | ULONGLONG ullTotalBytes;
|
---|
[2] | 281 |
|
---|
[551] | 282 | *ffb.achName = 0;
|
---|
| 283 | ullTotalBytes = FillInRecordFromFFB(hwndCnr,
|
---|
[344] | 284 | pci,
|
---|
[551] | 285 | filename, &ffb, partial, dcd);
|
---|
[751] | 286 | if (strlen(pci->pszFileName) < 4)
|
---|
| 287 | SelectDriveIcon(pci);
|
---|
[551] | 288 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
| 289 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 290 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
| 291 | ri.pRecordParent = (PRECORDCORE) pciParent;
|
---|
| 292 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
[751] | 293 | ri.cRecordsInsert = 1;
|
---|
[551] | 294 | ri.fInvalidateRecord = TRUE;
|
---|
| 295 | if (WinSendMsg(hwndCnr,
|
---|
| 296 | CM_INSERTRECORD,
|
---|
| 297 | MPFROMP(pci), MPFROMP(&ri)) && ullTotalBytes) {
|
---|
| 298 | if (dcd->type == DIR_FRAME) {
|
---|
| 299 | dcd->ullTotalBytes += ullTotalBytes;
|
---|
[1611] | 300 | }
|
---|
[1856] | 301 | AddFleshWorkRequest(hwndCnr, pci, eStubby);
|
---|
[551] | 302 | }
|
---|
| 303 | }
|
---|
[2] | 304 | }
|
---|
| 305 | }
|
---|
| 306 | }
|
---|
[551] | 307 | else if ((pci = FindCnrRecord(hwndCnr,
|
---|
| 308 | filename,
|
---|
| 309 | (PCNRITEM) NULL,
|
---|
| 310 | partial,
|
---|
| 311 | FALSE,
|
---|
| 312 | TRUE)) !=
|
---|
[730] | 313 | NULL && (INT) pci != -1 && strlen(pci->pszFileName) > 3) {
|
---|
[1611] | 314 | // File has disappeared and found stale CNRITEM record delete it
|
---|
[551] | 315 | if (!dcd)
|
---|
[2] | 316 | dcd = INSTDATA(hwndCnr);
|
---|
[551] | 317 | if (pci->rc.flRecordAttr & CRA_SELECTED)
|
---|
[2] | 318 | WinSendMsg(hwndCnr,
|
---|
[551] | 319 | CM_SETRECORDEMPHASIS,
|
---|
| 320 | MPFROMP(pci), MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
| 321 | if (dcd->type == DIR_FRAME)
|
---|
[152] | 322 | dcd->ullTotalBytes -= pci->cbFile + pci->easize;
|
---|
[751] | 323 | RemoveCnrItems(hwndCnr, pci, 1, CMA_FREE | CMA_INVALIDATE);
|
---|
| 324 | pci = NULL;
|
---|
[551] | 325 | PostMsg(hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
---|
[2] | 326 | }
|
---|
| 327 | return pci;
|
---|
| 328 | }
|
---|
| 329 |
|
---|
[551] | 330 | BOOL UpdateCnrList(HWND hwndCnr, CHAR ** filename, INT howmany, BOOL partial,
|
---|
| 331 | DIRCNRDATA * dcd)
|
---|
[51] | 332 | {
|
---|
[551] | 333 | PCNRITEM pci, *pciList = NULL;
|
---|
[841] | 334 | FILEFINDBUF4L ffb;
|
---|
[551] | 335 | HDIR hDir;
|
---|
[761] | 336 | ULONG nm = (ULONG) howmany;
|
---|
[551] | 337 | INT x;
|
---|
| 338 | INT numlist = 0;
|
---|
| 339 | INT numremain;
|
---|
| 340 | BOOL repos = FALSE;
|
---|
| 341 | BOOL ret = FALSE;
|
---|
| 342 | APIRET status;
|
---|
[2] | 343 |
|
---|
[551] | 344 | if (!dcd)
|
---|
[2] | 345 | dcd = INSTDATA(hwndCnr);
|
---|
[344] | 346 | if (!dcd) {
|
---|
[1398] | 347 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
[2] | 348 | return ret;
|
---|
[344] | 349 | }
|
---|
| 350 | if (!filename || !howmany || !filename[0])
|
---|
[2] | 351 | return ret;
|
---|
| 352 | {
|
---|
| 353 | CNRINFO cnri;
|
---|
| 354 |
|
---|
[551] | 355 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
[2] | 356 | cnri.cb = sizeof(CNRINFO);
|
---|
| 357 | WinSendMsg(hwndCnr,
|
---|
[551] | 358 | CM_QUERYCNRINFO, MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
[2] | 359 | numremain = cnri.cRecords;
|
---|
| 360 | }
|
---|
[551] | 361 | pciList = xmalloc(sizeof(PCNRITEM) * howmany, pszSrcFile, __LINE__);
|
---|
[344] | 362 | if (pciList) {
|
---|
[551] | 363 | for (x = 0; filename[x] && x < howmany; x++) {
|
---|
[344] | 364 | if (IsFullName(filename[x])) {
|
---|
[551] | 365 | if (driveflags[toupper(*filename[x]) - 'A'] & DRIVE_NOTWRITEABLE)
|
---|
[1673] | 366 | // ignore non-writeable drives
|
---|
[551] | 367 | continue;
|
---|
[344] | 368 | }
|
---|
| 369 | hDir = HDIR_CREATE;
|
---|
[838] | 370 | status = xDosFindFirst(filename[x],
|
---|
| 371 | &hDir,
|
---|
| 372 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
| 373 | FILE_ARCHIVED | FILE_READONLY |
|
---|
| 374 | FILE_HIDDEN | FILE_SYSTEM,
|
---|
[841] | 375 | &ffb, sizeof(ffb), &nm, FIL_QUERYEASIZEL);
|
---|
[551] | 376 | if (!status) {
|
---|
[1673] | 377 | // file exists
|
---|
[551] | 378 | DosFindClose(hDir);
|
---|
| 379 | if (dcd->type == DIR_FRAME && *dcd->directory) {
|
---|
[2] | 380 |
|
---|
[551] | 381 | CHAR *p, temp;
|
---|
[2] | 382 |
|
---|
[551] | 383 | p = strrchr(filename[x], '\\');
|
---|
| 384 | if (p) {
|
---|
| 385 | if (p < filename[x] + 3)
|
---|
| 386 | p++;
|
---|
| 387 | temp = *p;
|
---|
| 388 | *p = 0;
|
---|
| 389 | if (stricmp(filename[x], dcd->directory)) {
|
---|
| 390 | *p = temp;
|
---|
| 391 | continue;
|
---|
| 392 | }
|
---|
| 393 | *p = temp;
|
---|
| 394 | }
|
---|
| 395 | else
|
---|
| 396 | continue;
|
---|
| 397 | }
|
---|
| 398 | ret = TRUE;
|
---|
| 399 | pci = FindCnrRecord(hwndCnr,
|
---|
| 400 | filename[x],
|
---|
| 401 | (PCNRITEM) NULL, partial, FALSE, TRUE);
|
---|
| 402 | if (pci) {
|
---|
[1673] | 403 | // update record?
|
---|
[551] | 404 | if ((!fForceUpper && !fForceLower &&
|
---|
[730] | 405 | strcmp(pci->pszFileName, filename[x])) ||
|
---|
[551] | 406 | pci->cbFile != ffb.cbFile || pci->attrFile != ffb.attrFile ||
|
---|
| 407 | pci->easize != CBLIST_TO_EASIZE(ffb.cbList) ||
|
---|
| 408 | pci->date.day != ffb.fdateLastWrite.day ||
|
---|
| 409 | pci->date.month != ffb.fdateLastWrite.month ||
|
---|
| 410 | pci->date.year != ffb.fdateLastWrite.year + 1980 ||
|
---|
| 411 | pci->time.seconds != ffb.ftimeLastWrite.twosecs * 2 ||
|
---|
| 412 | pci->time.minutes != ffb.ftimeLastWrite.minutes ||
|
---|
| 413 | pci->time.hours != ffb.ftimeLastWrite.hours ||
|
---|
| 414 | pci->ladate.day != ffb.fdateLastAccess.day ||
|
---|
| 415 | pci->ladate.month != ffb.fdateLastAccess.month ||
|
---|
| 416 | pci->ladate.year != ffb.fdateLastAccess.year + 1980 ||
|
---|
| 417 | pci->latime.seconds != ffb.ftimeLastAccess.twosecs * 2 ||
|
---|
| 418 | pci->latime.minutes != ffb.ftimeLastAccess.minutes ||
|
---|
| 419 | pci->latime.hours != ffb.ftimeLastAccess.hours) {
|
---|
[1673] | 420 | // changed; update
|
---|
[551] | 421 | pciList[numlist++] = pci;
|
---|
| 422 | *ffb.achName = 0;
|
---|
| 423 | ffb.cchName = 0;
|
---|
| 424 | FillInRecordFromFFB(hwndCnr,
|
---|
| 425 | pci, filename[x], &ffb, partial, dcd);
|
---|
[751] | 426 | if (IsRoot(pci->pszFileName))
|
---|
[1348] | 427 | SelectDriveIcon(pci);
|
---|
[551] | 428 | WinSendMsg(hwndCnr,
|
---|
| 429 | CM_SETRECORDEMPHASIS,
|
---|
| 430 | MPFROMP(pci),
|
---|
| 431 | MPFROM2SHORT(FALSE, CRA_SELECTED | CRA_CURSORED));
|
---|
| 432 | }
|
---|
| 433 | }
|
---|
| 434 | else {
|
---|
[1673] | 435 | // add record
|
---|
[551] | 436 | if (dcd->type == DIR_FRAME) {
|
---|
| 437 | RECORDINSERT ri;
|
---|
| 438 | ULONGLONG ullTotalBytes;
|
---|
[2] | 439 |
|
---|
[551] | 440 | pci = WinSendMsg(hwndCnr,
|
---|
| 441 | CM_ALLOCRECORD,
|
---|
[751] | 442 | MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(1));
|
---|
[551] | 443 | if (pci) {
|
---|
| 444 | ret = TRUE;
|
---|
| 445 | *ffb.achName = 0;
|
---|
| 446 | ullTotalBytes = FillInRecordFromFFB(hwndCnr,
|
---|
| 447 | pci,
|
---|
| 448 | filename[x],
|
---|
| 449 | &ffb, partial, dcd);
|
---|
[751] | 450 | if (strlen(pci->pszFileName) < 4)
|
---|
[1611] | 451 | SelectDriveIcon(pci);
|
---|
[551] | 452 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
| 453 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 454 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
| 455 | ri.pRecordParent = (PRECORDCORE) NULL;
|
---|
| 456 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
[751] | 457 | ri.cRecordsInsert = 1;
|
---|
[551] | 458 | ri.fInvalidateRecord = FALSE;
|
---|
| 459 | if (WinSendMsg(hwndCnr,
|
---|
| 460 | CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
|
---|
| 461 | if (ullTotalBytes) {
|
---|
| 462 | dcd->ullTotalBytes += ullTotalBytes;
|
---|
| 463 | numremain++;
|
---|
| 464 | }
|
---|
| 465 | repos = TRUE;
|
---|
[1611] | 466 | if (pci->attrFile & FILE_DIRECTORY) {
|
---|
[1856] | 467 | AddFleshWorkRequest(hwndCnr, pci, eStubby);
|
---|
[1611] | 468 | }
|
---|
[551] | 469 | }
|
---|
| 470 | else
|
---|
[751] | 471 | FreeCnrItem(hwndCnr, pci);
|
---|
[551] | 472 | }
|
---|
| 473 | }
|
---|
| 474 | else if (ffb.attrFile & FILE_DIRECTORY) {
|
---|
[1673] | 475 | // check all parts and insert as required
|
---|
[551] | 476 | CHAR *p, temp;
|
---|
| 477 | PCNRITEM pciParent = NULL, pciT;
|
---|
[344] | 478 |
|
---|
[551] | 479 | p = strchr(filename[x], '\\');
|
---|
| 480 | if (p) {
|
---|
| 481 | while (p && *p) {
|
---|
| 482 | if (p < filename[x] + 3)
|
---|
| 483 | p++;
|
---|
| 484 | temp = *p;
|
---|
| 485 | *p = 0;
|
---|
| 486 | pciT = FindCnrRecord(hwndCnr,
|
---|
| 487 | filename[x], NULL, partial, FALSE, TRUE);
|
---|
| 488 | if (!pciT || (INT) pciT == -1) {
|
---|
| 489 | pci = WinSendMsg(hwndCnr,
|
---|
| 490 | CM_ALLOCRECORD,
|
---|
| 491 | MPFROMLONG(EXTRA_RECORD_BYTES),
|
---|
[751] | 492 | MPFROMLONG(1));
|
---|
[551] | 493 | if (pci) {
|
---|
[344] | 494 |
|
---|
[551] | 495 | RECORDINSERT ri;
|
---|
| 496 | ULONGLONG ullTotalBytes;
|
---|
[344] | 497 |
|
---|
[551] | 498 | ret = TRUE;
|
---|
| 499 | *ffb.achName = 0;
|
---|
| 500 | ullTotalBytes = FillInRecordFromFFB(hwndCnr,
|
---|
| 501 | pci,
|
---|
| 502 | filename[x],
|
---|
| 503 | &ffb, partial, dcd);
|
---|
[751] | 504 | if (strlen(pci->pszFileName) < 4)
|
---|
[1017] | 505 | SelectDriveIcon(pci);
|
---|
[551] | 506 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
| 507 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 508 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
| 509 | ri.pRecordParent = (PRECORDCORE) pciParent;
|
---|
| 510 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
[751] | 511 | ri.cRecordsInsert = 1;
|
---|
[551] | 512 | ri.fInvalidateRecord = FALSE;
|
---|
| 513 | if (WinSendMsg(hwndCnr,
|
---|
| 514 | CM_INSERTRECORD,
|
---|
| 515 | MPFROMP(pci), MPFROMP(&ri))) {
|
---|
| 516 | if (ullTotalBytes) {
|
---|
| 517 | numremain++;
|
---|
| 518 | if (dcd->type == DIR_FRAME)
|
---|
| 519 | dcd->ullTotalBytes += ullTotalBytes;
|
---|
| 520 | }
|
---|
| 521 | repos = TRUE;
|
---|
| 522 | }
|
---|
| 523 | else
|
---|
[751] | 524 | FreeCnrItem(hwndCnr, pci);
|
---|
[551] | 525 | }
|
---|
| 526 | }
|
---|
| 527 | else
|
---|
| 528 | pciParent = pciT;
|
---|
| 529 | *p = temp;
|
---|
| 530 | p = strchr(p + ((temp == '\\') ? 1 : 0), '\\');
|
---|
| 531 | }
|
---|
| 532 | }
|
---|
| 533 | {
|
---|
| 534 | pci = WinSendMsg(hwndCnr,
|
---|
| 535 | CM_ALLOCRECORD,
|
---|
| 536 | MPFROMLONG(EXTRA_RECORD_BYTES),
|
---|
[751] | 537 | MPFROMLONG(1));
|
---|
[551] | 538 | if (pci) {
|
---|
[344] | 539 |
|
---|
[551] | 540 | RECORDINSERT ri;
|
---|
| 541 | ULONGLONG ullTotalBytes;
|
---|
[344] | 542 |
|
---|
[551] | 543 | ret = TRUE;
|
---|
| 544 | *ffb.achName = 0;
|
---|
| 545 | ullTotalBytes = FillInRecordFromFFB(hwndCnr,
|
---|
| 546 | pci,
|
---|
| 547 | filename[x],
|
---|
| 548 | &ffb, partial, dcd);
|
---|
[751] | 549 | if (strlen(pci->pszFileName) < 4)
|
---|
[1017] | 550 | SelectDriveIcon(pci);
|
---|
[551] | 551 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
| 552 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 553 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
| 554 | ri.pRecordParent = (PRECORDCORE) pciParent;
|
---|
| 555 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
[751] | 556 | ri.cRecordsInsert = 1;
|
---|
[551] | 557 | ri.fInvalidateRecord = FALSE;
|
---|
| 558 | if (WinSendMsg(hwndCnr,
|
---|
| 559 | CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
|
---|
| 560 | if (ullTotalBytes) {
|
---|
| 561 | numremain++;
|
---|
| 562 | if (dcd->type == DIR_FRAME)
|
---|
| 563 | dcd->ullTotalBytes += ullTotalBytes;
|
---|
| 564 | }
|
---|
[1611] | 565 | repos = TRUE;
|
---|
[1856] | 566 | AddFleshWorkRequest(hwndCnr, pci, eStubby);
|
---|
[551] | 567 | }
|
---|
| 568 | else
|
---|
[751] | 569 | FreeCnrItem(hwndCnr, pci);
|
---|
[551] | 570 | }
|
---|
| 571 | }
|
---|
| 572 | }
|
---|
| 573 | }
|
---|
[2] | 574 | }
|
---|
[344] | 575 | else if ((pci = FindCnrRecord(hwndCnr,
|
---|
[551] | 576 | filename[x],
|
---|
| 577 | (PCNRITEM) NULL,
|
---|
| 578 | partial,
|
---|
| 579 | FALSE,
|
---|
| 580 | TRUE)) != NULL &&
|
---|
[730] | 581 | (INT) pci != -1 && !IsRoot(pci->pszFileName)) {
|
---|
[1673] | 582 | // file doesn't exist; delete record
|
---|
[551] | 583 | if (pci->rc.flRecordAttr & CRA_SELECTED)
|
---|
| 584 | WinSendMsg(hwndCnr,
|
---|
| 585 | CM_SETRECORDEMPHASIS,
|
---|
| 586 | MPFROMP(pci), MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
| 587 | if (dcd->type == DIR_FRAME)
|
---|
| 588 | dcd->ullTotalBytes -= (pci->cbFile + pci->easize);
|
---|
[751] | 589 | // 02 Aug 07 SHL rc check was wrong
|
---|
| 590 | if (RemoveCnrItems(hwndCnr, pci, 1,
|
---|
| 591 | CMA_FREE |
|
---|
[1611] | 592 | numremain == 1 ? CMA_INVALIDATE : 0) != -1) {
|
---|
| 593 | pci = NULL;
|
---|
[551] | 594 | numremain--;
|
---|
| 595 | repos = TRUE;
|
---|
| 596 | }
|
---|
[2] | 597 | }
|
---|
[751] | 598 | } // for x
|
---|
[2] | 599 | }
|
---|
[551] | 600 | if (repos || (pciList && numlist)) {
|
---|
[2] | 601 | QUERYRECORDRECT qrr;
|
---|
[551] | 602 | RECTL rCnr, rCItem;
|
---|
[2] | 603 |
|
---|
| 604 | pci = WinSendMsg(hwndCnr,
|
---|
[551] | 605 | CM_QUERYRECORDEMPHASIS,
|
---|
| 606 | MPFROMLONG(CMA_FIRST), MPFROMLONG(CRA_CURSORED));
|
---|
| 607 | if (pci && (INT) pci != -1) {
|
---|
[2] | 608 | memset(&qrr, 0, sizeof(QUERYRECORDRECT));
|
---|
| 609 | qrr.cb = sizeof(QUERYRECORDRECT);
|
---|
| 610 | qrr.pRecord = (PRECORDCORE) pci;
|
---|
| 611 | qrr.fRightSplitWindow = FALSE;
|
---|
| 612 | qrr.fsExtent = CMA_TEXT;
|
---|
[551] | 613 | if (!WinSendMsg(hwndCnr,
|
---|
| 614 | CM_QUERYRECORDRECT, MPFROMP(&rCItem), MPFROMP(&qrr)))
|
---|
| 615 | qrr.cb = 0;
|
---|
[2] | 616 | }
|
---|
[551] | 617 | if (pciList && numlist && !repos) {
|
---|
[2] | 618 | WinSendMsg(hwndCnr,
|
---|
[551] | 619 | CM_INVALIDATERECORD,
|
---|
| 620 | MPFROMP(pciList),
|
---|
| 621 | MPFROM2SHORT(numlist,
|
---|
| 622 | (repos ? CMA_NOREPOSITION :
|
---|
| 623 | CMA_REPOSITION | CMA_ERASE)));
|
---|
[152] | 624 | }
|
---|
| 625 | if (repos)
|
---|
[2] | 626 | WinSendMsg(hwndCnr,
|
---|
[551] | 627 | CM_INVALIDATERECORD,
|
---|
| 628 | MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
---|
| 629 | if (pci && (INT) pci != -1 && qrr.cb) {
|
---|
[2] | 630 | WinSendMsg(hwndCnr,
|
---|
[551] | 631 | CM_QUERYVIEWPORTRECT,
|
---|
| 632 | MPFROMP(&rCnr), MPFROM2SHORT(CMA_WINDOW, (SHORT) FALSE));
|
---|
[2] | 633 | WinSendMsg(hwndCnr,
|
---|
[551] | 634 | CM_SCROLLWINDOW,
|
---|
| 635 | MPFROMSHORT(CMA_VERTICAL),
|
---|
| 636 | MPFROMLONG(rCnr.yTop - rCItem.yTop));
|
---|
[2] | 637 | }
|
---|
| 638 | }
|
---|
[551] | 639 | PostMsg(hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
---|
[344] | 640 | if (pciList) {
|
---|
[1039] | 641 | free(pciList);
|
---|
[2] | 642 | DosPostEventSem(CompactSem);
|
---|
| 643 | }
|
---|
| 644 | return ret;
|
---|
| 645 | }
|
---|
[793] | 646 |
|
---|
| 647 | #pragma alloc_text(UPDATECNR,UpdateCnrRecord,UpdateCnrList)
|
---|