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