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