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