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