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