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