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