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