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