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