| 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 | 
|---|
| 9 | Copyright (c) 2003, 2008 Steven H. Levine | 
|---|
| 10 |  | 
|---|
| 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 | 
|---|
| 15 | 06 Jun 05 SHL Drop unused code | 
|---|
| 16 | 22 Jul 06 SHL Use wrappers | 
|---|
| 17 | 20 Feb 07 GKY Add SelectDriveIcon() | 
|---|
| 18 | 09 Mar 07 GKY Cleanup SelectDriveIcon using "driveflag =" from Steven | 
|---|
| 19 | 02 Aug 07 SHL Sync with CNRITEM mods | 
|---|
| 20 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat | 
|---|
| 21 | 14 Mar 09 GKY Prevent execution of UM_SHOWME while drive scan is occuring | 
|---|
| 22 |  | 
|---|
| 23 | ***********************************************************************/ | 
|---|
| 24 |  | 
|---|
| 25 | #include <stdlib.h> | 
|---|
| 26 | #include <string.h> | 
|---|
| 27 | #include <ctype.h> | 
|---|
| 28 |  | 
|---|
| 29 | #define INCL_DOS | 
|---|
| 30 | #define INCL_WIN | 
|---|
| 31 | #define INCL_LONGLONG | 
|---|
| 32 |  | 
|---|
| 33 | #include "fm3dll.h" | 
|---|
| 34 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc. | 
|---|
| 35 | #include "update.h" | 
|---|
| 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 | 
|---|
| 40 | #include "fm3str.h" | 
|---|
| 41 | #include "errutil.h"                    // Dos_Error... | 
|---|
| 42 | #include "filldir.h"                    // FillInRecordFromFFB | 
|---|
| 43 | #include "dircnrs.h" | 
|---|
| 44 | #include "flesh.h"                      // Flesh, Stubby | 
|---|
| 45 | #include "findrec.h"                    // FindCnrRecord | 
|---|
| 46 | #include "valid.h"                      // IsFullName | 
|---|
| 47 | #include "wrappers.h"                   // xDosFindFirst | 
|---|
| 48 | #include "misc.h"                       // PostMsg | 
|---|
| 49 | #include "fortify.h" | 
|---|
| 50 |  | 
|---|
| 51 | static PSZ pszSrcFile = __FILE__; | 
|---|
| 52 |  | 
|---|
| 53 | HPOINTER SelectDriveIcon(PCNRITEM pci) | 
|---|
| 54 | { | 
|---|
| 55 | UINT driveflag = driveflags[toupper(*pci->pszFileName) - 'A']; | 
|---|
| 56 | *pci->pszFileName = toupper(*pci->pszFileName); | 
|---|
| 57 | if (isalpha(*pci->pszFileName) && | 
|---|
| 58 | toupper(*pci->pszFileName) > 'B') { | 
|---|
| 59 | if (driveflag & DRIVE_CDROM) | 
|---|
| 60 | pci->rc.hptrIcon = hptrCDROM; | 
|---|
| 61 | else | 
|---|
| 62 | pci->rc.hptrIcon = | 
|---|
| 63 | (driveflag & DRIVE_REMOVABLE) ? hptrRemovable | 
|---|
| 64 | :(driveflag & DRIVE_VIRTUAL) ? hptrVirtual | 
|---|
| 65 | :(driveflag & DRIVE_REMOTE) ? hptrRemote | 
|---|
| 66 | :(driveflag & DRIVE_RAMDISK) ? hptrRamdisk | 
|---|
| 67 | :(driveflag & DRIVE_ZIPSTREAM) ? hptrZipstrm : hptrDrive; | 
|---|
| 68 | } | 
|---|
| 69 | else | 
|---|
| 70 | pci->rc.hptrIcon = hptrFloppy; | 
|---|
| 71 | return pci->rc.hptrIcon; | 
|---|
| 72 | } | 
|---|
| 73 | PCNRITEM UpdateCnrRecord(HWND hwndCnr, CHAR * filename, BOOL partial, | 
|---|
| 74 | DIRCNRDATA * dcd) | 
|---|
| 75 | { | 
|---|
| 76 | PCNRITEM pci; | 
|---|
| 77 | FILEFINDBUF4L ffb; | 
|---|
| 78 | HDIR hDir = HDIR_CREATE; | 
|---|
| 79 | ULONG nm = 1; | 
|---|
| 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) | 
|---|
| 87 | /* ignore non-writeable drives */ | 
|---|
| 88 | return (PCNRITEM) NULL; | 
|---|
| 89 | } | 
|---|
| 90 | status = xDosFindFirst(filename, | 
|---|
| 91 | &hDir, | 
|---|
| 92 | FILE_NORMAL | FILE_DIRECTORY | | 
|---|
| 93 | FILE_ARCHIVED | FILE_READONLY | | 
|---|
| 94 | FILE_HIDDEN | FILE_SYSTEM, | 
|---|
| 95 | &ffb, sizeof(ffb), &nm, FIL_QUERYEASIZEL); | 
|---|
| 96 | if (!status) { | 
|---|
| 97 | /* file exists */ | 
|---|
| 98 | DosFindClose(hDir); | 
|---|
| 99 | if (!dcd) | 
|---|
| 100 | dcd = INSTDATA(hwndCnr); | 
|---|
| 101 | /* | 
|---|
| 102 | if(dcd->type == TREE_FRAME && | 
|---|
| 103 | !(ffb.attrFile & FILE_DIRECTORY)) | 
|---|
| 104 | return (PCNRITEM)NULL; | 
|---|
| 105 | */ | 
|---|
| 106 | if (dcd->type == ARC_FRAME) | 
|---|
| 107 | return (PCNRITEM) NULL; | 
|---|
| 108 | if (*dcd->directory) { | 
|---|
| 109 |  | 
|---|
| 110 | CHAR *p, temp; | 
|---|
| 111 |  | 
|---|
| 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; | 
|---|
| 123 | } | 
|---|
| 124 | else | 
|---|
| 125 | return (PCNRITEM) NULL; | 
|---|
| 126 | } | 
|---|
| 127 | pci = FindCnrRecord(hwndCnr, | 
|---|
| 128 | filename, (PCNRITEM) NULL, partial, FALSE, TRUE); | 
|---|
| 129 | Update: | 
|---|
| 130 | if (pci) {                          /* update record? */ | 
|---|
| 131 | if ((!fForceUpper && !fForceLower && strcmp(pci->pszFileName, filename)) || | 
|---|
| 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 */ | 
|---|
| 142 | *ffb.achName = 0; | 
|---|
| 143 | ffb.cchName = 0; | 
|---|
| 144 | FillInRecordFromFFB(hwndCnr, pci, filename, &ffb, partial, dcd); | 
|---|
| 145 | if (strlen(pci->pszFileName) < 4) | 
|---|
| 146 | SelectDriveIcon(pci); | 
|---|
| 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)); | 
|---|
| 160 | } | 
|---|
| 161 | else                              /* existed, unchanged, do nothing but return */ | 
|---|
| 162 | return pci; | 
|---|
| 163 | } | 
|---|
| 164 | else {                              /* add record */ | 
|---|
| 165 | if (dcd->type == DIR_FRAME) { | 
|---|
| 166 |  | 
|---|
| 167 | RECORDINSERT ri; | 
|---|
| 168 | ULONGLONG ullTotalBytes; | 
|---|
| 169 |  | 
|---|
| 170 | pci = WinSendMsg(hwndCnr, | 
|---|
| 171 | CM_ALLOCRECORD, | 
|---|
| 172 | MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(1)); | 
|---|
| 173 | if (pci) { | 
|---|
| 174 | *ffb.achName = 0; | 
|---|
| 175 | ullTotalBytes = FillInRecordFromFFB(hwndCnr, | 
|---|
| 176 | pci, | 
|---|
| 177 | filename, &ffb, partial, dcd); | 
|---|
| 178 | if (strlen(pci->pszFileName) < 4) | 
|---|
| 179 | SelectDriveIcon(pci); | 
|---|
| 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; | 
|---|
| 185 | ri.cRecordsInsert = 1; | 
|---|
| 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); | 
|---|
| 192 | if (pci->attrFile & FILE_DIRECTORY) { | 
|---|
| 193 | /*if (fInitialDriveScan) | 
|---|
| 194 | Stubby(hwndCnr, pci); | 
|---|
| 195 | else { | 
|---|
| 196 | while (StubbyScanCount != 0) | 
|---|
| 197 | DosSleep(50);*/ | 
|---|
| 198 | Stubby(hwndCnr, pci); | 
|---|
| 199 | //} | 
|---|
| 200 | } | 
|---|
| 201 | } | 
|---|
| 202 | } | 
|---|
| 203 | } | 
|---|
| 204 | else if (ffb.attrFile & FILE_DIRECTORY) { | 
|---|
| 205 |  | 
|---|
| 206 | /* check all parts and insert as required */ | 
|---|
| 207 | CHAR *p, temp; | 
|---|
| 208 | PCNRITEM pciParent = NULL, pciT; | 
|---|
| 209 |  | 
|---|
| 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), | 
|---|
| 223 | MPFROMLONG(1)); | 
|---|
| 224 | if (pci) { | 
|---|
| 225 |  | 
|---|
| 226 | RECORDINSERT ri; | 
|---|
| 227 |  | 
|---|
| 228 | *ffb.achName = 0; | 
|---|
| 229 | FillInRecordFromFFB(hwndCnr, | 
|---|
| 230 | pci, filename, &ffb, partial, dcd); | 
|---|
| 231 | if (strlen(pci->pszFileName) < 4) | 
|---|
| 232 | SelectDriveIcon(pci); | 
|---|
| 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; | 
|---|
| 238 | ri.cRecordsInsert = 1; | 
|---|
| 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, | 
|---|
| 268 | MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(1)); | 
|---|
| 269 | if (pci) { | 
|---|
| 270 |  | 
|---|
| 271 | RECORDINSERT ri; | 
|---|
| 272 | ULONGLONG ullTotalBytes; | 
|---|
| 273 |  | 
|---|
| 274 | *ffb.achName = 0; | 
|---|
| 275 | ullTotalBytes = FillInRecordFromFFB(hwndCnr, | 
|---|
| 276 | pci, | 
|---|
| 277 | filename, &ffb, partial, dcd); | 
|---|
| 278 | if (strlen(pci->pszFileName) < 4) | 
|---|
| 279 | SelectDriveIcon(pci); | 
|---|
| 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; | 
|---|
| 285 | ri.cRecordsInsert = 1; | 
|---|
| 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; | 
|---|
| 292 | } | 
|---|
| 293 | /*if (fInitialDriveScan) | 
|---|
| 294 | Stubby(hwndCnr, pci); | 
|---|
| 295 | else { | 
|---|
| 296 | while (StubbyScanCount != 0) | 
|---|
| 297 | DosSleep(50);*/ | 
|---|
| 298 | Stubby(hwndCnr, pci); | 
|---|
| 299 | //} | 
|---|
| 300 | } | 
|---|
| 301 | } | 
|---|
| 302 | } | 
|---|
| 303 | } | 
|---|
| 304 | } | 
|---|
| 305 | else if ((pci = FindCnrRecord(hwndCnr, | 
|---|
| 306 | filename, | 
|---|
| 307 | (PCNRITEM) NULL, | 
|---|
| 308 | partial, | 
|---|
| 309 | FALSE, | 
|---|
| 310 | TRUE)) != | 
|---|
| 311 | NULL && (INT) pci != -1 && strlen(pci->pszFileName) > 3) { | 
|---|
| 312 | /* file doesn't exist; delete record */ | 
|---|
| 313 | if (!dcd) | 
|---|
| 314 | dcd = INSTDATA(hwndCnr); | 
|---|
| 315 | if (pci->rc.flRecordAttr & CRA_SELECTED) | 
|---|
| 316 | WinSendMsg(hwndCnr, | 
|---|
| 317 | CM_SETRECORDEMPHASIS, | 
|---|
| 318 | MPFROMP(pci), MPFROM2SHORT(FALSE, CRA_SELECTED)); | 
|---|
| 319 | if (dcd->type == DIR_FRAME) | 
|---|
| 320 | dcd->ullTotalBytes -= pci->cbFile + pci->easize; | 
|---|
| 321 | RemoveCnrItems(hwndCnr, pci, 1, CMA_FREE | CMA_INVALIDATE); | 
|---|
| 322 | pci = NULL; | 
|---|
| 323 | PostMsg(hwndCnr, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 324 | } | 
|---|
| 325 | return pci; | 
|---|
| 326 | } | 
|---|
| 327 |  | 
|---|
| 328 | BOOL UpdateCnrList(HWND hwndCnr, CHAR ** filename, INT howmany, BOOL partial, | 
|---|
| 329 | DIRCNRDATA * dcd) | 
|---|
| 330 | { | 
|---|
| 331 | PCNRITEM pci, *pciList = NULL; | 
|---|
| 332 | FILEFINDBUF4L ffb; | 
|---|
| 333 | HDIR hDir; | 
|---|
| 334 | ULONG nm = (ULONG) howmany; | 
|---|
| 335 | INT x; | 
|---|
| 336 | INT numlist = 0; | 
|---|
| 337 | INT numremain; | 
|---|
| 338 | BOOL repos = FALSE; | 
|---|
| 339 | BOOL ret = FALSE; | 
|---|
| 340 | APIRET status; | 
|---|
| 341 |  | 
|---|
| 342 | if (!dcd) | 
|---|
| 343 | dcd = INSTDATA(hwndCnr); | 
|---|
| 344 | if (!dcd) { | 
|---|
| 345 | Runtime_Error(pszSrcFile, __LINE__, NULL); | 
|---|
| 346 | return ret; | 
|---|
| 347 | } | 
|---|
| 348 | if (!filename || !howmany || !filename[0]) | 
|---|
| 349 | return ret; | 
|---|
| 350 | { | 
|---|
| 351 | CNRINFO cnri; | 
|---|
| 352 |  | 
|---|
| 353 | memset(&cnri, 0, sizeof(CNRINFO)); | 
|---|
| 354 | cnri.cb = sizeof(CNRINFO); | 
|---|
| 355 | WinSendMsg(hwndCnr, | 
|---|
| 356 | CM_QUERYCNRINFO, MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO))); | 
|---|
| 357 | numremain = cnri.cRecords; | 
|---|
| 358 | } | 
|---|
| 359 | pciList = xmalloc(sizeof(PCNRITEM) * howmany, pszSrcFile, __LINE__); | 
|---|
| 360 | if (pciList) { | 
|---|
| 361 | for (x = 0; filename[x] && x < howmany; x++) { | 
|---|
| 362 | if (IsFullName(filename[x])) { | 
|---|
| 363 | if (driveflags[toupper(*filename[x]) - 'A'] & DRIVE_NOTWRITEABLE) | 
|---|
| 364 | /* ignore non-writeable drives */ | 
|---|
| 365 | continue; | 
|---|
| 366 | } | 
|---|
| 367 | hDir = HDIR_CREATE; | 
|---|
| 368 | status = xDosFindFirst(filename[x], | 
|---|
| 369 | &hDir, | 
|---|
| 370 | FILE_NORMAL | FILE_DIRECTORY | | 
|---|
| 371 | FILE_ARCHIVED | FILE_READONLY | | 
|---|
| 372 | FILE_HIDDEN | FILE_SYSTEM, | 
|---|
| 373 | &ffb, sizeof(ffb), &nm, FIL_QUERYEASIZEL); | 
|---|
| 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) { | 
|---|
| 380 |  | 
|---|
| 381 | CHAR *p, temp; | 
|---|
| 382 |  | 
|---|
| 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 && | 
|---|
| 405 | strcmp(pci->pszFileName, filename[x])) || | 
|---|
| 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) { | 
|---|
| 420 | /* changed; update */ | 
|---|
| 421 | pciList[numlist++] = pci; | 
|---|
| 422 | *ffb.achName = 0; | 
|---|
| 423 | ffb.cchName = 0; | 
|---|
| 424 | FillInRecordFromFFB(hwndCnr, | 
|---|
| 425 | pci, filename[x], &ffb, partial, dcd); | 
|---|
| 426 | if (IsRoot(pci->pszFileName)) | 
|---|
| 427 | SelectDriveIcon(pci); | 
|---|
| 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; | 
|---|
| 439 |  | 
|---|
| 440 | pci = WinSendMsg(hwndCnr, | 
|---|
| 441 | CM_ALLOCRECORD, | 
|---|
| 442 | MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(1)); | 
|---|
| 443 | if (pci) { | 
|---|
| 444 | ret = TRUE; | 
|---|
| 445 | *ffb.achName = 0; | 
|---|
| 446 | ullTotalBytes = FillInRecordFromFFB(hwndCnr, | 
|---|
| 447 | pci, | 
|---|
| 448 | filename[x], | 
|---|
| 449 | &ffb, partial, dcd); | 
|---|
| 450 | if (strlen(pci->pszFileName) < 4) | 
|---|
| 451 | SelectDriveIcon(pci); | 
|---|
| 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; | 
|---|
| 457 | ri.cRecordsInsert = 1; | 
|---|
| 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; | 
|---|
| 466 | if (pci->attrFile & FILE_DIRECTORY) { | 
|---|
| 467 | /*if (fInitialDriveScan) | 
|---|
| 468 | Stubby(hwndCnr, pci); | 
|---|
| 469 | else { | 
|---|
| 470 | while (StubbyScanCount != 0) | 
|---|
| 471 | DosSleep(50);*/ | 
|---|
| 472 | Stubby(hwndCnr, pci); | 
|---|
| 473 | // } | 
|---|
| 474 | } | 
|---|
| 475 | } | 
|---|
| 476 | else | 
|---|
| 477 | FreeCnrItem(hwndCnr, pci); | 
|---|
| 478 | } | 
|---|
| 479 | } | 
|---|
| 480 | else if (ffb.attrFile & FILE_DIRECTORY) { | 
|---|
| 481 | /* check all parts and insert as required */ | 
|---|
| 482 | CHAR *p, temp; | 
|---|
| 483 | PCNRITEM pciParent = NULL, pciT; | 
|---|
| 484 |  | 
|---|
| 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), | 
|---|
| 498 | MPFROMLONG(1)); | 
|---|
| 499 | if (pci) { | 
|---|
| 500 |  | 
|---|
| 501 | RECORDINSERT ri; | 
|---|
| 502 | ULONGLONG ullTotalBytes; | 
|---|
| 503 |  | 
|---|
| 504 | ret = TRUE; | 
|---|
| 505 | *ffb.achName = 0; | 
|---|
| 506 | ullTotalBytes = FillInRecordFromFFB(hwndCnr, | 
|---|
| 507 | pci, | 
|---|
| 508 | filename[x], | 
|---|
| 509 | &ffb, partial, dcd); | 
|---|
| 510 | if (strlen(pci->pszFileName) < 4) | 
|---|
| 511 | SelectDriveIcon(pci); | 
|---|
| 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; | 
|---|
| 517 | ri.cRecordsInsert = 1; | 
|---|
| 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 | 
|---|
| 530 | FreeCnrItem(hwndCnr, pci); | 
|---|
| 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), | 
|---|
| 543 | MPFROMLONG(1)); | 
|---|
| 544 | if (pci) { | 
|---|
| 545 |  | 
|---|
| 546 | RECORDINSERT ri; | 
|---|
| 547 | ULONGLONG ullTotalBytes; | 
|---|
| 548 |  | 
|---|
| 549 | ret = TRUE; | 
|---|
| 550 | *ffb.achName = 0; | 
|---|
| 551 | ullTotalBytes = FillInRecordFromFFB(hwndCnr, | 
|---|
| 552 | pci, | 
|---|
| 553 | filename[x], | 
|---|
| 554 | &ffb, partial, dcd); | 
|---|
| 555 | if (strlen(pci->pszFileName) < 4) | 
|---|
| 556 | SelectDriveIcon(pci); | 
|---|
| 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; | 
|---|
| 562 | ri.cRecordsInsert = 1; | 
|---|
| 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 | } | 
|---|
| 571 | repos = TRUE; | 
|---|
| 572 | /*if (fInitialDriveScan) | 
|---|
| 573 | Stubby(hwndCnr, pci); | 
|---|
| 574 | else { | 
|---|
| 575 | while (StubbyScanCount != 0) | 
|---|
| 576 | DosSleep(50);*/ | 
|---|
| 577 | Stubby(hwndCnr, pci); | 
|---|
| 578 | //} | 
|---|
| 579 | } | 
|---|
| 580 | else | 
|---|
| 581 | FreeCnrItem(hwndCnr, pci); | 
|---|
| 582 | } | 
|---|
| 583 | } | 
|---|
| 584 | } | 
|---|
| 585 | } | 
|---|
| 586 | } | 
|---|
| 587 | else if ((pci = FindCnrRecord(hwndCnr, | 
|---|
| 588 | filename[x], | 
|---|
| 589 | (PCNRITEM) NULL, | 
|---|
| 590 | partial, | 
|---|
| 591 | FALSE, | 
|---|
| 592 | TRUE)) != NULL && | 
|---|
| 593 | (INT) pci != -1 && !IsRoot(pci->pszFileName)) { | 
|---|
| 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); | 
|---|
| 601 | // 02 Aug 07 SHL rc check was wrong | 
|---|
| 602 | if (RemoveCnrItems(hwndCnr, pci, 1, | 
|---|
| 603 | CMA_FREE | | 
|---|
| 604 | numremain == 1 ? CMA_INVALIDATE : 0) != -1) { | 
|---|
| 605 | pci = NULL; | 
|---|
| 606 | numremain--; | 
|---|
| 607 | repos = TRUE; | 
|---|
| 608 | } | 
|---|
| 609 | } | 
|---|
| 610 | } // for x | 
|---|
| 611 | } | 
|---|
| 612 | if (repos || (pciList && numlist)) { | 
|---|
| 613 | QUERYRECORDRECT qrr; | 
|---|
| 614 | RECTL rCnr, rCItem; | 
|---|
| 615 |  | 
|---|
| 616 | pci = WinSendMsg(hwndCnr, | 
|---|
| 617 | CM_QUERYRECORDEMPHASIS, | 
|---|
| 618 | MPFROMLONG(CMA_FIRST), MPFROMLONG(CRA_CURSORED)); | 
|---|
| 619 | if (pci && (INT) pci != -1) { | 
|---|
| 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; | 
|---|
| 625 | if (!WinSendMsg(hwndCnr, | 
|---|
| 626 | CM_QUERYRECORDRECT, MPFROMP(&rCItem), MPFROMP(&qrr))) | 
|---|
| 627 | qrr.cb = 0; | 
|---|
| 628 | } | 
|---|
| 629 | if (pciList && numlist && !repos) { | 
|---|
| 630 | WinSendMsg(hwndCnr, | 
|---|
| 631 | CM_INVALIDATERECORD, | 
|---|
| 632 | MPFROMP(pciList), | 
|---|
| 633 | MPFROM2SHORT(numlist, | 
|---|
| 634 | (repos ? CMA_NOREPOSITION : | 
|---|
| 635 | CMA_REPOSITION | CMA_ERASE))); | 
|---|
| 636 | } | 
|---|
| 637 | if (repos) | 
|---|
| 638 | WinSendMsg(hwndCnr, | 
|---|
| 639 | CM_INVALIDATERECORD, | 
|---|
| 640 | MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION)); | 
|---|
| 641 | if (pci && (INT) pci != -1 && qrr.cb) { | 
|---|
| 642 | WinSendMsg(hwndCnr, | 
|---|
| 643 | CM_QUERYVIEWPORTRECT, | 
|---|
| 644 | MPFROMP(&rCnr), MPFROM2SHORT(CMA_WINDOW, (SHORT) FALSE)); | 
|---|
| 645 | WinSendMsg(hwndCnr, | 
|---|
| 646 | CM_SCROLLWINDOW, | 
|---|
| 647 | MPFROMSHORT(CMA_VERTICAL), | 
|---|
| 648 | MPFROMLONG(rCnr.yTop - rCItem.yTop)); | 
|---|
| 649 | } | 
|---|
| 650 | } | 
|---|
| 651 | PostMsg(hwndCnr, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 652 | if (pciList) { | 
|---|
| 653 | free(pciList); | 
|---|
| 654 | DosPostEventSem(CompactSem); | 
|---|
| 655 | } | 
|---|
| 656 | return ret; | 
|---|
| 657 | } | 
|---|
| 658 |  | 
|---|
| 659 | #pragma alloc_text(UPDATECNR,UpdateCnrRecord,UpdateCnrList) | 
|---|