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