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