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