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