| 1 |  | 
|---|
| 2 | /*********************************************************************** | 
|---|
| 3 |  | 
|---|
| 4 | $Id: update.c 85 2004-05-21 15:12:18Z root $ | 
|---|
| 5 |  | 
|---|
| 6 | Update Container record/list | 
|---|
| 7 |  | 
|---|
| 8 | Copyright (c) 1993-98 M. Kimes | 
|---|
| 9 | Copyright (c) 2003 Steven H.Levine | 
|---|
| 10 |  | 
|---|
| 11 | Revisions     12 Feb 03 SHL - Standardize EA math | 
|---|
| 12 | 10 Jan 04 SHL - Add some intermin large drive error avoidance | 
|---|
| 13 |  | 
|---|
| 14 | ***********************************************************************/ | 
|---|
| 15 |  | 
|---|
| 16 | #define INCL_DOS | 
|---|
| 17 | #define INCL_WIN | 
|---|
| 18 |  | 
|---|
| 19 | #include <os2.h> | 
|---|
| 20 | #include <stdarg.h> | 
|---|
| 21 | #include <stdio.h> | 
|---|
| 22 | #include <stdlib.h> | 
|---|
| 23 | #include <string.h> | 
|---|
| 24 | #include <ctype.h> | 
|---|
| 25 | #include "fm3dll.h" | 
|---|
| 26 |  | 
|---|
| 27 | #pragma alloc_text(UPDATECNR,UpdateCnrRecord,UpdateCnrList) | 
|---|
| 28 |  | 
|---|
| 29 |  | 
|---|
| 30 | PCNRITEM UpdateCnrRecord (HWND hwndCnr,CHAR *filename,BOOL partial, | 
|---|
| 31 | DIRCNRDATA *dcd) | 
|---|
| 32 | { | 
|---|
| 33 |  | 
|---|
| 34 | PCNRITEM      pci; | 
|---|
| 35 | FILEFINDBUF4  ffb; | 
|---|
| 36 | HDIR          hDir = HDIR_CREATE; | 
|---|
| 37 | ULONG         nm = 1L; | 
|---|
| 38 | ULONG         oldemphasis = 0; | 
|---|
| 39 | APIRET        status; | 
|---|
| 40 | BOOL          needtosort = FALSE; | 
|---|
| 41 | #ifdef DEBUG | 
|---|
| 42 | BOOL existed=FALSE,updated=FALSE,added=FALSE,deleted=FALSE,found=FALSE; | 
|---|
| 43 | #endif | 
|---|
| 44 |  | 
|---|
| 45 | if(!filename || !*filename) | 
|---|
| 46 | return (PCNRITEM)NULL; | 
|---|
| 47 | if(IsFullName(filename)) { | 
|---|
| 48 | if(driveflags[toupper(*filename) - 'A'] & DRIVE_NOTWRITEABLE) | 
|---|
| 49 | /* ignore non-writeable drives */ | 
|---|
| 50 | return (PCNRITEM)NULL; | 
|---|
| 51 | } | 
|---|
| 52 | status = DosFindFirst(filename, | 
|---|
| 53 | &hDir, | 
|---|
| 54 | FILE_NORMAL   | FILE_DIRECTORY | | 
|---|
| 55 | FILE_ARCHIVED | FILE_READONLY | | 
|---|
| 56 | FILE_HIDDEN   | FILE_SYSTEM, | 
|---|
| 57 | &ffb, | 
|---|
| 58 | sizeof(ffb), | 
|---|
| 59 | &nm, | 
|---|
| 60 | FIL_QUERYEASIZE); | 
|---|
| 61 | if(!status) { | 
|---|
| 62 | #ifdef DEBUG | 
|---|
| 63 | existed = TRUE; | 
|---|
| 64 | #endif | 
|---|
| 65 | /* file exists */ | 
|---|
| 66 | DosFindClose(hDir); | 
|---|
| 67 | if(!dcd) | 
|---|
| 68 | dcd = INSTDATA(hwndCnr); | 
|---|
| 69 | /* | 
|---|
| 70 | if(dcd->type == TREE_FRAME && | 
|---|
| 71 | !(ffb.attrFile & FILE_DIRECTORY)) | 
|---|
| 72 | return (PCNRITEM)NULL; | 
|---|
| 73 | */ | 
|---|
| 74 | if(dcd->type == ARC_FRAME) | 
|---|
| 75 | return (PCNRITEM)NULL; | 
|---|
| 76 | if(*dcd->directory) { | 
|---|
| 77 |  | 
|---|
| 78 | CHAR *p,temp; | 
|---|
| 79 |  | 
|---|
| 80 | p = strrchr(filename,'\\'); | 
|---|
| 81 | if(p) { | 
|---|
| 82 | if(p < filename + 3) | 
|---|
| 83 | p++; | 
|---|
| 84 | temp = *p; | 
|---|
| 85 | *p = 0; | 
|---|
| 86 | if(stricmp(filename,dcd->directory)) { | 
|---|
| 87 | *p = temp; | 
|---|
| 88 | return (PCNRITEM)NULL; | 
|---|
| 89 | } | 
|---|
| 90 | *p = temp; | 
|---|
| 91 | } | 
|---|
| 92 | else | 
|---|
| 93 | return (PCNRITEM)NULL; | 
|---|
| 94 | } | 
|---|
| 95 | pci = FindCnrRecord(hwndCnr, | 
|---|
| 96 | filename, | 
|---|
| 97 | (PCNRITEM)NULL, | 
|---|
| 98 | partial, | 
|---|
| 99 | FALSE, | 
|---|
| 100 | TRUE); | 
|---|
| 101 | Update: | 
|---|
| 102 | if(pci) {     /* update record? */ | 
|---|
| 103 | #ifdef DEBUG | 
|---|
| 104 | found=TRUE; | 
|---|
| 105 | #endif | 
|---|
| 106 | if((!fForceUpper && !fForceLower && | 
|---|
| 107 | strcmp(pci->szFileName,filename)) || | 
|---|
| 108 | pci->cbFile != ffb.cbFile || pci->attrFile != ffb.attrFile || | 
|---|
| 109 | pci->easize != CBLIST_TO_EASIZE(ffb.cbList) || | 
|---|
| 110 | pci->date.day != ffb.fdateLastWrite.day || | 
|---|
| 111 | pci->date.month != ffb.fdateLastWrite.month || | 
|---|
| 112 | pci->date.year != ffb.fdateLastWrite.year + 1980 || | 
|---|
| 113 | pci->time.seconds != ffb.ftimeLastWrite.twosecs * 2 || | 
|---|
| 114 | pci->time.minutes != ffb.ftimeLastWrite.minutes || | 
|---|
| 115 | pci->time.hours != ffb.ftimeLastWrite.hours || | 
|---|
| 116 | pci->ladate.day != ffb.fdateLastAccess.day || | 
|---|
| 117 | pci->ladate.month != ffb.fdateLastAccess.month || | 
|---|
| 118 | pci->ladate.year != ffb.fdateLastAccess.year + 1980 || | 
|---|
| 119 | pci->latime.seconds != ffb.ftimeLastAccess.twosecs * 2 || | 
|---|
| 120 | pci->latime.minutes != ffb.ftimeLastAccess.minutes || | 
|---|
| 121 | pci->latime.hours != ffb.ftimeLastAccess.hours) { /* changed; update */ | 
|---|
| 122 | #ifdef DEBUG | 
|---|
| 123 | updated=TRUE; | 
|---|
| 124 | #endif | 
|---|
| 125 | *ffb.achName = 0; | 
|---|
| 126 | ffb.cchName = 0; | 
|---|
| 127 | FillInRecordFromFFB(hwndCnr,pci,filename,&ffb,partial,dcd); | 
|---|
| 128 | if(strlen(pci->szFileName) < 4) { | 
|---|
| 129 | *pci->szFileName = toupper(*pci->szFileName); | 
|---|
| 130 | if(isalpha(*pci->szFileName) && toupper(*pci->szFileName) > 'B') { | 
|---|
| 131 | if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) | 
|---|
| 132 | pci->rc.hptrIcon = hptrCDROM; | 
|---|
| 133 | else | 
|---|
| 134 | pci->rc.hptrIcon = (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) ? | 
|---|
| 135 | hptrRemovable : | 
|---|
| 136 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOTE) ? | 
|---|
| 137 | hptrRemote : | 
|---|
| 138 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_ZIPSTREAM) ? | 
|---|
| 139 | hptrZipstrm : hptrDrive; | 
|---|
| 140 | } | 
|---|
| 141 | else | 
|---|
| 142 | pci->rc.hptrIcon = hptrFloppy; | 
|---|
| 143 | } | 
|---|
| 144 | oldemphasis = pci->rc.flRecordAttr & | 
|---|
| 145 | (CRA_SELECTED | CRA_CURSORED); | 
|---|
| 146 | if(oldemphasis) | 
|---|
| 147 | WinSendMsg(hwndCnr, | 
|---|
| 148 | CM_SETRECORDEMPHASIS, | 
|---|
| 149 | MPFROMP(pci), | 
|---|
| 150 | MPFROM2SHORT(FALSE, | 
|---|
| 151 | oldemphasis)); | 
|---|
| 152 | WinSendMsg(hwndCnr, | 
|---|
| 153 | CM_INVALIDATERECORD, | 
|---|
| 154 | MPFROMP(&pci), | 
|---|
| 155 | MPFROM2SHORT(1, | 
|---|
| 156 | /* CMA_ERASE | */CMA_TEXTCHANGED)); | 
|---|
| 157 | if(oldemphasis) | 
|---|
| 158 | WinSendMsg(hwndCnr, | 
|---|
| 159 | CM_SETRECORDEMPHASIS, | 
|---|
| 160 | MPFROMP(pci), | 
|---|
| 161 | MPFROM2SHORT(TRUE, | 
|---|
| 162 | oldemphasis)); | 
|---|
| 163 | } | 
|---|
| 164 | else  /* existed, unchanged, do nothing but return */ | 
|---|
| 165 | return pci; | 
|---|
| 166 | } | 
|---|
| 167 | else {        /* add record */ | 
|---|
| 168 | #ifdef DEBUG | 
|---|
| 169 | added=TRUE; | 
|---|
| 170 | #endif | 
|---|
| 171 | needtosort = TRUE; | 
|---|
| 172 | if(dcd->type == DIR_FRAME) { | 
|---|
| 173 |  | 
|---|
| 174 | RECORDINSERT ri; | 
|---|
| 175 | ULONG        totalbytes; | 
|---|
| 176 |  | 
|---|
| 177 | pci = WinSendMsg(hwndCnr, | 
|---|
| 178 | CM_ALLOCRECORD, | 
|---|
| 179 | MPFROMLONG(EXTRA_RECORD_BYTES), | 
|---|
| 180 | MPFROMLONG(1L)); | 
|---|
| 181 | if(pci) { | 
|---|
| 182 | *ffb.achName = 0; | 
|---|
| 183 | totalbytes = FillInRecordFromFFB(hwndCnr, | 
|---|
| 184 | pci, | 
|---|
| 185 | filename, | 
|---|
| 186 | &ffb, | 
|---|
| 187 | partial, | 
|---|
| 188 | dcd); | 
|---|
| 189 | if(strlen(pci->szFileName) < 4) { | 
|---|
| 190 | *pci->szFileName = toupper(*pci->szFileName); | 
|---|
| 191 | if(isalpha(*pci->szFileName) && | 
|---|
| 192 | toupper(*pci->szFileName) > 'B') { | 
|---|
| 193 | if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) | 
|---|
| 194 | pci->rc.hptrIcon = hptrCDROM; | 
|---|
| 195 | else | 
|---|
| 196 | pci->rc.hptrIcon = (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) ? | 
|---|
| 197 | hptrRemovable : | 
|---|
| 198 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOTE) ? | 
|---|
| 199 | hptrRemote : | 
|---|
| 200 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_ZIPSTREAM) ? | 
|---|
| 201 | hptrZipstrm : hptrDrive; | 
|---|
| 202 | } | 
|---|
| 203 | else | 
|---|
| 204 | pci->rc.hptrIcon = hptrFloppy; | 
|---|
| 205 | } | 
|---|
| 206 | memset(&ri,0,sizeof(RECORDINSERT)); | 
|---|
| 207 | ri.cb                 = sizeof(RECORDINSERT); | 
|---|
| 208 | ri.pRecordOrder       = (PRECORDCORE)CMA_END; | 
|---|
| 209 | ri.pRecordParent      = (PRECORDCORE)NULL; | 
|---|
| 210 | ri.zOrder             = (USHORT)CMA_TOP; | 
|---|
| 211 | ri.cRecordsInsert     = 1L; | 
|---|
| 212 | ri.fInvalidateRecord  = TRUE; | 
|---|
| 213 | if(WinSendMsg(hwndCnr, | 
|---|
| 214 | CM_INSERTRECORD, | 
|---|
| 215 | MPFROMP(pci), | 
|---|
| 216 | MPFROMP(&ri)) && | 
|---|
| 217 | totalbytes != -1 && | 
|---|
| 218 | totalbytes) | 
|---|
| 219 | { | 
|---|
| 220 | dcd->totalbytes += totalbytes; | 
|---|
| 221 | if (dcd->totalbytes == -1) | 
|---|
| 222 | dcd->totalbytes--; | 
|---|
| 223 | PostMsg(hwndCnr, | 
|---|
| 224 | UM_RESCAN, | 
|---|
| 225 | MPVOID, | 
|---|
| 226 | MPVOID); | 
|---|
| 227 | if(pci->attrFile & FILE_DIRECTORY) | 
|---|
| 228 | Stubby(hwndCnr,pci); | 
|---|
| 229 | } | 
|---|
| 230 | } | 
|---|
| 231 | } | 
|---|
| 232 | else if(ffb.attrFile & FILE_DIRECTORY) { | 
|---|
| 233 |  | 
|---|
| 234 | /* check all parts and insert as required */ | 
|---|
| 235 | CHAR    *p,temp; | 
|---|
| 236 | PCNRITEM pciParent = NULL,pciT; | 
|---|
| 237 |  | 
|---|
| 238 | p = strchr(filename,'\\'); | 
|---|
| 239 | if(p) { | 
|---|
| 240 | while(p && *p) { | 
|---|
| 241 | if(p < filename + 3) | 
|---|
| 242 | p++; | 
|---|
| 243 | temp = *p; | 
|---|
| 244 | *p = 0; | 
|---|
| 245 | pciT = FindCnrRecord(hwndCnr, | 
|---|
| 246 | filename, | 
|---|
| 247 | NULL, | 
|---|
| 248 | partial, | 
|---|
| 249 | FALSE, | 
|---|
| 250 | TRUE); | 
|---|
| 251 | if(!pciT || (INT)pciT == -1) { | 
|---|
| 252 | pci = WinSendMsg(hwndCnr, | 
|---|
| 253 | CM_ALLOCRECORD, | 
|---|
| 254 | MPFROMLONG(EXTRA_RECORD_BYTES), | 
|---|
| 255 | MPFROMLONG(1L)); | 
|---|
| 256 | if(pci) { | 
|---|
| 257 |  | 
|---|
| 258 | RECORDINSERT ri; | 
|---|
| 259 |  | 
|---|
| 260 | *ffb.achName = 0; | 
|---|
| 261 | FillInRecordFromFFB(hwndCnr, | 
|---|
| 262 | pci, | 
|---|
| 263 | filename, | 
|---|
| 264 | &ffb, | 
|---|
| 265 | partial, | 
|---|
| 266 | dcd); | 
|---|
| 267 | if(strlen(pci->szFileName) < 4) { | 
|---|
| 268 | *pci->szFileName = toupper(*pci->szFileName); | 
|---|
| 269 | if(isalpha(*pci->szFileName) && toupper(*pci->szFileName) > 'B') { | 
|---|
| 270 | if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) | 
|---|
| 271 | pci->rc.hptrIcon = hptrCDROM; | 
|---|
| 272 | else | 
|---|
| 273 | pci->rc.hptrIcon = (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) ? | 
|---|
| 274 | hptrRemovable : | 
|---|
| 275 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOTE) ? | 
|---|
| 276 | hptrRemote : | 
|---|
| 277 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_ZIPSTREAM) ? | 
|---|
| 278 | hptrZipstrm : hptrDrive; | 
|---|
| 279 | } | 
|---|
| 280 | else | 
|---|
| 281 | pci->rc.hptrIcon = hptrFloppy; | 
|---|
| 282 | } | 
|---|
| 283 | memset(&ri,0,sizeof(RECORDINSERT)); | 
|---|
| 284 | ri.cb                 = sizeof(RECORDINSERT); | 
|---|
| 285 | ri.pRecordOrder       = (PRECORDCORE)CMA_END; | 
|---|
| 286 | ri.pRecordParent      = (PRECORDCORE)pciParent; | 
|---|
| 287 | ri.zOrder             = (USHORT)CMA_TOP; | 
|---|
| 288 | ri.cRecordsInsert     = 1L; | 
|---|
| 289 | ri.fInvalidateRecord  = TRUE; | 
|---|
| 290 | if(WinSendMsg(hwndCnr, | 
|---|
| 291 | CM_INSERTRECORD, | 
|---|
| 292 | MPFROMP(pci), | 
|---|
| 293 | MPFROMP(&ri))) { | 
|---|
| 294 | Flesh(hwndCnr,pci); | 
|---|
| 295 | *p = temp; | 
|---|
| 296 | pci = FindCnrRecord(hwndCnr, | 
|---|
| 297 | filename, | 
|---|
| 298 | pciT, | 
|---|
| 299 | partial, | 
|---|
| 300 | FALSE, | 
|---|
| 301 | TRUE); | 
|---|
| 302 | if(pci) | 
|---|
| 303 | goto Update; | 
|---|
| 304 | } | 
|---|
| 305 | } | 
|---|
| 306 | } | 
|---|
| 307 | else { | 
|---|
| 308 | pciParent = pciT; | 
|---|
| 309 | if(!(pciT->rc.flRecordAttr & CRA_EXPANDED)) { | 
|---|
| 310 | Flesh(hwndCnr,pciT); | 
|---|
| 311 | *p = temp; | 
|---|
| 312 | pci = FindCnrRecord(hwndCnr, | 
|---|
| 313 | filename, | 
|---|
| 314 | pciT, | 
|---|
| 315 | partial, | 
|---|
| 316 | FALSE, | 
|---|
| 317 | TRUE); | 
|---|
| 318 | if(pci) | 
|---|
| 319 | goto Update; | 
|---|
| 320 | } | 
|---|
| 321 | } | 
|---|
| 322 | *p = temp; | 
|---|
| 323 | p = strchr(p + ((temp == '\\') ? 1 : 0),'\\'); | 
|---|
| 324 | } | 
|---|
| 325 | } | 
|---|
| 326 | pci = WinSendMsg(hwndCnr, | 
|---|
| 327 | CM_ALLOCRECORD, | 
|---|
| 328 | MPFROMLONG(EXTRA_RECORD_BYTES), | 
|---|
| 329 | MPFROMLONG(1L)); | 
|---|
| 330 | if(pci) { | 
|---|
| 331 |  | 
|---|
| 332 | RECORDINSERT ri; | 
|---|
| 333 | ULONG        totalbytes; | 
|---|
| 334 |  | 
|---|
| 335 | *ffb.achName = 0; | 
|---|
| 336 | totalbytes = FillInRecordFromFFB(hwndCnr, | 
|---|
| 337 | pci, | 
|---|
| 338 | filename, | 
|---|
| 339 | &ffb, | 
|---|
| 340 | partial, | 
|---|
| 341 | dcd); | 
|---|
| 342 | if(strlen(pci->szFileName) < 4) { | 
|---|
| 343 | *pci->szFileName = toupper(*pci->szFileName); | 
|---|
| 344 | if(isalpha(*pci->szFileName) && | 
|---|
| 345 | toupper(*pci->szFileName) > 'B') { | 
|---|
| 346 | if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) | 
|---|
| 347 | pci->rc.hptrIcon = hptrCDROM; | 
|---|
| 348 | else | 
|---|
| 349 | pci->rc.hptrIcon = (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) ? | 
|---|
| 350 | hptrRemovable : | 
|---|
| 351 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOTE) ? | 
|---|
| 352 | hptrRemote : | 
|---|
| 353 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_ZIPSTREAM) ? | 
|---|
| 354 | hptrZipstrm : hptrDrive; | 
|---|
| 355 | } | 
|---|
| 356 | else | 
|---|
| 357 | pci->rc.hptrIcon = hptrFloppy; | 
|---|
| 358 | } | 
|---|
| 359 | memset(&ri,0,sizeof(RECORDINSERT)); | 
|---|
| 360 | ri.cb                 = sizeof(RECORDINSERT); | 
|---|
| 361 | ri.pRecordOrder       = (PRECORDCORE)CMA_END; | 
|---|
| 362 | ri.pRecordParent      = (PRECORDCORE)pciParent; | 
|---|
| 363 | ri.zOrder             = (USHORT)CMA_TOP; | 
|---|
| 364 | ri.cRecordsInsert     = 1L; | 
|---|
| 365 | ri.fInvalidateRecord  = TRUE; | 
|---|
| 366 | if(WinSendMsg(hwndCnr, | 
|---|
| 367 | CM_INSERTRECORD, | 
|---|
| 368 | MPFROMP(pci), | 
|---|
| 369 | MPFROMP(&ri)) && | 
|---|
| 370 | totalbytes != -1 && | 
|---|
| 371 | totalbytes) | 
|---|
| 372 | { | 
|---|
| 373 | if (dcd->type == DIR_FRAME) { | 
|---|
| 374 | dcd->totalbytes += totalbytes; | 
|---|
| 375 | if (dcd->totalbytes == -1) | 
|---|
| 376 | dcd->totalbytes--;      // fixme for real someday | 
|---|
| 377 | } | 
|---|
| 378 | Stubby(hwndCnr,pci); | 
|---|
| 379 | } | 
|---|
| 380 | } | 
|---|
| 381 | } | 
|---|
| 382 | } | 
|---|
| 383 | } | 
|---|
| 384 | else if((pci = FindCnrRecord(hwndCnr, | 
|---|
| 385 | filename, | 
|---|
| 386 | (PCNRITEM)NULL, | 
|---|
| 387 | partial, | 
|---|
| 388 | FALSE, | 
|---|
| 389 | TRUE)) != | 
|---|
| 390 | NULL && (INT)pci != -1 && strlen(pci->szFileName) > 3) { | 
|---|
| 391 | /* file doesn't exist; delete record */ | 
|---|
| 392 | #ifdef DEBUG | 
|---|
| 393 | found=TRUE; | 
|---|
| 394 | deleted=TRUE; | 
|---|
| 395 | #endif | 
|---|
| 396 | if(!dcd) | 
|---|
| 397 | dcd = INSTDATA(hwndCnr); | 
|---|
| 398 | if(pci->rc.flRecordAttr & CRA_SELECTED) | 
|---|
| 399 | WinSendMsg(hwndCnr, | 
|---|
| 400 | CM_SETRECORDEMPHASIS, | 
|---|
| 401 | MPFROMP(pci), | 
|---|
| 402 | MPFROM2SHORT(FALSE, | 
|---|
| 403 | CRA_SELECTED)); | 
|---|
| 404 | if(dcd->type == DIR_FRAME) | 
|---|
| 405 | dcd->totalbytes -= pci->cbFile + pci->easize; | 
|---|
| 406 | WinSendMsg(hwndCnr, | 
|---|
| 407 | CM_REMOVERECORD, | 
|---|
| 408 | MPFROMP(&pci), | 
|---|
| 409 | MPFROM2SHORT(1, | 
|---|
| 410 | CMA_FREE | CMA_INVALIDATE)); | 
|---|
| 411 | pci = (PCNRITEM)NULL; | 
|---|
| 412 | PostMsg(hwndCnr, | 
|---|
| 413 | UM_RESCAN, | 
|---|
| 414 | MPVOID, | 
|---|
| 415 | MPVOID); | 
|---|
| 416 | } | 
|---|
| 417 | #ifdef DEBUG | 
|---|
| 418 | { | 
|---|
| 419 | char s[CCHMAXPATH + 80]; | 
|---|
| 420 | sprintf(s,"%s:%s%s%s%s%s",filename,(existed) ? " Existed" : "", | 
|---|
| 421 | (updated) ? " Updated" : "",(added) ? " Added" : "", | 
|---|
| 422 | (deleted) ? " Deleted" : "",(found) ? " Found" : ""); | 
|---|
| 423 | WinSetWindowText(WinQueryWindow(hwndMain,QW_PARENT),s); | 
|---|
| 424 | } | 
|---|
| 425 | #endif | 
|---|
| 426 | return pci; | 
|---|
| 427 | } | 
|---|
| 428 |  | 
|---|
| 429 |  | 
|---|
| 430 |  | 
|---|
| 431 | BOOL UpdateCnrList (HWND hwndCnr,CHAR **filename,INT howmany,BOOL partial, | 
|---|
| 432 | DIRCNRDATA *dcd) | 
|---|
| 433 | { | 
|---|
| 434 |  | 
|---|
| 435 | PCNRITEM      pci,*pciList = NULL; | 
|---|
| 436 | FILEFINDBUF4  ffb; | 
|---|
| 437 | HDIR          hDir; | 
|---|
| 438 | ULONG         nm = 1L; | 
|---|
| 439 | register INT  x,numlist = 0,numremain; | 
|---|
| 440 | BOOL          repos = FALSE,needtosort = FALSE,ret = FALSE; | 
|---|
| 441 | APIRET        status; | 
|---|
| 442 |  | 
|---|
| 443 | if(!dcd) | 
|---|
| 444 | dcd = INSTDATA(hwndCnr); | 
|---|
| 445 | if(!dcd) | 
|---|
| 446 | return ret; | 
|---|
| 447 | if(!filename || !howmany || !filename[0]) | 
|---|
| 448 | return ret; | 
|---|
| 449 | { | 
|---|
| 450 | CNRINFO cnri; | 
|---|
| 451 |  | 
|---|
| 452 | memset(&cnri,0,sizeof(CNRINFO)); | 
|---|
| 453 | cnri.cb = sizeof(CNRINFO); | 
|---|
| 454 | WinSendMsg(hwndCnr, | 
|---|
| 455 | CM_QUERYCNRINFO, | 
|---|
| 456 | MPFROMP(&cnri), | 
|---|
| 457 | MPFROMLONG(sizeof(CNRINFO))); | 
|---|
| 458 | numremain = cnri.cRecords; | 
|---|
| 459 | } | 
|---|
| 460 | pciList = malloc(sizeof(PCNRITEM) * howmany); | 
|---|
| 461 | for(x = 0;filename[x] && x < howmany;x++) { | 
|---|
| 462 | if(IsFullName(filename[x])) { | 
|---|
| 463 | if(driveflags[toupper(*filename[x]) - 'A'] & DRIVE_NOTWRITEABLE) | 
|---|
| 464 | /* ignore non-writeable drives */ | 
|---|
| 465 | continue; | 
|---|
| 466 | } | 
|---|
| 467 | hDir = HDIR_CREATE; | 
|---|
| 468 | status = DosFindFirst(filename[x], | 
|---|
| 469 | &hDir, | 
|---|
| 470 | FILE_NORMAL   | FILE_DIRECTORY | | 
|---|
| 471 | FILE_ARCHIVED | FILE_READONLY | | 
|---|
| 472 | FILE_HIDDEN   | FILE_SYSTEM, | 
|---|
| 473 | &ffb, | 
|---|
| 474 | sizeof(ffb), | 
|---|
| 475 | &nm, | 
|---|
| 476 | FIL_QUERYEASIZE); | 
|---|
| 477 | if(!status) { | 
|---|
| 478 | /* file exists */ | 
|---|
| 479 | DosFindClose(hDir); | 
|---|
| 480 | //      if(dcd->type == TREE_FRAME && !(ffb.attrFile & FILE_DIRECTORY)) | 
|---|
| 481 | //        continue; | 
|---|
| 482 | if(dcd->type == DIR_FRAME && | 
|---|
| 483 | *dcd->directory) { | 
|---|
| 484 |  | 
|---|
| 485 | CHAR *p,temp; | 
|---|
| 486 |  | 
|---|
| 487 | p = strrchr(filename[x],'\\'); | 
|---|
| 488 | if(p) { | 
|---|
| 489 | if(p < filename[x] + 3) | 
|---|
| 490 | p++; | 
|---|
| 491 | temp = *p; | 
|---|
| 492 | *p = 0; | 
|---|
| 493 | if(stricmp(filename[x],dcd->directory)) { | 
|---|
| 494 | *p = temp; | 
|---|
| 495 | continue; | 
|---|
| 496 | } | 
|---|
| 497 | *p = temp; | 
|---|
| 498 | } | 
|---|
| 499 | else | 
|---|
| 500 | continue; | 
|---|
| 501 | } | 
|---|
| 502 | ret = TRUE; | 
|---|
| 503 | pci = FindCnrRecord(hwndCnr, | 
|---|
| 504 | filename[x], | 
|---|
| 505 | (PCNRITEM)NULL, | 
|---|
| 506 | partial, | 
|---|
| 507 | FALSE, | 
|---|
| 508 | TRUE); | 
|---|
| 509 | if(pci) {     /* update record? */ | 
|---|
| 510 | if((!fForceUpper && !fForceLower && | 
|---|
| 511 | strcmp(pci->szFileName,filename[x])) || | 
|---|
| 512 | pci->cbFile != ffb.cbFile || pci->attrFile != ffb.attrFile || | 
|---|
| 513 | pci->easize != CBLIST_TO_EASIZE(ffb.cbList) || | 
|---|
| 514 | pci->date.day != ffb.fdateLastWrite.day || | 
|---|
| 515 | pci->date.month != ffb.fdateLastWrite.month || | 
|---|
| 516 | pci->date.year != ffb.fdateLastWrite.year + 1980 || | 
|---|
| 517 | pci->time.seconds != ffb.ftimeLastWrite.twosecs * 2 || | 
|---|
| 518 | pci->time.minutes != ffb.ftimeLastWrite.minutes || | 
|---|
| 519 | pci->time.hours != ffb.ftimeLastWrite.hours || | 
|---|
| 520 | pci->ladate.day != ffb.fdateLastAccess.day || | 
|---|
| 521 | pci->ladate.month != ffb.fdateLastAccess.month || | 
|---|
| 522 | pci->ladate.year != ffb.fdateLastAccess.year + 1980 || | 
|---|
| 523 | pci->latime.seconds != ffb.ftimeLastAccess.twosecs * 2 || | 
|---|
| 524 | pci->latime.minutes != ffb.ftimeLastAccess.minutes || | 
|---|
| 525 | pci->latime.hours != ffb.ftimeLastAccess.hours) { /* changed; update */ | 
|---|
| 526 | pciList[numlist++] = pci; | 
|---|
| 527 | *ffb.achName = 0; | 
|---|
| 528 | ffb.cchName = 0; | 
|---|
| 529 | FillInRecordFromFFB(hwndCnr, | 
|---|
| 530 | pci, | 
|---|
| 531 | filename[x], | 
|---|
| 532 | &ffb, | 
|---|
| 533 | partial, | 
|---|
| 534 | dcd); | 
|---|
| 535 | if(IsRoot(pci->szFileName)) { | 
|---|
| 536 | *pci->szFileName = toupper(*pci->szFileName); | 
|---|
| 537 | if(isalpha(*pci->szFileName) && | 
|---|
| 538 | toupper(*pci->szFileName) > 'B') { | 
|---|
| 539 | if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) | 
|---|
| 540 | pci->rc.hptrIcon = hptrCDROM; | 
|---|
| 541 | else | 
|---|
| 542 | pci->rc.hptrIcon = (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) ? | 
|---|
| 543 | hptrRemovable : | 
|---|
| 544 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOTE) ? | 
|---|
| 545 | hptrRemote : | 
|---|
| 546 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_ZIPSTREAM) ? | 
|---|
| 547 | hptrZipstrm : hptrDrive; | 
|---|
| 548 | } | 
|---|
| 549 | else | 
|---|
| 550 | pci->rc.hptrIcon = hptrFloppy; | 
|---|
| 551 | } | 
|---|
| 552 | WinSendMsg(hwndCnr, | 
|---|
| 553 | CM_SETRECORDEMPHASIS, | 
|---|
| 554 | MPFROMP(pci), | 
|---|
| 555 | MPFROM2SHORT(FALSE, | 
|---|
| 556 | CRA_SELECTED | CRA_CURSORED)); | 
|---|
| 557 | } | 
|---|
| 558 | } | 
|---|
| 559 | else {        /* add record */ | 
|---|
| 560 | needtosort = TRUE; | 
|---|
| 561 | if(dcd->type == DIR_FRAME) { | 
|---|
| 562 |  | 
|---|
| 563 | RECORDINSERT ri; | 
|---|
| 564 | ULONG        totalbytes; | 
|---|
| 565 |  | 
|---|
| 566 | pci = WinSendMsg(hwndCnr, | 
|---|
| 567 | CM_ALLOCRECORD, | 
|---|
| 568 | MPFROMLONG(EXTRA_RECORD_BYTES), | 
|---|
| 569 | MPFROMLONG(1L)); | 
|---|
| 570 | if(pci) { | 
|---|
| 571 | ret = TRUE; | 
|---|
| 572 | *ffb.achName = 0; | 
|---|
| 573 | totalbytes = FillInRecordFromFFB(hwndCnr, | 
|---|
| 574 | pci, | 
|---|
| 575 | filename[x], | 
|---|
| 576 | &ffb, | 
|---|
| 577 | partial, | 
|---|
| 578 | dcd); | 
|---|
| 579 | if(strlen(pci->szFileName) < 4) { | 
|---|
| 580 | *pci->szFileName = toupper(*pci->szFileName); | 
|---|
| 581 | if(isalpha(*pci->szFileName) && | 
|---|
| 582 | toupper(*pci->szFileName) > 'B') { | 
|---|
| 583 | if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) | 
|---|
| 584 | pci->rc.hptrIcon = hptrCDROM; | 
|---|
| 585 | else | 
|---|
| 586 | pci->rc.hptrIcon = (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) ? | 
|---|
| 587 | hptrRemovable : | 
|---|
| 588 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOTE) ? | 
|---|
| 589 | hptrRemote : | 
|---|
| 590 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_ZIPSTREAM) ? | 
|---|
| 591 | hptrZipstrm : hptrDrive; | 
|---|
| 592 | } | 
|---|
| 593 | else | 
|---|
| 594 | pci->rc.hptrIcon = hptrFloppy; | 
|---|
| 595 | } | 
|---|
| 596 | memset(&ri,0,sizeof(RECORDINSERT)); | 
|---|
| 597 | ri.cb                 = sizeof(RECORDINSERT); | 
|---|
| 598 | ri.pRecordOrder       = (PRECORDCORE)CMA_END; | 
|---|
| 599 | ri.pRecordParent      = (PRECORDCORE)NULL; | 
|---|
| 600 | ri.zOrder             = (USHORT)CMA_TOP; | 
|---|
| 601 | ri.cRecordsInsert     = 1L; | 
|---|
| 602 | ri.fInvalidateRecord  = FALSE; | 
|---|
| 603 | if(WinSendMsg(hwndCnr, | 
|---|
| 604 | CM_INSERTRECORD, | 
|---|
| 605 | MPFROMP(pci), | 
|---|
| 606 | MPFROMP(&ri))) { | 
|---|
| 607 | if (totalbytes != -1 && | 
|---|
| 608 | totalbytes) | 
|---|
| 609 | { | 
|---|
| 610 | dcd->totalbytes += totalbytes; | 
|---|
| 611 | if (dcd->totalbytes == -1) | 
|---|
| 612 | dcd->totalbytes--;    // fixme for real someday | 
|---|
| 613 | numremain++; | 
|---|
| 614 | } | 
|---|
| 615 | repos = TRUE; | 
|---|
| 616 | if(pci->attrFile & FILE_DIRECTORY) | 
|---|
| 617 | Stubby(hwndCnr,pci); | 
|---|
| 618 | } | 
|---|
| 619 | else | 
|---|
| 620 | WinSendMsg(hwndCnr, | 
|---|
| 621 | CM_FREERECORD, | 
|---|
| 622 | MPFROMP(&pci), | 
|---|
| 623 | MPFROMSHORT(1)); | 
|---|
| 624 | } | 
|---|
| 625 | } | 
|---|
| 626 | else if(ffb.attrFile & FILE_DIRECTORY) {  /* check all parts and insert as required */ | 
|---|
| 627 |  | 
|---|
| 628 | CHAR    *p,temp; | 
|---|
| 629 | PCNRITEM pciParent = NULL,pciT; | 
|---|
| 630 |  | 
|---|
| 631 | p = strchr(filename[x],'\\'); | 
|---|
| 632 | if(p) { | 
|---|
| 633 | while(p && *p) { | 
|---|
| 634 | if(p < filename[x] + 3) | 
|---|
| 635 | p++; | 
|---|
| 636 | temp = *p; | 
|---|
| 637 | *p = 0; | 
|---|
| 638 | pciT = FindCnrRecord(hwndCnr, | 
|---|
| 639 | filename[x], | 
|---|
| 640 | NULL, | 
|---|
| 641 | partial, | 
|---|
| 642 | FALSE, | 
|---|
| 643 | TRUE); | 
|---|
| 644 | if(!pciT || (INT)pciT == -1) { | 
|---|
| 645 | pci = WinSendMsg(hwndCnr, | 
|---|
| 646 | CM_ALLOCRECORD, | 
|---|
| 647 | MPFROMLONG(EXTRA_RECORD_BYTES), | 
|---|
| 648 | MPFROMLONG(1L)); | 
|---|
| 649 | if(pci) { | 
|---|
| 650 |  | 
|---|
| 651 | RECORDINSERT ri; | 
|---|
| 652 | ULONG        totalbytes; | 
|---|
| 653 |  | 
|---|
| 654 | ret = TRUE; | 
|---|
| 655 | *ffb.achName = 0; | 
|---|
| 656 | totalbytes = FillInRecordFromFFB(hwndCnr, | 
|---|
| 657 | pci, | 
|---|
| 658 | filename[x], | 
|---|
| 659 | &ffb, | 
|---|
| 660 | partial, | 
|---|
| 661 | dcd); | 
|---|
| 662 | if(strlen(pci->szFileName) < 4) { | 
|---|
| 663 | *pci->szFileName = toupper(*pci->szFileName); | 
|---|
| 664 | if(isalpha(*pci->szFileName) && | 
|---|
| 665 | toupper(*pci->szFileName) > 'B') { | 
|---|
| 666 | if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) | 
|---|
| 667 | pci->rc.hptrIcon = hptrCDROM; | 
|---|
| 668 | else | 
|---|
| 669 | pci->rc.hptrIcon = (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) ? | 
|---|
| 670 | hptrRemovable : | 
|---|
| 671 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOTE) ? | 
|---|
| 672 | hptrRemote : | 
|---|
| 673 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_ZIPSTREAM) ? | 
|---|
| 674 | hptrZipstrm : hptrDrive; | 
|---|
| 675 | } | 
|---|
| 676 | else | 
|---|
| 677 | pci->rc.hptrIcon = hptrFloppy; | 
|---|
| 678 | } | 
|---|
| 679 | memset(&ri,0,sizeof(RECORDINSERT)); | 
|---|
| 680 | ri.cb                 = sizeof(RECORDINSERT); | 
|---|
| 681 | ri.pRecordOrder       = (PRECORDCORE)CMA_END; | 
|---|
| 682 | ri.pRecordParent      = (PRECORDCORE)pciParent; | 
|---|
| 683 | ri.zOrder             = (USHORT)CMA_TOP; | 
|---|
| 684 | ri.cRecordsInsert     = 1L; | 
|---|
| 685 | ri.fInvalidateRecord  = FALSE; | 
|---|
| 686 | if(WinSendMsg(hwndCnr, | 
|---|
| 687 | CM_INSERTRECORD, | 
|---|
| 688 | MPFROMP(pci), | 
|---|
| 689 | MPFROMP(&ri))) { | 
|---|
| 690 | if (totalbytes != -1 && | 
|---|
| 691 | totalbytes) | 
|---|
| 692 | { | 
|---|
| 693 | numremain++; | 
|---|
| 694 | if(dcd->type == DIR_FRAME) { | 
|---|
| 695 | dcd->totalbytes += totalbytes; | 
|---|
| 696 | if (dcd->totalbytes == -1) | 
|---|
| 697 | dcd->totalbytes--;    // fixme for real someday | 
|---|
| 698 | } | 
|---|
| 699 | } | 
|---|
| 700 | repos = TRUE; | 
|---|
| 701 | } | 
|---|
| 702 | else | 
|---|
| 703 | WinSendMsg(hwndCnr, | 
|---|
| 704 | CM_FREERECORD, | 
|---|
| 705 | MPFROMP(&pci), | 
|---|
| 706 | MPFROMSHORT(1)); | 
|---|
| 707 | } | 
|---|
| 708 | } | 
|---|
| 709 | else | 
|---|
| 710 | pciParent = pciT; | 
|---|
| 711 | *p = temp; | 
|---|
| 712 | p = strchr(p + ((temp == '\\') ? 1 : 0),'\\'); | 
|---|
| 713 | } | 
|---|
| 714 | } | 
|---|
| 715 | { | 
|---|
| 716 | pci = WinSendMsg(hwndCnr, | 
|---|
| 717 | CM_ALLOCRECORD, | 
|---|
| 718 | MPFROMLONG(EXTRA_RECORD_BYTES), | 
|---|
| 719 | MPFROMLONG(1L)); | 
|---|
| 720 | if(pci) { | 
|---|
| 721 |  | 
|---|
| 722 | RECORDINSERT ri; | 
|---|
| 723 | ULONG        totalbytes; | 
|---|
| 724 |  | 
|---|
| 725 | ret = TRUE; | 
|---|
| 726 | *ffb.achName = 0; | 
|---|
| 727 | totalbytes = FillInRecordFromFFB(hwndCnr, | 
|---|
| 728 | pci, | 
|---|
| 729 | filename[x], | 
|---|
| 730 | &ffb, | 
|---|
| 731 | partial, | 
|---|
| 732 | dcd); | 
|---|
| 733 | if(strlen(pci->szFileName) < 4) { | 
|---|
| 734 | *pci->szFileName = toupper(*pci->szFileName); | 
|---|
| 735 | if(isalpha(*pci->szFileName) && | 
|---|
| 736 | toupper(*pci->szFileName) > 'B') { | 
|---|
| 737 | if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) | 
|---|
| 738 | pci->rc.hptrIcon = hptrCDROM; | 
|---|
| 739 | else | 
|---|
| 740 | pci->rc.hptrIcon = (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) ? | 
|---|
| 741 | hptrRemovable : | 
|---|
| 742 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOTE) ? | 
|---|
| 743 | hptrRemote : | 
|---|
| 744 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_ZIPSTREAM) ? | 
|---|
| 745 | hptrZipstrm : hptrDrive; | 
|---|
| 746 | } | 
|---|
| 747 | else | 
|---|
| 748 | pci->rc.hptrIcon = hptrFloppy; | 
|---|
| 749 | } | 
|---|
| 750 | memset(&ri,0,sizeof(RECORDINSERT)); | 
|---|
| 751 | ri.cb                 = sizeof(RECORDINSERT); | 
|---|
| 752 | ri.pRecordOrder       = (PRECORDCORE)CMA_END; | 
|---|
| 753 | ri.pRecordParent      = (PRECORDCORE)pciParent; | 
|---|
| 754 | ri.zOrder             = (USHORT)CMA_TOP; | 
|---|
| 755 | ri.cRecordsInsert     = 1L; | 
|---|
| 756 | ri.fInvalidateRecord  = FALSE; | 
|---|
| 757 | if(WinSendMsg(hwndCnr, | 
|---|
| 758 | CM_INSERTRECORD, | 
|---|
| 759 | MPFROMP(pci), | 
|---|
| 760 | MPFROMP(&ri))) { | 
|---|
| 761 | if (totalbytes != -1 && | 
|---|
| 762 | totalbytes) | 
|---|
| 763 | { | 
|---|
| 764 | numremain++; | 
|---|
| 765 | if (dcd->type == DIR_FRAME) { | 
|---|
| 766 | dcd->totalbytes += totalbytes; | 
|---|
| 767 | if (dcd->totalbytes == -1) | 
|---|
| 768 | dcd->totalbytes--;        // fixme for real someday | 
|---|
| 769 | } | 
|---|
| 770 | } | 
|---|
| 771 | repos = TRUE; | 
|---|
| 772 | Stubby(hwndCnr,pci); | 
|---|
| 773 | } | 
|---|
| 774 | else | 
|---|
| 775 | WinSendMsg(hwndCnr, | 
|---|
| 776 | CM_FREERECORD, | 
|---|
| 777 | MPFROMP(&pci), | 
|---|
| 778 | MPFROMSHORT(1)); | 
|---|
| 779 | } | 
|---|
| 780 | } | 
|---|
| 781 | } | 
|---|
| 782 | } | 
|---|
| 783 | } | 
|---|
| 784 | else if((pci = FindCnrRecord(hwndCnr, | 
|---|
| 785 | filename[x], | 
|---|
| 786 | (PCNRITEM)NULL, | 
|---|
| 787 | partial, | 
|---|
| 788 | FALSE, | 
|---|
| 789 | TRUE)) !=  NULL && | 
|---|
| 790 | (INT)pci != -1 && !IsRoot(pci->szFileName)) { | 
|---|
| 791 | /* file doesn't exist; delete record */ | 
|---|
| 792 | if(pci->rc.flRecordAttr & CRA_SELECTED) | 
|---|
| 793 | WinSendMsg(hwndCnr, | 
|---|
| 794 | CM_SETRECORDEMPHASIS, | 
|---|
| 795 | MPFROMP(pci), | 
|---|
| 796 | MPFROM2SHORT(FALSE, | 
|---|
| 797 | CRA_SELECTED)); | 
|---|
| 798 | if(dcd->type == DIR_FRAME) | 
|---|
| 799 | dcd->totalbytes -= (pci->cbFile + pci->easize); | 
|---|
| 800 | if(WinSendMsg(hwndCnr, | 
|---|
| 801 | CM_REMOVERECORD, | 
|---|
| 802 | MPFROMP(&pci), | 
|---|
| 803 | MPFROM2SHORT(1, | 
|---|
| 804 | CMA_FREE | | 
|---|
| 805 | ((numremain == 1) ? | 
|---|
| 806 | CMA_INVALIDATE : 0)))) { | 
|---|
| 807 | numremain--; | 
|---|
| 808 | repos = TRUE; | 
|---|
| 809 | } | 
|---|
| 810 | } | 
|---|
| 811 | } | 
|---|
| 812 | if(repos || (pciList && numlist)) { | 
|---|
| 813 |  | 
|---|
| 814 | QUERYRECORDRECT qrr; | 
|---|
| 815 | RECTL           rCnr,rCItem; | 
|---|
| 816 |  | 
|---|
| 817 | pci = WinSendMsg(hwndCnr, | 
|---|
| 818 | CM_QUERYRECORDEMPHASIS, | 
|---|
| 819 | MPFROMLONG(CMA_FIRST), | 
|---|
| 820 | MPFROMLONG(CRA_CURSORED)); | 
|---|
| 821 | if(pci && (INT)pci != -1) { | 
|---|
| 822 | memset(&qrr, 0, sizeof(QUERYRECORDRECT)); | 
|---|
| 823 | qrr.cb = sizeof(QUERYRECORDRECT); | 
|---|
| 824 | qrr.pRecord = (PRECORDCORE) pci; | 
|---|
| 825 | qrr.fRightSplitWindow = FALSE; | 
|---|
| 826 | qrr.fsExtent = CMA_TEXT; | 
|---|
| 827 | if(!WinSendMsg(hwndCnr, | 
|---|
| 828 | CM_QUERYRECORDRECT, | 
|---|
| 829 | MPFROMP(&rCItem), | 
|---|
| 830 | MPFROMP(&qrr))) | 
|---|
| 831 | qrr.cb = 0; | 
|---|
| 832 | } | 
|---|
| 833 | if(pciList && numlist && !repos) | 
|---|
| 834 | WinSendMsg(hwndCnr, | 
|---|
| 835 | CM_INVALIDATERECORD, | 
|---|
| 836 | MPFROMP(pciList), | 
|---|
| 837 | MPFROM2SHORT(numlist,((repos) ? | 
|---|
| 838 | CMA_NOREPOSITION : | 
|---|
| 839 | CMA_REPOSITION | CMA_ERASE))); | 
|---|
| 840 | if(repos) | 
|---|
| 841 | WinSendMsg(hwndCnr, | 
|---|
| 842 | CM_INVALIDATERECORD, | 
|---|
| 843 | MPVOID, | 
|---|
| 844 | MPFROM2SHORT(0, | 
|---|
| 845 | CMA_ERASE | CMA_REPOSITION)); | 
|---|
| 846 | if(pci && (INT)pci != -1 && qrr.cb) { | 
|---|
| 847 | WinSendMsg(hwndCnr, | 
|---|
| 848 | CM_QUERYVIEWPORTRECT, | 
|---|
| 849 | MPFROMP(&rCnr), | 
|---|
| 850 | MPFROM2SHORT(CMA_WINDOW, | 
|---|
| 851 | (SHORT)FALSE)); | 
|---|
| 852 | WinSendMsg(hwndCnr, | 
|---|
| 853 | CM_SCROLLWINDOW, | 
|---|
| 854 | MPFROMSHORT(CMA_VERTICAL), | 
|---|
| 855 | MPFROMLONG(rCnr.yTop - rCItem.yTop)); | 
|---|
| 856 | } | 
|---|
| 857 | } | 
|---|
| 858 | PostMsg(hwndCnr, | 
|---|
| 859 | UM_RESCAN, | 
|---|
| 860 | MPVOID, | 
|---|
| 861 | MPVOID); | 
|---|
| 862 | if(pciList) { | 
|---|
| 863 | free(pciList); | 
|---|
| 864 | DosPostEventSem(CompactSem); | 
|---|
| 865 | } | 
|---|
| 866 | return ret; | 
|---|
| 867 | } | 
|---|
| 868 |  | 
|---|