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