| 1 | 
 | 
|---|
| 2 | /***********************************************************************
 | 
|---|
| 3 | 
 | 
|---|
| 4 |   $Id: filldir.c 246 2005-08-13 21:00:07Z root $
 | 
|---|
| 5 | 
 | 
|---|
| 6 |   Fill Directory Tree Containers
 | 
|---|
| 7 | 
 | 
|---|
| 8 |   Copyright (c) 1993-98 M. Kimes
 | 
|---|
| 9 |   Copyright (c) 2001, 2005 Steven H. Levine
 | 
|---|
| 10 | 
 | 
|---|
| 11 |   12 Sep 02 SHL Rework symbols to understand code
 | 
|---|
| 12 |   08 Feb 03 SHL DropHelp: calc EA size consistently
 | 
|---|
| 13 |   11 Jun 03 SHL Add JFS and FAT32 support
 | 
|---|
| 14 |   10 Jan 04 SHL ProcessDirectory: avoid most large drive failures
 | 
|---|
| 15 |   24 May 05 SHL Rework Win_Error usage
 | 
|---|
| 16 |   24 May 05 SHL Rework for CNRITEM.szSubject
 | 
|---|
| 17 |   25 May 05 SHL Rework for ULONGLONG
 | 
|---|
| 18 |   25 May 05 SHL Rework FillInRecordFromFFB
 | 
|---|
| 19 |   25 May 05 SHL Rework FillTreeCnr
 | 
|---|
| 20 |   28 May 05 SHL Drop stale debug code
 | 
|---|
| 21 |   05 Jun 05 SHL Comments
 | 
|---|
| 22 |   09 Jun 05 SHL Rework WinLoadFileIcon enables
 | 
|---|
| 23 |   09 Jun 05 SHL Rework IDFile
 | 
|---|
| 24 |   13 Aug 05 SHL Renames
 | 
|---|
| 25 | 
 | 
|---|
| 26 | ***********************************************************************/
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #define INCL_DOS
 | 
|---|
| 29 | #define INCL_WIN
 | 
|---|
| 30 | #define INCL_LONGLONG
 | 
|---|
| 31 | #include <os2.h>
 | 
|---|
| 32 | 
 | 
|---|
| 33 | #include <stdarg.h>
 | 
|---|
| 34 | #include <stdio.h>
 | 
|---|
| 35 | #include <stdlib.h>
 | 
|---|
| 36 | #include <string.h>
 | 
|---|
| 37 | #include <ctype.h>
 | 
|---|
| 38 | #include <time.h>
 | 
|---|
| 39 | 
 | 
|---|
| 40 | #include "fm3dll.h"
 | 
|---|
| 41 | #include "fm3str.h"
 | 
|---|
| 42 | 
 | 
|---|
| 43 | #pragma alloc_text(FILLDIR,FillInRecordFromFFB,FillInRecordFromFSA,IDFile)
 | 
|---|
| 44 | #pragma alloc_text(FILLDIR1,ProcessDirectory,FillDirCnr,FillTreeCnr)
 | 
|---|
| 45 | 
 | 
|---|
| 46 | 
 | 
|---|
| 47 | static HPOINTER IDFile(PSZ p)
 | 
|---|
| 48 | {
 | 
|---|
| 49 |   HPOINTER hptr;
 | 
|---|
| 50 |   ULONG    cmp;
 | 
|---|
| 51 |   CHAR     cmps[4];
 | 
|---|
| 52 | 
 | 
|---|
| 53 |   p = strrchr(p,'.');
 | 
|---|
| 54 |   if (p && !p[4])
 | 
|---|
| 55 |   {
 | 
|---|
| 56 |     cmps[0] = '.';
 | 
|---|
| 57 |     cmps[1] = toupper(p[1]);
 | 
|---|
| 58 |     cmps[2] = toupper(p[2]);
 | 
|---|
| 59 |     cmps[3] = toupper(p[3]);
 | 
|---|
| 60 | 
 | 
|---|
| 61 |     cmp = *(ULONG *)cmps;
 | 
|---|
| 62 | 
 | 
|---|
| 63 |     if (cmp == *(ULONG *)".EXE" || cmp == *(ULONG *)".CMD" ||
 | 
|---|
| 64 |         cmp == *(ULONG *)".BAT" || cmp == *(ULONG *)".COM")
 | 
|---|
| 65 |       hptr = hptrApp;
 | 
|---|
| 66 |     else if (cmp == *(ULONG *)".ZIP" || cmp == *(ULONG *)".LZH" ||
 | 
|---|
| 67 |              cmp == *(ULONG *)".ARJ" || cmp == *(ULONG *)".ARC" ||
 | 
|---|
| 68 |              cmp == *(ULONG *)".ZOO" || cmp == *(ULONG *)".RAR")
 | 
|---|
| 69 |       hptr = hptrArc;
 | 
|---|
| 70 |     else if (cmp == *(ULONG *)".BMP" || cmp == *(ULONG *)".ICO" ||
 | 
|---|
| 71 |              cmp == *(ULONG *)".PTR" || cmp == *(ULONG *)".GIF" ||
 | 
|---|
| 72 |              cmp == *(ULONG *)".TIF" || cmp == *(ULONG *)".PCX" ||
 | 
|---|
| 73 |              cmp == *(ULONG *)".TGA" || cmp == *(ULONG *)".XBM")
 | 
|---|
| 74 |       hptr = hptrArt;
 | 
|---|
| 75 |     else
 | 
|---|
| 76 |       hptr = (HPOINTER)0;
 | 
|---|
| 77 |   }
 | 
|---|
| 78 |   else
 | 
|---|
| 79 |     hptr = (HPOINTER)0;
 | 
|---|
| 80 | 
 | 
|---|
| 81 |   return hptr;
 | 
|---|
| 82 | }
 | 
|---|
| 83 | 
 | 
|---|
| 84 | 
 | 
|---|
| 85 | static BOOL IsDefaultIcon(HPOINTER hptr)
 | 
|---|
| 86 | {
 | 
|---|
| 87 |   HPOINTER hptr2;
 | 
|---|
| 88 |   HPOINTER hptr3;
 | 
|---|
| 89 |   LONG l;
 | 
|---|
| 90 |   UINT u;
 | 
|---|
| 91 | 
 | 
|---|
| 92 |   static HPOINTER hptrPMFile;
 | 
|---|
| 93 |   static HPOINTER hptrWPSFile;
 | 
|---|
| 94 | 
 | 
|---|
| 95 |   if (!hptrPMFile)
 | 
|---|
| 96 |   {
 | 
|---|
| 97 | #   if 0 // fixme to be gone
 | 
|---|
| 98 |     for (l = 1; l <= SPTR_CPTR; l++)
 | 
|---|
| 99 |     {
 | 
|---|
| 100 |       hptr3 = WinQuerySysPointer(HWND_DESKTOP,l,FALSE);
 | 
|---|
| 101 |       fprintf(stderr, "0x%08lx SPTR %ld\n", hptr3, l);
 | 
|---|
| 102 |     }
 | 
|---|
| 103 | #   endif // fixme to be gone
 | 
|---|
| 104 |     hptrPMFile = WinQuerySysPointer(HWND_DESKTOP,SPTR_FILE,FALSE);
 | 
|---|
| 105 |   }
 | 
|---|
| 106 | # if 0 // fixme to be gone
 | 
|---|
| 107 |   else
 | 
|---|
| 108 |   {
 | 
|---|
| 109 |     hptr2 = WinQuerySysPointer(HWND_DESKTOP,SPTR_FILE,FALSE);
 | 
|---|
| 110 |     if (hptr2 != hptrPMFile)
 | 
|---|
| 111 |     {
 | 
|---|
| 112 |       saymsg(0, NULLHANDLE, "*Debug*", "ptr changed from %lx to %lx", hptrPMFile, hptr2);
 | 
|---|
| 113 |       hptrPMFile = hptr2;
 | 
|---|
| 114 |       fprintf(stderr, "0x%08lx SPTR_FILE changed\n", hptrPMFile);
 | 
|---|
| 115 |     }
 | 
|---|
| 116 |   }
 | 
|---|
| 117 | # endif // fixme to be gone
 | 
|---|
| 118 | 
 | 
|---|
| 119 |   // try to guess WPS default file icon
 | 
|---|
| 120 |   hptr2 = (HPOINTER)0;
 | 
|---|
| 121 |   for (u = 0; !hptrWPSFile && u < 10; u++)
 | 
|---|
| 122 |   {
 | 
|---|
| 123 |     char szFileName[CCHMAXPATH];
 | 
|---|
| 124 |     char *psz;
 | 
|---|
| 125 | 
 | 
|---|
| 126 |     psz = getenv("TMP");
 | 
|---|
| 127 |     if (!psz && *psz)
 | 
|---|
| 128 |       psz = getenv("TEMP");
 | 
|---|
| 129 |     if (psz && *psz)
 | 
|---|
| 130 |     {
 | 
|---|
| 131 |       strcpy(szFileName, psz);
 | 
|---|
| 132 |       psz = szFileName + strlen(szFileName) - 1;
 | 
|---|
| 133 |       if (*psz != '\\')
 | 
|---|
| 134 |       {
 | 
|---|
| 135 |         psz++;
 | 
|---|
| 136 |         *psz++ = '\\';
 | 
|---|
| 137 |       }
 | 
|---|
| 138 |     }
 | 
|---|
| 139 |     else
 | 
|---|
| 140 |       psz = szFileName;
 | 
|---|
| 141 | 
 | 
|---|
| 142 |     sprintf(psz,"%08x.%03x",rand() & 0xffffffff, rand() & 0xfff);
 | 
|---|
| 143 |     if (IsFile(szFileName) != 1)
 | 
|---|
| 144 |     {
 | 
|---|
| 145 |       FILE *fp = fopen(szFileName,"w");
 | 
|---|
| 146 |       if (fp)
 | 
|---|
| 147 |       {
 | 
|---|
| 148 |         fclose(fp);
 | 
|---|
| 149 |         hptr3 = WinLoadFileIcon(szFileName, FALSE);
 | 
|---|
| 150 | #       if 0  // fixme to be gone
 | 
|---|
| 151 |         fprintf(stderr, "0x%08lx %s\n", hptr3, szFileName);
 | 
|---|
| 152 | #       endif // fixme to be gone
 | 
|---|
| 153 |         unlinkf("%s", szFileName);
 | 
|---|
| 154 |         if (!hptr2)
 | 
|---|
| 155 |           hptr2 = hptr3;
 | 
|---|
| 156 |         else if (hptr3 == hptr3)
 | 
|---|
| 157 |         {
 | 
|---|
| 158 |           hptrWPSFile = hptr3;          // Got same icon twice
 | 
|---|
| 159 |           break;
 | 
|---|
| 160 |         }
 | 
|---|
| 161 |       }
 | 
|---|
| 162 |     }
 | 
|---|
| 163 |     DosSleep(rand() % 100);
 | 
|---|
| 164 | 
 | 
|---|
| 165 |   } // for
 | 
|---|
| 166 | 
 | 
|---|
| 167 |   return hptr == hptrPMFile || hptr == hptrWPSFile;
 | 
|---|
| 168 | 
 | 
|---|
| 169 | } // IsDefaultIcon
 | 
|---|
| 170 | 
 | 
|---|
| 171 | 
 | 
|---|
| 172 | ULONGLONG FillInRecordFromFFB(HWND hwndCnr,PCNRITEM pci, const PSZ pszDirectory,
 | 
|---|
| 173 |                               const PFILEFINDBUF4 pffb,const BOOL partial,
 | 
|---|
| 174 |                               DIRCNRDATA *dcd)
 | 
|---|
| 175 | {
 | 
|---|
| 176 |   /* fill in a container record from a FILEFINDBUF4 structure */
 | 
|---|
| 177 | 
 | 
|---|
| 178 |   CHAR          attrstring[] = "RHS\0DA";
 | 
|---|
| 179 |   CHAR         *p;
 | 
|---|
| 180 |   HPOINTER      hptr;
 | 
|---|
| 181 |   UINT          x;
 | 
|---|
| 182 |   UINT          y;
 | 
|---|
| 183 |   UINT          t;
 | 
|---|
| 184 | 
 | 
|---|
| 185 |   pci->hwndCnr = hwndCnr;
 | 
|---|
| 186 |   t = strlen(pszDirectory);
 | 
|---|
| 187 |   memcpy(pci->szFileName,pszDirectory,t + 1);
 | 
|---|
| 188 |   /* note!  we cheat below, and accept the full pathname in pszDirectory
 | 
|---|
| 189 |      if !*pffb->achName.  speeds up and simplifies processing elsewhere
 | 
|---|
| 190 |      (like in update.c)
 | 
|---|
| 191 |   */
 | 
|---|
| 192 |   if (*pffb->achName)
 | 
|---|
| 193 |   {
 | 
|---|
| 194 |     p = pci->szFileName + (t - 1);
 | 
|---|
| 195 |     if (*p != '\\') {
 | 
|---|
| 196 |       p++;
 | 
|---|
| 197 |       *p = '\\';
 | 
|---|
| 198 |     }
 | 
|---|
| 199 |     p++;
 | 
|---|
| 200 |     memcpy(p,pffb->achName,pffb->cchName + 1);
 | 
|---|
| 201 |   }
 | 
|---|
| 202 |   /* load the object's Subject, if required */
 | 
|---|
| 203 |   if (pffb->cbList > 4L &&
 | 
|---|
| 204 |       dcd && fLoadSubject &&
 | 
|---|
| 205 |       (isalpha(*pci->szFileName) &&
 | 
|---|
| 206 |        !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADSUBJS)))
 | 
|---|
| 207 |   {
 | 
|---|
| 208 |     APIRET    rc;
 | 
|---|
| 209 |     EAOP2     eaop;
 | 
|---|
| 210 |     PGEA2LIST pgealist;
 | 
|---|
| 211 |     PFEA2LIST pfealist;
 | 
|---|
| 212 |     PGEA2     pgea;
 | 
|---|
| 213 |     PFEA2     pfea;
 | 
|---|
| 214 |     CHAR      *value;
 | 
|---|
| 215 | 
 | 
|---|
| 216 |     pgealist = malloc(sizeof(GEA2LIST) + 32);
 | 
|---|
| 217 |     if (pgealist)
 | 
|---|
| 218 |     {
 | 
|---|
| 219 |       memset(pgealist,0,sizeof(GEA2LIST) + 32);
 | 
|---|
| 220 |       pgea = &pgealist->list[0];
 | 
|---|
| 221 |       strcpy(pgea->szName,SUBJECT);
 | 
|---|
| 222 |       pgea->cbName = strlen(pgea->szName);
 | 
|---|
| 223 |       pgea->oNextEntryOffset = 0;
 | 
|---|
| 224 |       pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
 | 
|---|
| 225 |       pfealist = malloc(1532);
 | 
|---|
| 226 |       if (pfealist)
 | 
|---|
| 227 |       {
 | 
|---|
| 228 |         memset(pfealist,0,1532);
 | 
|---|
| 229 |         pfealist->cbList = 1024;
 | 
|---|
| 230 |         eaop.fpGEA2List = pgealist;
 | 
|---|
| 231 |         eaop.fpFEA2List = pfealist;
 | 
|---|
| 232 |         eaop.oError = 0;
 | 
|---|
| 233 |         rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
 | 
|---|
| 234 |                               (PVOID)&eaop,(ULONG)sizeof(EAOP2));
 | 
|---|
| 235 |         if (!rc) {
 | 
|---|
| 236 |           pfea = &eaop.fpFEA2List->list[0];
 | 
|---|
| 237 |           value = pfea->szName + pfea->cbName + 1;
 | 
|---|
| 238 |           value[pfea->cbValue] = 0;
 | 
|---|
| 239 |           if (*(USHORT *)value == EAT_ASCII)
 | 
|---|
| 240 |             strncpy(pci->szSubject,value + (sizeof(USHORT) * 2),39);
 | 
|---|
| 241 |           pci->szSubject[39] = 0;
 | 
|---|
| 242 |         }
 | 
|---|
| 243 |         free(pfealist);
 | 
|---|
| 244 |       }
 | 
|---|
| 245 |       free(pgealist);
 | 
|---|
| 246 |     }
 | 
|---|
| 247 |   }
 | 
|---|
| 248 |   pci->pszSubject = pci->szSubject;
 | 
|---|
| 249 |   /* load the object's longname */
 | 
|---|
| 250 |   *pci->szLongname = 0;
 | 
|---|
| 251 |   if (pffb->cbList > 4L &&
 | 
|---|
| 252 |       dcd && fLoadLongnames &&
 | 
|---|
| 253 |       (isalpha(*pci->szFileName) &&
 | 
|---|
| 254 |        (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLONGNAMES) &&
 | 
|---|
| 255 |        !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADLONGS)))
 | 
|---|
| 256 |   {
 | 
|---|
| 257 |     APIRET    rc;
 | 
|---|
| 258 |     EAOP2     eaop;
 | 
|---|
| 259 |     PGEA2LIST pgealist;
 | 
|---|
| 260 |     PFEA2LIST pfealist;
 | 
|---|
| 261 |     PGEA2     pgea;
 | 
|---|
| 262 |     PFEA2     pfea;
 | 
|---|
| 263 |     CHAR      *value;
 | 
|---|
| 264 | 
 | 
|---|
| 265 |     pgealist = malloc(sizeof(GEA2LIST) + 32);
 | 
|---|
| 266 |     if (pgealist)
 | 
|---|
| 267 |     {
 | 
|---|
| 268 |       memset(pgealist,0,sizeof(GEA2LIST) + 32);
 | 
|---|
| 269 |       pgea = &pgealist->list[0];
 | 
|---|
| 270 |       strcpy(pgea->szName,LONGNAME);
 | 
|---|
| 271 |       pgea->cbName = strlen(pgea->szName);
 | 
|---|
| 272 |       pgea->oNextEntryOffset = 0;
 | 
|---|
| 273 |       pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
 | 
|---|
| 274 |       pfealist = malloc(1532);
 | 
|---|
| 275 |       if (pfealist) {
 | 
|---|
| 276 |         memset(pfealist,0,1532);
 | 
|---|
| 277 |         pfealist->cbList = 1024;
 | 
|---|
| 278 |         eaop.fpGEA2List = pgealist;
 | 
|---|
| 279 |         eaop.fpFEA2List = pfealist;
 | 
|---|
| 280 |         eaop.oError = 0;
 | 
|---|
| 281 |         rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
 | 
|---|
| 282 |                               (PVOID)&eaop,(ULONG)sizeof(EAOP2));
 | 
|---|
| 283 |         if (!rc)
 | 
|---|
| 284 |         {
 | 
|---|
| 285 |           pfea = &eaop.fpFEA2List->list[0];
 | 
|---|
| 286 |           value = pfea->szName + pfea->cbName + 1;
 | 
|---|
| 287 |           value[pfea->cbValue] = 0;
 | 
|---|
| 288 |           if (*(USHORT *)value == EAT_ASCII)
 | 
|---|
| 289 |             strncpy(pci->szLongname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP);
 | 
|---|
| 290 |           pci->szLongname[CCHMAXPATHCOMP - 1] = 0;
 | 
|---|
| 291 |         }
 | 
|---|
| 292 |         free(pfealist);
 | 
|---|
| 293 |       }
 | 
|---|
| 294 |       free(pgealist);
 | 
|---|
| 295 |     }
 | 
|---|
| 296 |   }
 | 
|---|
| 297 |   pci->pszLongname = pci->szLongname;
 | 
|---|
| 298 | 
 | 
|---|
| 299 |   /* do anything required to case of filename */
 | 
|---|
| 300 |   if (fForceUpper)
 | 
|---|
| 301 |     strupr(pci->szFileName);
 | 
|---|
| 302 |   else if (fForceLower)
 | 
|---|
| 303 |     strlwr(pci->szFileName);
 | 
|---|
| 304 | 
 | 
|---|
| 305 |   /* get an icon to use with it */
 | 
|---|
| 306 |   if (pffb->attrFile & FILE_DIRECTORY)
 | 
|---|
| 307 |   {
 | 
|---|
| 308 |     // is directory
 | 
|---|
| 309 |     if (fNoIconsDirs ||
 | 
|---|
| 310 |         (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS) ||
 | 
|---|
| 311 |         !isalpha(*pci->szFileName))
 | 
|---|
| 312 |     {
 | 
|---|
| 313 |       hptr = (HPOINTER)0;
 | 
|---|
| 314 |     }
 | 
|---|
| 315 |     else
 | 
|---|
| 316 |       hptr = WinLoadFileIcon(pci->szFileName, FALSE);
 | 
|---|
| 317 |   }
 | 
|---|
| 318 |   else
 | 
|---|
| 319 |   {
 | 
|---|
| 320 |     // is file
 | 
|---|
| 321 |     if (fNoIconsFiles ||
 | 
|---|
| 322 |         (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS) ||
 | 
|---|
| 323 |         !isalpha(*pci->szFileName))
 | 
|---|
| 324 |     {
 | 
|---|
| 325 |       hptr = (HPOINTER)0;
 | 
|---|
| 326 |     }
 | 
|---|
| 327 |     else
 | 
|---|
| 328 |       hptr = WinLoadFileIcon(pci->szFileName, FALSE);
 | 
|---|
| 329 | 
 | 
|---|
| 330 |     if (!hptr || IsDefaultIcon(hptr))
 | 
|---|
| 331 |       hptr = IDFile(pci->szFileName);
 | 
|---|
| 332 |   }
 | 
|---|
| 333 | 
 | 
|---|
| 334 |   if (!hptr)
 | 
|---|
| 335 |   {
 | 
|---|
| 336 |     hptr = pffb->attrFile & FILE_DIRECTORY ?
 | 
|---|
| 337 |              hptrDir :
 | 
|---|
| 338 |              pffb->attrFile & FILE_SYSTEM ?
 | 
|---|
| 339 |                 hptrSystem :
 | 
|---|
| 340 |                 pffb->attrFile & FILE_HIDDEN ?
 | 
|---|
| 341 |                    hptrHidden :
 | 
|---|
| 342 |                    pffb->attrFile & FILE_READONLY ?
 | 
|---|
| 343 |                      hptrReadonly :
 | 
|---|
| 344 |                      hptrFile;
 | 
|---|
| 345 |   }
 | 
|---|
| 346 | 
 | 
|---|
| 347 |   /* decide where to point for the container's title text */
 | 
|---|
| 348 |   if (partial)
 | 
|---|
| 349 |   {
 | 
|---|
| 350 |     p = strrchr(pci->szFileName,'\\');
 | 
|---|
| 351 |     if (!p)
 | 
|---|
| 352 |     {
 | 
|---|
| 353 |       p = strrchr(pci->szFileName,':');
 | 
|---|
| 354 |       if (!p)
 | 
|---|
| 355 |         p = pci->szFileName;
 | 
|---|
| 356 |       else
 | 
|---|
| 357 |         p++;
 | 
|---|
| 358 |     }
 | 
|---|
| 359 |     else if ((dcd && dcd->type == TREE_FRAME) ||
 | 
|---|
| 360 |              (!(pffb->attrFile & FILE_DIRECTORY) || !*(p + 1)))
 | 
|---|
| 361 |     {
 | 
|---|
| 362 |       p++;
 | 
|---|
| 363 |     }
 | 
|---|
| 364 |     if (!*p)
 | 
|---|
| 365 |       p = pci->szFileName;
 | 
|---|
| 366 |   }
 | 
|---|
| 367 |   else
 | 
|---|
| 368 |     p = pci->szFileName;
 | 
|---|
| 369 |   /* now fill the darned thing in... */
 | 
|---|
| 370 |   pci->pszFileName    = p;
 | 
|---|
| 371 |   pci->date.day       = pffb->fdateLastWrite.day;
 | 
|---|
| 372 |   pci->date.month     = pffb->fdateLastWrite.month;
 | 
|---|
| 373 |   pci->date.year      = pffb->fdateLastWrite.year + 1980;
 | 
|---|
| 374 |   pci->time.seconds   = pffb->ftimeLastWrite.twosecs * 2;
 | 
|---|
| 375 |   pci->time.minutes   = pffb->ftimeLastWrite.minutes;
 | 
|---|
| 376 |   pci->time.hours     = pffb->ftimeLastWrite.hours;
 | 
|---|
| 377 |   pci->ladate.day     = pffb->fdateLastAccess.day;
 | 
|---|
| 378 |   pci->ladate.month   = pffb->fdateLastAccess.month;
 | 
|---|
| 379 |   pci->ladate.year    = pffb->fdateLastAccess.year + 1980;
 | 
|---|
| 380 |   pci->latime.seconds = pffb->ftimeLastAccess.twosecs * 2;
 | 
|---|
| 381 |   pci->latime.minutes = pffb->ftimeLastAccess.minutes;
 | 
|---|
| 382 |   pci->latime.hours   = pffb->ftimeLastAccess.hours;
 | 
|---|
| 383 |   pci->crdate.day     = pffb->fdateCreation.day;
 | 
|---|
| 384 |   pci->crdate.month   = pffb->fdateCreation.month;
 | 
|---|
| 385 |   pci->crdate.year    = pffb->fdateCreation.year + 1980;
 | 
|---|
| 386 |   pci->crtime.seconds = pffb->ftimeCreation.twosecs * 2;
 | 
|---|
| 387 |   pci->crtime.minutes = pffb->ftimeCreation.minutes;
 | 
|---|
| 388 |   pci->crtime.hours   = pffb->ftimeCreation.hours;
 | 
|---|
| 389 |   pci->easize         = CBLIST_TO_EASIZE(pffb->cbList);
 | 
|---|
| 390 |   pci->cbFile         = pffb->cbFile;
 | 
|---|
| 391 |   pci->attrFile       = pffb->attrFile;
 | 
|---|
| 392 |   /* build attribute string for display */
 | 
|---|
| 393 |   y = 0;
 | 
|---|
| 394 |   for (x = 0; x < 6; x++)
 | 
|---|
| 395 |   {
 | 
|---|
| 396 |     if (attrstring[x])
 | 
|---|
| 397 |     {
 | 
|---|
| 398 |       pci->szDispAttr[y++] =
 | 
|---|
| 399 |         (CHAR)((pci->attrFile & (1 << x)) ? attrstring[x] : '-');
 | 
|---|
| 400 |     }
 | 
|---|
| 401 |   }
 | 
|---|
| 402 |   pci->szDispAttr[5]  = 0;
 | 
|---|
| 403 |   pci->pszDispAttr    = pci->szDispAttr;
 | 
|---|
| 404 |   pci->rc.pszIcon     = pci->pszFileName;
 | 
|---|
| 405 |   pci->rc.hptrIcon    = hptr;
 | 
|---|
| 406 | 
 | 
|---|
| 407 |   /* check to see if record should be visible */
 | 
|---|
| 408 |   if (dcd && (*dcd->mask.szMask || dcd->mask.antiattr ||
 | 
|---|
| 409 |       ((dcd->mask.attrFile &
 | 
|---|
| 410 |        (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) !=
 | 
|---|
| 411 |        (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED))))
 | 
|---|
| 412 |   {
 | 
|---|
| 413 |     if (*dcd->mask.szMask || dcd->mask.antiattr)
 | 
|---|
| 414 |     {
 | 
|---|
| 415 |       if(!Filter((PMINIRECORDCORE)pci,(PVOID)&dcd->mask))
 | 
|---|
| 416 |         pci->rc.flRecordAttr |= CRA_FILTERED;
 | 
|---|
| 417 |     }
 | 
|---|
| 418 |     else if((!(dcd->mask.attrFile & FILE_HIDDEN) &&
 | 
|---|
| 419 |              (pci->attrFile & FILE_HIDDEN)) ||
 | 
|---|
| 420 |             (!(dcd->mask.attrFile & FILE_SYSTEM) &&
 | 
|---|
| 421 |              (pci->attrFile & FILE_SYSTEM)) ||
 | 
|---|
| 422 |             (!(dcd->mask.attrFile & FILE_READONLY) &&
 | 
|---|
| 423 |              (pci->attrFile & FILE_READONLY)) ||
 | 
|---|
| 424 |             (!(dcd->mask.attrFile & FILE_ARCHIVED) &&
 | 
|---|
| 425 |              (pci->attrFile & FILE_ARCHIVED)))
 | 
|---|
| 426 |     {
 | 
|---|
| 427 |       pci->rc.flRecordAttr |= CRA_FILTERED;
 | 
|---|
| 428 |     }
 | 
|---|
| 429 |   }
 | 
|---|
| 430 | 
 | 
|---|
| 431 |   return pffb->cbFile + pci->easize;
 | 
|---|
| 432 | 
 | 
|---|
| 433 | } // FillInRecordFromFFB
 | 
|---|
| 434 | 
 | 
|---|
| 435 | 
 | 
|---|
| 436 | ULONGLONG FillInRecordFromFSA(HWND hwndCnr,
 | 
|---|
| 437 |                               PCNRITEM pci,
 | 
|---|
| 438 |                               const PSZ pszFileName,
 | 
|---|
| 439 |                               const PFILESTATUS4 pfsa4,
 | 
|---|
| 440 |                               const BOOL partial,
 | 
|---|
| 441 |                               DIRCNRDATA *dcd)          // Optional
 | 
|---|
| 442 | {
 | 
|---|
| 443 |   HPOINTER       hptr;
 | 
|---|
| 444 |   CHAR           attrstring[] = "RHS\0DA";
 | 
|---|
| 445 |   register CHAR *p;
 | 
|---|
| 446 |   register INT   x;
 | 
|---|
| 447 |   register INT   y;
 | 
|---|
| 448 | 
 | 
|---|
| 449 |   /* fill in a container record from a FILESTATUS4 structure */
 | 
|---|
| 450 | 
 | 
|---|
| 451 |   pci->hwndCnr = hwndCnr;
 | 
|---|
| 452 |   strcpy(pci->szFileName,pszFileName);
 | 
|---|
| 453 |   /* load the object's Subject, if required */
 | 
|---|
| 454 |   if (pfsa4->cbList > 4L &&
 | 
|---|
| 455 |       dcd &&
 | 
|---|
| 456 |       fLoadSubject &&
 | 
|---|
| 457 |       (!isalpha(*pci->szFileName) ||
 | 
|---|
| 458 |        !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADSUBJS)))
 | 
|---|
| 459 |   {
 | 
|---|
| 460 |     APIRET    rc;
 | 
|---|
| 461 |     EAOP2     eaop;
 | 
|---|
| 462 |     PGEA2LIST pgealist;
 | 
|---|
| 463 |     PFEA2LIST pfealist;
 | 
|---|
| 464 |     PGEA2     pgea;
 | 
|---|
| 465 |     PFEA2     pfea;
 | 
|---|
| 466 |     CHAR      *value;
 | 
|---|
| 467 | 
 | 
|---|
| 468 |     pgealist = malloc(sizeof(GEA2LIST) + 32);
 | 
|---|
| 469 |     if (pgealist) {
 | 
|---|
| 470 |       memset(pgealist,0,sizeof(GEA2LIST) + 32);
 | 
|---|
| 471 |       pgea = &pgealist->list[0];
 | 
|---|
| 472 |       strcpy(pgea->szName,SUBJECT);
 | 
|---|
| 473 |       pgea->cbName = strlen(pgea->szName);
 | 
|---|
| 474 |       pgea->oNextEntryOffset = 0;
 | 
|---|
| 475 |       pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
 | 
|---|
| 476 |       pfealist = malloc(1532);
 | 
|---|
| 477 |       if (pfealist) {
 | 
|---|
| 478 |         memset(pfealist,0,1532);
 | 
|---|
| 479 |         pfealist->cbList = 1024;
 | 
|---|
| 480 |         eaop.fpGEA2List = pgealist;
 | 
|---|
| 481 |         eaop.fpFEA2List = pfealist;
 | 
|---|
| 482 |         eaop.oError = 0;
 | 
|---|
| 483 |         rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
 | 
|---|
| 484 |                               (PVOID)&eaop,
 | 
|---|
| 485 |                               (ULONG)sizeof(EAOP2));
 | 
|---|
| 486 |         if (!rc) {
 | 
|---|
| 487 |           pfea = &eaop.fpFEA2List->list[0];
 | 
|---|
| 488 |           value = pfea->szName + pfea->cbName + 1;
 | 
|---|
| 489 |           value[pfea->cbValue] = 0;
 | 
|---|
| 490 |           if (*(USHORT *)value == EAT_ASCII)
 | 
|---|
| 491 |             strncpy(pci->szSubject,value + (sizeof(USHORT) * 2),39);
 | 
|---|
| 492 |           pci->szSubject[39] = 0;
 | 
|---|
| 493 |         }
 | 
|---|
| 494 |         free(pfealist);
 | 
|---|
| 495 |       }
 | 
|---|
| 496 |       free(pgealist);
 | 
|---|
| 497 |     }
 | 
|---|
| 498 |   }
 | 
|---|
| 499 |   pci->pszSubject = pci->szSubject;
 | 
|---|
| 500 |   *pci->szLongname = 0;
 | 
|---|
| 501 |   if (pfsa4->cbList > 4L &&
 | 
|---|
| 502 |       dcd &&
 | 
|---|
| 503 |       fLoadLongnames &&
 | 
|---|
| 504 |       (!isalpha(*pci->szFileName) ||
 | 
|---|
| 505 |        ((driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLONGNAMES) &&
 | 
|---|
| 506 |        !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADLONGS))))
 | 
|---|
| 507 |   {
 | 
|---|
| 508 |     APIRET    rc;
 | 
|---|
| 509 |     EAOP2     eaop;
 | 
|---|
| 510 |     PGEA2LIST pgealist;
 | 
|---|
| 511 |     PFEA2LIST pfealist;
 | 
|---|
| 512 |     PGEA2     pgea;
 | 
|---|
| 513 |     PFEA2     pfea;
 | 
|---|
| 514 |     CHAR      *value;
 | 
|---|
| 515 | 
 | 
|---|
| 516 |     pgealist = malloc(sizeof(GEA2LIST) + 32);
 | 
|---|
| 517 |     if (pgealist) {
 | 
|---|
| 518 |       memset(pgealist,0,sizeof(GEA2LIST) + 32);
 | 
|---|
| 519 |       pgea = &pgealist->list[0];
 | 
|---|
| 520 |       strcpy(pgea->szName,LONGNAME);
 | 
|---|
| 521 |       pgea->cbName = strlen(pgea->szName);
 | 
|---|
| 522 |       pgea->oNextEntryOffset = 0;
 | 
|---|
| 523 |       pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
 | 
|---|
| 524 |       pfealist = malloc(1532);
 | 
|---|
| 525 |       if (pfealist) {
 | 
|---|
| 526 |         memset(pfealist,0,1532);
 | 
|---|
| 527 |         pfealist->cbList = 1024;
 | 
|---|
| 528 |         eaop.fpGEA2List = pgealist;
 | 
|---|
| 529 |         eaop.fpFEA2List = pfealist;
 | 
|---|
| 530 |         eaop.oError = 0;
 | 
|---|
| 531 |         rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
 | 
|---|
| 532 |                               (PVOID)&eaop,(ULONG)sizeof(EAOP2));
 | 
|---|
| 533 |         if (!rc) {
 | 
|---|
| 534 |           pfea = &eaop.fpFEA2List->list[0];
 | 
|---|
| 535 |           value = pfea->szName + pfea->cbName + 1;
 | 
|---|
| 536 |           value[pfea->cbValue] = 0;
 | 
|---|
| 537 |           if (*(USHORT *)value == EAT_ASCII)
 | 
|---|
| 538 |             strncpy(pci->szLongname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP);
 | 
|---|
| 539 |           pci->szLongname[CCHMAXPATHCOMP - 1] = 0;
 | 
|---|
| 540 |         }
 | 
|---|
| 541 |         free(pfealist);
 | 
|---|
| 542 |       }
 | 
|---|
| 543 |       free(pgealist);
 | 
|---|
| 544 |     }
 | 
|---|
| 545 |   }
 | 
|---|
| 546 |   pci->pszLongname = pci->szLongname;
 | 
|---|
| 547 |   if (fForceUpper)
 | 
|---|
| 548 |     strupr(pci->szFileName);
 | 
|---|
| 549 |   else if (fForceLower)
 | 
|---|
| 550 |     strlwr(pci->szFileName);
 | 
|---|
| 551 | 
 | 
|---|
| 552 |   if (pfsa4->attrFile & FILE_DIRECTORY)
 | 
|---|
| 553 |   {
 | 
|---|
| 554 |     if (fNoIconsDirs ||
 | 
|---|
| 555 |         (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS) ||
 | 
|---|
| 556 |         !isalpha(*pci->szFileName))
 | 
|---|
| 557 |     {
 | 
|---|
| 558 |       hptr = (HPOINTER)0;
 | 
|---|
| 559 |     }
 | 
|---|
| 560 |     else
 | 
|---|
| 561 |       hptr = WinLoadFileIcon(pci->szFileName, FALSE);
 | 
|---|
| 562 |   }
 | 
|---|
| 563 |   else
 | 
|---|
| 564 |   {
 | 
|---|
| 565 |     if (fNoIconsFiles ||
 | 
|---|
| 566 |         (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS) ||
 | 
|---|
| 567 |         !isalpha(*pci->szFileName))
 | 
|---|
| 568 |     {
 | 
|---|
| 569 |       hptr = IDFile(pci->szFileName);
 | 
|---|
| 570 |     }
 | 
|---|
| 571 |     else
 | 
|---|
| 572 |       hptr = WinLoadFileIcon(pci->szFileName, FALSE);
 | 
|---|
| 573 |   }
 | 
|---|
| 574 |   if (!hptr)
 | 
|---|
| 575 |   {
 | 
|---|
| 576 |     hptr = pfsa4->attrFile & FILE_DIRECTORY ?
 | 
|---|
| 577 |              hptrDir :
 | 
|---|
| 578 |              pfsa4->attrFile & FILE_SYSTEM ?
 | 
|---|
| 579 |                 hptrSystem :
 | 
|---|
| 580 |                 pfsa4->attrFile & FILE_HIDDEN ?
 | 
|---|
| 581 |                   hptrHidden :
 | 
|---|
| 582 |                   pfsa4->attrFile & FILE_READONLY ?
 | 
|---|
| 583 |                      hptrReadonly :
 | 
|---|
| 584 |                      hptrFile;
 | 
|---|
| 585 |   }
 | 
|---|
| 586 | 
 | 
|---|
| 587 |   if (partial)
 | 
|---|
| 588 |   {
 | 
|---|
| 589 |     p = strrchr(pci->szFileName,'\\');
 | 
|---|
| 590 |     if (!p) {
 | 
|---|
| 591 |         p = strrchr(pci->szFileName,':');
 | 
|---|
| 592 |       if (!p)
 | 
|---|
| 593 |         p = pci->szFileName;
 | 
|---|
| 594 |       else
 | 
|---|
| 595 |         p++;
 | 
|---|
| 596 |     }
 | 
|---|
| 597 |     else if ((dcd && dcd->type == TREE_FRAME) ||
 | 
|---|
| 598 |              !(pfsa4->attrFile & FILE_DIRECTORY) ||
 | 
|---|
| 599 |              !*(p + 1))
 | 
|---|
| 600 |       p++;
 | 
|---|
| 601 |     if (!*p)
 | 
|---|
| 602 |       p = pci->szFileName;
 | 
|---|
| 603 |   }
 | 
|---|
| 604 |   else
 | 
|---|
| 605 |     p = pci->szFileName;
 | 
|---|
| 606 |   pci->pszFileName    = p;
 | 
|---|
| 607 |   pci->date.day       = pfsa4->fdateLastWrite.day;
 | 
|---|
| 608 |   pci->date.month     = pfsa4->fdateLastWrite.month;
 | 
|---|
| 609 |   pci->date.year      = pfsa4->fdateLastWrite.year + 1980;
 | 
|---|
| 610 |   pci->time.seconds   = pfsa4->ftimeLastWrite.twosecs * 2;
 | 
|---|
| 611 |   pci->time.minutes   = pfsa4->ftimeLastWrite.minutes;
 | 
|---|
| 612 |   pci->time.hours     = pfsa4->ftimeLastWrite.hours;
 | 
|---|
| 613 |   pci->ladate.day     = pfsa4->fdateLastAccess.day;
 | 
|---|
| 614 |   pci->ladate.month   = pfsa4->fdateLastAccess.month;
 | 
|---|
| 615 |   pci->ladate.year    = pfsa4->fdateLastAccess.year + 1980;
 | 
|---|
| 616 |   pci->latime.seconds = pfsa4->ftimeLastAccess.twosecs * 2;
 | 
|---|
| 617 |   pci->latime.minutes = pfsa4->ftimeLastAccess.minutes;
 | 
|---|
| 618 |   pci->latime.hours   = pfsa4->ftimeLastAccess.hours;
 | 
|---|
| 619 |   pci->crdate.day     = pfsa4->fdateCreation.day;
 | 
|---|
| 620 |   pci->crdate.month   = pfsa4->fdateCreation.month;
 | 
|---|
| 621 |   pci->crdate.year    = pfsa4->fdateCreation.year + 1980;
 | 
|---|
| 622 |   pci->crtime.seconds = pfsa4->ftimeCreation.twosecs * 2;
 | 
|---|
| 623 |   pci->crtime.minutes = pfsa4->ftimeCreation.minutes;
 | 
|---|
| 624 |   pci->crtime.hours   = pfsa4->ftimeCreation.hours;
 | 
|---|
| 625 |   pci->easize         = CBLIST_TO_EASIZE(pfsa4->cbList);
 | 
|---|
| 626 |   pci->cbFile         = pfsa4->cbFile;
 | 
|---|
| 627 |   pci->attrFile       = pfsa4->attrFile;
 | 
|---|
| 628 |   y = 0;
 | 
|---|
| 629 |   for(x = 0;x < 6;x++)
 | 
|---|
| 630 |     if (attrstring[x])
 | 
|---|
| 631 |       pci->szDispAttr[y++] = (CHAR)((pci->attrFile & (1 << x)) ?
 | 
|---|
| 632 |                              attrstring[x] : '-');
 | 
|---|
| 633 |   pci->szDispAttr[5]  = 0;
 | 
|---|
| 634 |   pci->pszDispAttr    = pci->szDispAttr;
 | 
|---|
| 635 |   pci->rc.pszIcon     = pci->pszFileName;
 | 
|---|
| 636 |   pci->rc.hptrIcon    = hptr;
 | 
|---|
| 637 | 
 | 
|---|
| 638 |   if (dcd &&
 | 
|---|
| 639 |       (*dcd->mask.szMask || dcd->mask.antiattr ||
 | 
|---|
| 640 |        ((dcd->mask.attrFile &
 | 
|---|
| 641 |         (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) !=
 | 
|---|
| 642 |         (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED))))
 | 
|---|
| 643 |   {
 | 
|---|
| 644 |     if (*dcd->mask.szMask || dcd->mask.antiattr)
 | 
|---|
| 645 |     {
 | 
|---|
| 646 |       if (!Filter((PMINIRECORDCORE)pci,(PVOID)&dcd->mask))
 | 
|---|
| 647 |         pci->rc.flRecordAttr |= CRA_FILTERED;
 | 
|---|
| 648 |     }
 | 
|---|
| 649 |     else if ((!(dcd->mask.attrFile & FILE_HIDDEN) &&
 | 
|---|
| 650 |               (pci->attrFile & FILE_HIDDEN)) ||
 | 
|---|
| 651 |              (!(dcd->mask.attrFile & FILE_SYSTEM) &&
 | 
|---|
| 652 |               (pci->attrFile & FILE_SYSTEM)) ||
 | 
|---|
| 653 |              (!(dcd->mask.attrFile & FILE_READONLY) &&
 | 
|---|
| 654 |               (pci->attrFile & FILE_READONLY)) ||
 | 
|---|
| 655 |              (!(dcd->mask.attrFile & FILE_ARCHIVED) &&
 | 
|---|
| 656 |               (pci->attrFile & FILE_ARCHIVED)))
 | 
|---|
| 657 |       pci->rc.flRecordAttr |= CRA_FILTERED;
 | 
|---|
| 658 |   }
 | 
|---|
| 659 | 
 | 
|---|
| 660 |   return pfsa4->cbFile + pci->easize;
 | 
|---|
| 661 | 
 | 
|---|
| 662 | } // FillInRecordFromFSA
 | 
|---|
| 663 | 
 | 
|---|
| 664 | 
 | 
|---|
| 665 | VOID ProcessDirectory(const HWND hwndCnr, const PCNRITEM pciParent,
 | 
|---|
| 666 |                       const CHAR *szDirBase, const BOOL filestoo,
 | 
|---|
| 667 |                       const BOOL recurse,const BOOL partial,
 | 
|---|
| 668 |                       CHAR *stopflag,
 | 
|---|
| 669 |                       DIRCNRDATA *dcd,                  // Optional
 | 
|---|
| 670 |                       ULONG *pulTotalFiles,             // Optional
 | 
|---|
| 671 |                       PULONGLONG pullTotalBytes)        // Optional
 | 
|---|
| 672 | {
 | 
|---|
| 673 |   /* put all the directories (and files if filestoo is TRUE) from a
 | 
|---|
| 674 |    * directory into the container.  recurse through subdirectories if
 | 
|---|
| 675 |    * recurse is TRUE.
 | 
|---|
| 676 |    */
 | 
|---|
| 677 | 
 | 
|---|
| 678 |   PSZ            pszFileSpec;
 | 
|---|
| 679 |   INT            t;
 | 
|---|
| 680 |   PFILEFINDBUF4  paffbFound;
 | 
|---|
| 681 |   PFILEFINDBUF4  *papffbSelected;
 | 
|---|
| 682 |   PFILEFINDBUF4  pffbFile;
 | 
|---|
| 683 |   PFILEFINDBUF4  paffbTotal = NULL;
 | 
|---|
| 684 |   PFILEFINDBUF4  paffbTemp;
 | 
|---|
| 685 |   HDIR           hdir = HDIR_CREATE;
 | 
|---|
| 686 |   ULONG          ulFileCnt;
 | 
|---|
| 687 |   ULONG          ulExtraBytes;
 | 
|---|
| 688 |   ULONG          ulM = 1;
 | 
|---|
| 689 |   ULONG          ulTotal = 0;
 | 
|---|
| 690 |   ULONGLONG      ullBytes;
 | 
|---|
| 691 |   ULONGLONG      ullTotalBytes;
 | 
|---|
| 692 |   ULONG          ulReturnFiles = 0;
 | 
|---|
| 693 |   ULONGLONG      ullReturnBytes = 0;
 | 
|---|
| 694 |   PCH            pchEndPath;
 | 
|---|
| 695 |   APIRET         rc;
 | 
|---|
| 696 |   PCNRITEM       pci;
 | 
|---|
| 697 |   PCNRITEM       pciFirst;
 | 
|---|
| 698 |   PCNRITEM       pcit;
 | 
|---|
| 699 |   RECORDINSERT   ri;
 | 
|---|
| 700 |   PBYTE          pByte;
 | 
|---|
| 701 |   PBYTE          pByte2;
 | 
|---|
| 702 |   BOOL           ok = TRUE;
 | 
|---|
| 703 | 
 | 
|---|
| 704 |   if (isalpha(*szDirBase) && szDirBase[1] == ':' && szDirBase[2] == '\\')
 | 
|---|
| 705 |   {
 | 
|---|
| 706 |     // if (!(driveflags[toupper(*szDirBase) - 'A'] & DRIVE_NOLONGNAMES))
 | 
|---|
| 707 |       ulExtraBytes = EXTRA_RECORD_BYTES;
 | 
|---|
| 708 |     // else
 | 
|---|
| 709 |     // ulExtraBytes = EXTRA_RECORD_BYTES2;
 | 
|---|
| 710 |     if ((driveflags[toupper(*szDirBase) - 'A'] & DRIVE_REMOTE) && fRemoteBug)
 | 
|---|
| 711 |       ulM = 1;          /* file system gets confused */
 | 
|---|
| 712 |     else if (driveflags[toupper(*szDirBase) - 'A'] & DRIVE_ZIPSTREAM)
 | 
|---|
| 713 |       ulM = min(FilesToGet,225);        /* anything more is wasted */
 | 
|---|
| 714 |     else
 | 
|---|
| 715 |       ulM = FilesToGet;                 /* full-out */
 | 
|---|
| 716 |   }
 | 
|---|
| 717 |   else
 | 
|---|
| 718 |   {
 | 
|---|
| 719 |     ulExtraBytes = EXTRA_RECORD_BYTES;
 | 
|---|
| 720 |     ulM = FilesToGet;
 | 
|---|
| 721 |   }
 | 
|---|
| 722 |   if (OS2ver[0] == 20 && OS2ver[1] < 30)
 | 
|---|
| 723 |     ulM = min(ulM,(65535 / sizeof(FILEFINDBUF4)));
 | 
|---|
| 724 | 
 | 
|---|
| 725 |   ulFileCnt = ulM;
 | 
|---|
| 726 |   pszFileSpec = malloc(CCHMAXPATH + 2);
 | 
|---|
| 727 |   paffbFound = malloc((ulM + 1) * sizeof(FILEFINDBUF4));
 | 
|---|
| 728 |   papffbSelected = malloc((ulM + 1) * sizeof(PFILEFINDBUF4));
 | 
|---|
| 729 |   if (paffbFound && papffbSelected && pszFileSpec) {
 | 
|---|
| 730 |     t = strlen(szDirBase);
 | 
|---|
| 731 |     memcpy(pszFileSpec,szDirBase,t + 1);
 | 
|---|
| 732 |     pchEndPath = pszFileSpec + t;
 | 
|---|
| 733 |     if (*(pchEndPath - 1) != '\\') {
 | 
|---|
| 734 |       memcpy(pchEndPath,"\\",2);
 | 
|---|
| 735 |       pchEndPath++;
 | 
|---|
| 736 |     }
 | 
|---|
| 737 |     memcpy(pchEndPath,"*",2);
 | 
|---|
| 738 |     DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 739 |     rc = DosFindFirst(pszFileSpec, &hdir,
 | 
|---|
| 740 |                       FILE_NORMAL | ((filestoo) ? FILE_DIRECTORY :
 | 
|---|
| 741 |                       MUST_HAVE_DIRECTORY) | FILE_READONLY |
 | 
|---|
| 742 |                       FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
 | 
|---|
| 743 |                       paffbFound, ulM * sizeof(FILEFINDBUF4),
 | 
|---|
| 744 |                       &ulFileCnt, FIL_QUERYEASIZE);
 | 
|---|
| 745 |     priority_normal();
 | 
|---|
| 746 |     *pchEndPath = 0;
 | 
|---|
| 747 |     if (!rc)
 | 
|---|
| 748 |     {
 | 
|---|
| 749 |       while (!rc)
 | 
|---|
| 750 |       {
 | 
|---|
| 751 |         /*
 | 
|---|
| 752 |          * remove . and .. from list if present
 | 
|---|
| 753 |          * also counter file system bugs that sometimes
 | 
|---|
| 754 |          * allows normal files to slip through when
 | 
|---|
| 755 |          * only directories should appear (only a few
 | 
|---|
| 756 |          * network file systems exhibit such a problem).
 | 
|---|
| 757 |          */
 | 
|---|
| 758 |         register ULONG x;
 | 
|---|
| 759 | 
 | 
|---|
| 760 |         if (stopflag && *stopflag)
 | 
|---|
| 761 |           goto Abort;
 | 
|---|
| 762 |         pByte = (PBYTE)paffbFound;
 | 
|---|
| 763 |         for (x = 0;x < ulFileCnt;)
 | 
|---|
| 764 |         {
 | 
|---|
| 765 |           pffbFile = (PFILEFINDBUF4)pByte;
 | 
|---|
| 766 |           if (!*pffbFile->achName ||
 | 
|---|
| 767 |               (!filestoo && !(pffbFile->attrFile & FILE_DIRECTORY)) ||
 | 
|---|
| 768 |               (((pffbFile->attrFile & FILE_DIRECTORY) &&
 | 
|---|
| 769 |                 pffbFile->achName[0] == '.') &&
 | 
|---|
| 770 |                (!pffbFile->achName[1] || (pffbFile->achName[1] == '.' &&
 | 
|---|
| 771 |                 !pffbFile->achName[2]))))
 | 
|---|
| 772 |           {
 | 
|---|
| 773 |             ulFileCnt--;                // Got . or ..
 | 
|---|
| 774 |           }
 | 
|---|
| 775 |           else
 | 
|---|
| 776 |             papffbSelected[x++] = pffbFile;     // Count file
 | 
|---|
| 777 |           if (!pffbFile->oNextEntryOffset)
 | 
|---|
| 778 |           {
 | 
|---|
| 779 |             ulFileCnt = x;                      // Adjust count
 | 
|---|
| 780 |             break;
 | 
|---|
| 781 |           }
 | 
|---|
| 782 |           pByte += pffbFile->oNextEntryOffset;
 | 
|---|
| 783 |         }
 | 
|---|
| 784 |         if (ulFileCnt)
 | 
|---|
| 785 |         {
 | 
|---|
| 786 |           if (stopflag && *stopflag)
 | 
|---|
| 787 |             goto Abort;
 | 
|---|
| 788 |           if (fSyncUpdates)
 | 
|---|
| 789 |           {
 | 
|---|
| 790 |             pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
 | 
|---|
| 791 |                                   MPFROMLONG(ulExtraBytes),
 | 
|---|
| 792 |                                   MPFROMLONG(ulFileCnt));
 | 
|---|
| 793 |             if (pciFirst)
 | 
|---|
| 794 |             {
 | 
|---|
| 795 |               register INT   i;
 | 
|---|
| 796 | 
 | 
|---|
| 797 |               pci = pciFirst;
 | 
|---|
| 798 |               ullTotalBytes = 0;
 | 
|---|
| 799 |               for(i = 0; i < ulFileCnt; i++) {
 | 
|---|
| 800 |                 pffbFile = papffbSelected[i];
 | 
|---|
| 801 |                 ullBytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec,
 | 
|---|
| 802 |                                          pffbFile,partial,dcd);
 | 
|---|
| 803 |                 pci = (PCNRITEM)pci->rc.preccNextRecord;
 | 
|---|
| 804 |                 ullTotalBytes += ullBytes;
 | 
|---|
| 805 |               }
 | 
|---|
| 806 |               if (ulFileCnt)
 | 
|---|
| 807 |               {
 | 
|---|
| 808 |                 memset(&ri,0,sizeof(RECORDINSERT));
 | 
|---|
| 809 |                 ri.cb                 = sizeof(RECORDINSERT);
 | 
|---|
| 810 |                 ri.pRecordOrder       = (PRECORDCORE) CMA_END;
 | 
|---|
| 811 |                 ri.pRecordParent      = (PRECORDCORE) pciParent;
 | 
|---|
| 812 |                 ri.zOrder             = (ULONG) CMA_TOP;
 | 
|---|
| 813 |                 ri.cRecordsInsert     = ulFileCnt;
 | 
|---|
| 814 |                 ri.fInvalidateRecord  = (!fSyncUpdates && dcd &&
 | 
|---|
| 815 |                                          dcd->type == DIR_FRAME) ?
 | 
|---|
| 816 |                                           FALSE : TRUE;
 | 
|---|
| 817 |                 if (!WinSendMsg(hwndCnr,
 | 
|---|
| 818 |                                 CM_INSERTRECORD,
 | 
|---|
| 819 |                                 MPFROMP(pciFirst),
 | 
|---|
| 820 |                                 MPFROMP(&ri)))
 | 
|---|
| 821 |                 {
 | 
|---|
| 822 |                   DosSleep(100);
 | 
|---|
| 823 |                   WinSetFocus(HWND_DESKTOP,hwndCnr);
 | 
|---|
| 824 |                   if (!WinSendMsg(hwndCnr,
 | 
|---|
| 825 |                                   CM_INSERTRECORD,
 | 
|---|
| 826 |                                   MPFROMP(pciFirst),
 | 
|---|
| 827 |                                   MPFROMP(&ri)))
 | 
|---|
| 828 |                   {
 | 
|---|
| 829 |                     Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
 | 
|---|
| 830 |                               GetPString(IDS_FILLDIRERR2TEXT));
 | 
|---|
| 831 |                     ok = FALSE;
 | 
|---|
| 832 |                     ullTotalBytes = 0;
 | 
|---|
| 833 |                     if (WinIsWindow((HAB)0,hwndCnr))
 | 
|---|
| 834 |                     {
 | 
|---|
| 835 |                       pci = pciFirst;
 | 
|---|
| 836 |                       while (pci)
 | 
|---|
| 837 |                       {
 | 
|---|
| 838 |                         pcit = (PCNRITEM)pci->rc.preccNextRecord;
 | 
|---|
| 839 |                         WinSendMsg(hwndCnr,
 | 
|---|
| 840 |                                    CM_FREERECORD,
 | 
|---|
| 841 |                                    MPFROMP(&pci),
 | 
|---|
| 842 |                                    MPFROMSHORT(1));
 | 
|---|
| 843 |                         pci = pcit;
 | 
|---|
| 844 |                       }
 | 
|---|
| 845 |                     }
 | 
|---|
| 846 |                   }
 | 
|---|
| 847 |                 }
 | 
|---|
| 848 |               }
 | 
|---|
| 849 |             }
 | 
|---|
| 850 |             else
 | 
|---|
| 851 |             {
 | 
|---|
| 852 |               Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
 | 
|---|
| 853 |                         GetPString(IDS_FILLDIRERR3TEXT));
 | 
|---|
| 854 |               ok = FALSE;
 | 
|---|
| 855 |               ullTotalBytes = 0;
 | 
|---|
| 856 |             }
 | 
|---|
| 857 |             if (ok)
 | 
|---|
| 858 |             {
 | 
|---|
| 859 |               ullReturnBytes += ullTotalBytes;
 | 
|---|
| 860 |               ulReturnFiles += ulFileCnt;
 | 
|---|
| 861 |             }
 | 
|---|
| 862 |           }
 | 
|---|
| 863 |           else
 | 
|---|
| 864 |           {
 | 
|---|
| 865 |             paffbTemp = realloc(paffbTotal,sizeof(FILEFINDBUF4) *
 | 
|---|
| 866 |                                      (ulFileCnt + ulTotal));
 | 
|---|
| 867 |             if (paffbTemp)
 | 
|---|
| 868 |             {
 | 
|---|
| 869 |               paffbTotal = paffbTemp;
 | 
|---|
| 870 |               for(x = 0;x < ulFileCnt;x++)
 | 
|---|
| 871 |                 paffbTotal[x + ulTotal] = *papffbSelected[x];
 | 
|---|
| 872 |               ulTotal += ulFileCnt;
 | 
|---|
| 873 |             }
 | 
|---|
| 874 |             else
 | 
|---|
| 875 |             {
 | 
|---|
| 876 |               saymsg(MB_ENTER,
 | 
|---|
| 877 |                      HWND_DESKTOP,
 | 
|---|
| 878 |                      GetPString(IDS_ERRORTEXT),
 | 
|---|
| 879 |                      GetPString(IDS_OUTOFMEMORY));
 | 
|---|
| 880 |               break;
 | 
|---|
| 881 |             }
 | 
|---|
| 882 |           }
 | 
|---|
| 883 |         }
 | 
|---|
| 884 |         if (stopflag && *stopflag)
 | 
|---|
| 885 |             goto Abort;
 | 
|---|
| 886 |         ulFileCnt = ulM;
 | 
|---|
| 887 |         DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 888 |         rc = DosFindNext(hdir, paffbFound, ulM * sizeof(FILEFINDBUF4),
 | 
|---|
| 889 |                          &ulFileCnt);
 | 
|---|
| 890 |         priority_normal();
 | 
|---|
| 891 |         if (rc)
 | 
|---|
| 892 |           DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 893 |       }
 | 
|---|
| 894 |       DosFindClose(hdir);
 | 
|---|
| 895 | 
 | 
|---|
| 896 |       if (paffbFound || papffbSelected) {
 | 
|---|
| 897 |         if (paffbFound)
 | 
|---|
| 898 |           free(paffbFound);
 | 
|---|
| 899 |         if (papffbSelected)
 | 
|---|
| 900 |           free(papffbSelected);
 | 
|---|
| 901 |         papffbSelected = NULL;
 | 
|---|
| 902 |         paffbFound = NULL;
 | 
|---|
| 903 |       }
 | 
|---|
| 904 | 
 | 
|---|
| 905 |       if (ulTotal && paffbTotal)
 | 
|---|
| 906 |       {
 | 
|---|
| 907 | 
 | 
|---|
| 908 |         if (stopflag && *stopflag)
 | 
|---|
| 909 |           goto Abort;
 | 
|---|
| 910 | 
 | 
|---|
| 911 |         pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
 | 
|---|
| 912 |                               MPFROMLONG(ulExtraBytes),
 | 
|---|
| 913 |                               MPFROMLONG(ulTotal));
 | 
|---|
| 914 |         if (pciFirst)
 | 
|---|
| 915 |         {
 | 
|---|
| 916 |           register INT   i;
 | 
|---|
| 917 | 
 | 
|---|
| 918 |           pci = pciFirst;
 | 
|---|
| 919 |           ullTotalBytes = 0;
 | 
|---|
| 920 |           pByte2 = (PBYTE)paffbTotal;
 | 
|---|
| 921 |           for(i = 0; i < ulTotal; i++)
 | 
|---|
| 922 |           {
 | 
|---|
| 923 |             pffbFile = (PFILEFINDBUF4)pByte2;
 | 
|---|
| 924 |             ullBytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec,
 | 
|---|
| 925 |                                            pffbFile,partial,dcd);
 | 
|---|
| 926 |             pci = (PCNRITEM)pci->rc.preccNextRecord;
 | 
|---|
| 927 |             ullTotalBytes += ullBytes;
 | 
|---|
| 928 | 
 | 
|---|
| 929 |             pByte2 += sizeof(FILEFINDBUF4);
 | 
|---|
| 930 |           }
 | 
|---|
| 931 |           if (ulTotal)
 | 
|---|
| 932 |           {
 | 
|---|
| 933 |             memset(&ri,0,sizeof(RECORDINSERT));
 | 
|---|
| 934 |             ri.cb                 = sizeof(RECORDINSERT);
 | 
|---|
| 935 |             ri.pRecordOrder       = (PRECORDCORE) CMA_END;
 | 
|---|
| 936 |             ri.pRecordParent      = (PRECORDCORE) pciParent;
 | 
|---|
| 937 |             ri.zOrder             = (ULONG) CMA_TOP;
 | 
|---|
| 938 |             ri.cRecordsInsert     = ulTotal;
 | 
|---|
| 939 |             ri.fInvalidateRecord  = (!fSyncUpdates && dcd &&
 | 
|---|
| 940 |                                      dcd->type == DIR_FRAME) ?
 | 
|---|
| 941 |                                       FALSE : TRUE;
 | 
|---|
| 942 |             if (!WinSendMsg(hwndCnr,CM_INSERTRECORD,
 | 
|---|
| 943 |                             MPFROMP(pciFirst),MPFROMP(&ri)))
 | 
|---|
| 944 |             {
 | 
|---|
| 945 |               DosSleep(100);
 | 
|---|
| 946 |               WinSetFocus(HWND_DESKTOP,hwndCnr);
 | 
|---|
| 947 |               if (!WinSendMsg(hwndCnr,CM_INSERTRECORD,
 | 
|---|
| 948 |                              MPFROMP(pciFirst),MPFROMP(&ri)))
 | 
|---|
| 949 |               {
 | 
|---|
| 950 |                 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
 | 
|---|
| 951 |                           GetPString(IDS_FILLDIRERR5TEXT));
 | 
|---|
| 952 |                 ok = FALSE;
 | 
|---|
| 953 |                 ullTotalBytes = 0;
 | 
|---|
| 954 |                 if (WinIsWindow((HAB)0,hwndCnr))
 | 
|---|
| 955 |                 {
 | 
|---|
| 956 |                   pci = pciFirst;
 | 
|---|
| 957 |                   while (pci)
 | 
|---|
| 958 |                   {
 | 
|---|
| 959 |                     pcit = (PCNRITEM)pci->rc.preccNextRecord;
 | 
|---|
| 960 |                     WinSendMsg(hwndCnr,CM_FREERECORD,
 | 
|---|
| 961 |                                MPFROMP(&pci),MPFROMSHORT(1));
 | 
|---|
| 962 |                     pci = pcit;
 | 
|---|
| 963 |                   }
 | 
|---|
| 964 |                 }
 | 
|---|
| 965 |               }
 | 
|---|
| 966 |             }
 | 
|---|
| 967 |           }
 | 
|---|
| 968 |         }
 | 
|---|
| 969 |         else
 | 
|---|
| 970 |         {
 | 
|---|
| 971 |           Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
 | 
|---|
| 972 |                     GetPString(IDS_FILLDIRERR3TEXT));
 | 
|---|
| 973 |           ok = FALSE;
 | 
|---|
| 974 |           ullTotalBytes = 0;
 | 
|---|
| 975 |         }
 | 
|---|
| 976 |         if (ok)
 | 
|---|
| 977 |         {
 | 
|---|
| 978 |           ullReturnBytes += ullTotalBytes;
 | 
|---|
| 979 |           ulReturnFiles += ulFileCnt;
 | 
|---|
| 980 |         }
 | 
|---|
| 981 |       }
 | 
|---|
| 982 |     }
 | 
|---|
| 983 | 
 | 
|---|
| 984 |     if (!fSyncUpdates && dcd && dcd->type == DIR_FRAME)
 | 
|---|
| 985 |       WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID,
 | 
|---|
| 986 |                  MPFROM2SHORT(0,CMA_ERASE));
 | 
|---|
| 987 |   }
 | 
|---|
| 988 | Abort:
 | 
|---|
| 989 |   if (paffbTotal || papffbSelected || paffbFound || pszFileSpec)
 | 
|---|
| 990 |   {
 | 
|---|
| 991 |     if (paffbTotal)
 | 
|---|
| 992 |       free(paffbTotal);
 | 
|---|
| 993 |     if (pszFileSpec)
 | 
|---|
| 994 |       free(pszFileSpec);
 | 
|---|
| 995 |     if (paffbFound)
 | 
|---|
| 996 |       free(paffbFound);
 | 
|---|
| 997 |     if (papffbSelected)
 | 
|---|
| 998 |       free(papffbSelected);
 | 
|---|
| 999 |   }
 | 
|---|
| 1000 |   if (recurse)
 | 
|---|
| 1001 |   {
 | 
|---|
| 1002 |     pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent),
 | 
|---|
| 1003 |                      MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
 | 
|---|
| 1004 |     while (pci && (INT)pci != -1)
 | 
|---|
| 1005 |     {
 | 
|---|
| 1006 |       if (pci->attrFile & FILE_DIRECTORY)
 | 
|---|
| 1007 |         Stubby(hwndCnr,pci);
 | 
|---|
| 1008 |       pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
 | 
|---|
| 1009 |                        MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
 | 
|---|
| 1010 |     }
 | 
|---|
| 1011 |   }
 | 
|---|
| 1012 | 
 | 
|---|
| 1013 |   if (pulTotalFiles)
 | 
|---|
| 1014 |     *pulTotalFiles = ulReturnFiles;
 | 
|---|
| 1015 | 
 | 
|---|
| 1016 |   if (pullTotalBytes)
 | 
|---|
| 1017 |     *pullTotalBytes = ullReturnBytes;
 | 
|---|
| 1018 | 
 | 
|---|
| 1019 | } // ProcessDirectory
 | 
|---|
| 1020 | 
 | 
|---|
| 1021 | 
 | 
|---|
| 1022 | VOID FillDirCnr(HWND hwndCnr,
 | 
|---|
| 1023 |                 CHAR *pszDirectory,
 | 
|---|
| 1024 |                 DIRCNRDATA *dcd,
 | 
|---|
| 1025 |                 PULONGLONG pullTotalBytes)
 | 
|---|
| 1026 | {
 | 
|---|
| 1027 |   ProcessDirectory(hwndCnr,
 | 
|---|
| 1028 |                    (PCNRITEM)NULL,
 | 
|---|
| 1029 |                    pszDirectory,
 | 
|---|
| 1030 |                    TRUE,
 | 
|---|
| 1031 |                    FALSE,
 | 
|---|
| 1032 |                    TRUE,
 | 
|---|
| 1033 |                    dcd ? &dcd->stopflag : NULL,
 | 
|---|
| 1034 |                    dcd,
 | 
|---|
| 1035 |                    NULL,
 | 
|---|
| 1036 |                    pullTotalBytes);
 | 
|---|
| 1037 |   DosPostEventSem(CompactSem);
 | 
|---|
| 1038 | 
 | 
|---|
| 1039 | } // FillDirCnr
 | 
|---|
| 1040 | 
 | 
|---|
| 1041 | 
 | 
|---|
| 1042 | VOID FillTreeCnr(HWND hwndCnr,HWND hwndParent)
 | 
|---|
| 1043 | {
 | 
|---|
| 1044 |   ULONG       ulDriveNum,ulDriveMap,numtoinsert = 0,drvtype;
 | 
|---|
| 1045 |   PCNRITEM    pci,pciFirst = NULL,pciNext,pciParent = NULL;
 | 
|---|
| 1046 |   INT         x,removable;
 | 
|---|
| 1047 |   CHAR        szDrive[] = " :\\",FileSystem[CCHMAXPATH],suggest[32];
 | 
|---|
| 1048 |   FILESTATUS4 fsa4;
 | 
|---|
| 1049 |   APIRET      rc;
 | 
|---|
| 1050 |   BOOL        drivesbuilt = FALSE;
 | 
|---|
| 1051 |   static BOOL didonce = FALSE;
 | 
|---|
| 1052 | 
 | 
|---|
| 1053 |   fDummy = TRUE;
 | 
|---|
| 1054 |   *suggest = 0;
 | 
|---|
| 1055 |   for (x = 0;x < 26;x++)
 | 
|---|
| 1056 |     driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS |
 | 
|---|
| 1057 |                       DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS |
 | 
|---|
| 1058 |                       DRIVE_INCLUDEFILES | DRIVE_SLOW);
 | 
|---|
| 1059 |   memset(driveserial,-1,sizeof(driveserial));
 | 
|---|
| 1060 |   {
 | 
|---|
| 1061 |     ULONG  startdrive = 3L;
 | 
|---|
| 1062 | 
 | 
|---|
| 1063 |     DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 1064 |     if (!DosQuerySysInfo(QSV_BOOT_DRIVE,
 | 
|---|
| 1065 |                          QSV_BOOT_DRIVE,
 | 
|---|
| 1066 |                          (PVOID)&startdrive,
 | 
|---|
| 1067 |                          (ULONG)sizeof(ULONG)) &&
 | 
|---|
| 1068 |        startdrive)
 | 
|---|
| 1069 |       driveflags[startdrive - 1] |= DRIVE_BOOT;
 | 
|---|
| 1070 |   }
 | 
|---|
| 1071 |   DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 1072 |   rc = DosQCurDisk(&ulDriveNum,
 | 
|---|
| 1073 |                    &ulDriveMap);
 | 
|---|
| 1074 |   if (rc)
 | 
|---|
| 1075 |   {
 | 
|---|
| 1076 |     Dos_Error(MB_CANCEL,
 | 
|---|
| 1077 |               rc,
 | 
|---|
| 1078 |               HWND_DESKTOP,
 | 
|---|
| 1079 |               __FILE__,
 | 
|---|
| 1080 |               __LINE__,
 | 
|---|
| 1081 |               GetPString(IDS_FILLDIRERR6TEXT));
 | 
|---|
| 1082 |     exit(0);
 | 
|---|
| 1083 |   }
 | 
|---|
| 1084 |   for(x = 0;x < 26;x++)
 | 
|---|
| 1085 |     if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE))
 | 
|---|
| 1086 |       numtoinsert++;
 | 
|---|
| 1087 |   if (numtoinsert)
 | 
|---|
| 1088 |     pciFirst = WinSendMsg(hwndCnr,
 | 
|---|
| 1089 |                           CM_ALLOCRECORD,
 | 
|---|
| 1090 |                           MPFROMLONG(EXTRA_RECORD_BYTES2),
 | 
|---|
| 1091 |                           MPFROMLONG((ULONG)numtoinsert));
 | 
|---|
| 1092 |   if (pciFirst)
 | 
|---|
| 1093 |   {
 | 
|---|
| 1094 |     pci = pciFirst;
 | 
|---|
| 1095 |     for(x = 0;x < 26;x++) {
 | 
|---|
| 1096 |       if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE))
 | 
|---|
| 1097 |       {
 | 
|---|
| 1098 |         *szDrive = (CHAR)x + 'A';
 | 
|---|
| 1099 | 
 | 
|---|
| 1100 |         {
 | 
|---|
| 1101 |           CHAR  s[80];
 | 
|---|
| 1102 |           ULONG flags = 0;
 | 
|---|
| 1103 |           ULONG size = sizeof(ULONG);
 | 
|---|
| 1104 | 
 | 
|---|
| 1105 |           sprintf(s,"%c.DriveFlags",toupper(*szDrive));
 | 
|---|
| 1106 |           if (PrfQueryProfileData(fmprof,appname,s,&flags,&size) &&
 | 
|---|
| 1107 |               size == sizeof(ULONG))
 | 
|---|
| 1108 |           {
 | 
|---|
| 1109 |             driveflags[toupper(*szDrive) - 'A'] |= flags;
 | 
|---|
| 1110 |           }
 | 
|---|
| 1111 |         }
 | 
|---|
| 1112 | 
 | 
|---|
| 1113 |         if (x > 1)
 | 
|---|
| 1114 |         {
 | 
|---|
| 1115 |           if (!(driveflags[x] & DRIVE_NOPRESCAN))
 | 
|---|
| 1116 |           {
 | 
|---|
| 1117 |             *FileSystem = 0;
 | 
|---|
| 1118 |             drvtype = 0;
 | 
|---|
| 1119 |             removable = CheckDrive(*szDrive,FileSystem,&drvtype);
 | 
|---|
| 1120 |             driveserial[x] = -1;
 | 
|---|
| 1121 |             if (removable != -1)
 | 
|---|
| 1122 |             {
 | 
|---|
| 1123 |               struct {
 | 
|---|
| 1124 |                 ULONG serial;
 | 
|---|
| 1125 |                 CHAR  volumelength;
 | 
|---|
| 1126 |                 CHAR  volumelabel[CCHMAXPATH];
 | 
|---|
| 1127 |               } volser;
 | 
|---|
| 1128 | 
 | 
|---|
| 1129 |               DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 1130 |               if (!DosQueryFSInfo((ULONG)x,
 | 
|---|
| 1131 |                                   FSIL_VOLSER,
 | 
|---|
| 1132 |                                   &volser,
 | 
|---|
| 1133 |                                   sizeof(volser)))
 | 
|---|
| 1134 |               {
 | 
|---|
| 1135 |                 driveserial[x] = volser.serial;
 | 
|---|
| 1136 |               }
 | 
|---|
| 1137 |             }
 | 
|---|
| 1138 |             else
 | 
|---|
| 1139 |               driveflags[x] |= DRIVE_INVALID;
 | 
|---|
| 1140 |             memset(&fsa4,0,sizeof(FILESTATUS4));
 | 
|---|
| 1141 |             driveflags[x] |= ((removable == -1 || removable == 1) ?
 | 
|---|
| 1142 |                                                DRIVE_REMOVABLE : 0);
 | 
|---|
| 1143 |             if (drvtype & DRIVE_REMOTE)
 | 
|---|
| 1144 |               driveflags[x] |= DRIVE_REMOTE;
 | 
|---|
| 1145 |             if (strcmp(FileSystem,HPFS) &&
 | 
|---|
| 1146 |                 strcmp(FileSystem,JFS) &&
 | 
|---|
| 1147 |                 strcmp(FileSystem,CDFS) &&
 | 
|---|
| 1148 |                 strcmp(FileSystem,FAT32) &&
 | 
|---|
| 1149 |                 strcmp(FileSystem,HPFS386))
 | 
|---|
| 1150 |             {
 | 
|---|
| 1151 |               driveflags[x] |= DRIVE_NOLONGNAMES;
 | 
|---|
| 1152 |             }
 | 
|---|
| 1153 |             if (!strcmp(FileSystem,CDFS))
 | 
|---|
| 1154 |             {
 | 
|---|
| 1155 |               removable = 1;
 | 
|---|
| 1156 |               driveflags[x] |= DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE |
 | 
|---|
| 1157 |                                 DRIVE_CDROM;
 | 
|---|
| 1158 |             }
 | 
|---|
| 1159 |             else if (!stricmp(FileSystem,CBSIFS))
 | 
|---|
| 1160 |             {
 | 
|---|
| 1161 |               driveflags[x] |= DRIVE_ZIPSTREAM;
 | 
|---|
| 1162 |               driveflags[x] &= ~DRIVE_REMOTE;
 | 
|---|
| 1163 |               if (drvtype & DRIVE_REMOVABLE)
 | 
|---|
| 1164 |                 driveflags[x] |= DRIVE_REMOVABLE;
 | 
|---|
| 1165 |               if (!(drvtype & DRIVE_NOLONGNAMES))
 | 
|---|
| 1166 |                 driveflags[x] &= ~DRIVE_NOLONGNAMES;
 | 
|---|
| 1167 |             }
 | 
|---|
| 1168 | 
 | 
|---|
| 1169 |             pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
 | 
|---|
| 1170 |             if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum)
 | 
|---|
| 1171 |               pci->rc.flRecordAttr |= (CRA_CURSORED | CRA_SELECTED);
 | 
|---|
| 1172 | 
 | 
|---|
| 1173 |             if (removable == 0)
 | 
|---|
| 1174 |             {
 | 
|---|
| 1175 |               pci->attrFile |= FILE_DIRECTORY;
 | 
|---|
| 1176 |               DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 1177 |               rc = DosQueryPathInfo(szDrive,
 | 
|---|
| 1178 |                                     FIL_QUERYEASIZE,
 | 
|---|
| 1179 |                                     &fsa4,
 | 
|---|
| 1180 |                                     (ULONG)sizeof(FILESTATUS4));
 | 
|---|
| 1181 |               if (rc == 58)
 | 
|---|
| 1182 |               {
 | 
|---|
| 1183 |                 DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 1184 |                 rc = DosQueryPathInfo(szDrive,
 | 
|---|
| 1185 |                                       FIL_STANDARD,
 | 
|---|
| 1186 |                                       &fsa4,
 | 
|---|
| 1187 |                                       (ULONG)sizeof(FILESTATUS3));
 | 
|---|
| 1188 |                 fsa4.cbList = 0;
 | 
|---|
| 1189 |               }
 | 
|---|
| 1190 |               if (rc && !didonce)
 | 
|---|
| 1191 |               {
 | 
|---|
| 1192 |                 if (!*suggest)
 | 
|---|
| 1193 |                 {
 | 
|---|
| 1194 |                   *suggest = '/';
 | 
|---|
| 1195 |                   suggest[1] = 0;
 | 
|---|
| 1196 |                 }
 | 
|---|
| 1197 |                 sprintf(suggest + strlen(suggest),
 | 
|---|
| 1198 |                         "%c",
 | 
|---|
| 1199 |                         toupper(*szDrive));
 | 
|---|
| 1200 |                 strcpy(pci->szFileName,szDrive);
 | 
|---|
| 1201 |                 pci->pszFileName = pci->szFileName;
 | 
|---|
| 1202 |                 pci->rc.pszIcon = pci->pszFileName;
 | 
|---|
| 1203 |                 pci->attrFile = FILE_DIRECTORY;
 | 
|---|
| 1204 |                 strcpy(pci->szDispAttr,"----D-");
 | 
|---|
| 1205 |                 pci->pszDispAttr = pci->szDispAttr;
 | 
|---|
| 1206 |                 driveserial[x] = -1;
 | 
|---|
| 1207 |               }
 | 
|---|
| 1208 |               else
 | 
|---|
| 1209 |                 FillInRecordFromFSA(hwndCnr,
 | 
|---|
| 1210 |                                     pci,
 | 
|---|
| 1211 |                                     szDrive,
 | 
|---|
| 1212 |                                     &fsa4,
 | 
|---|
| 1213 |                                     TRUE,
 | 
|---|
| 1214 |                                     NULL);
 | 
|---|
| 1215 |             }
 | 
|---|
| 1216 |             else
 | 
|---|
| 1217 |             {
 | 
|---|
| 1218 |               strcpy(pci->szFileName,szDrive);
 | 
|---|
| 1219 |               pci->pszFileName = pci->szFileName;
 | 
|---|
| 1220 |               pci->rc.pszIcon = pci->pszFileName;
 | 
|---|
| 1221 |               pci->attrFile = FILE_DIRECTORY;
 | 
|---|
| 1222 |               strcpy(pci->szDispAttr,"----D-");
 | 
|---|
| 1223 |               pci->pszDispAttr = pci->szDispAttr;
 | 
|---|
| 1224 |             }
 | 
|---|
| 1225 |             *pci->szFileName = toupper(*pci->szFileName);
 | 
|---|
| 1226 |             if (driveflags[x] & DRIVE_CDROM)
 | 
|---|
| 1227 |               pci->rc.hptrIcon = hptrCDROM;
 | 
|---|
| 1228 |             else
 | 
|---|
| 1229 |               pci->rc.hptrIcon = (driveflags[x] & DRIVE_REMOVABLE) ?
 | 
|---|
| 1230 |                                   hptrRemovable :
 | 
|---|
| 1231 |                                   (driveflags[x] & DRIVE_REMOTE) ?
 | 
|---|
| 1232 |                                   hptrRemote :
 | 
|---|
| 1233 |                                   (driveflags[x] & DRIVE_ZIPSTREAM) ?
 | 
|---|
| 1234 |                                   hptrZipstrm : hptrDrive;
 | 
|---|
| 1235 |           }
 | 
|---|
| 1236 |           else
 | 
|---|
| 1237 |           {
 | 
|---|
| 1238 |             pci->rc.hptrIcon = hptrDunno;
 | 
|---|
| 1239 |             strcpy(pci->szFileName,szDrive);
 | 
|---|
| 1240 |             pci->pszFileName = pci->szFileName;
 | 
|---|
| 1241 |             pci->rc.pszIcon = pci->pszFileName;
 | 
|---|
| 1242 |             pci->attrFile = FILE_DIRECTORY;
 | 
|---|
| 1243 |             strcpy(pci->szDispAttr,"----D-");
 | 
|---|
| 1244 |             pci->pszDispAttr = pci->szDispAttr;
 | 
|---|
| 1245 |             driveserial[x] = -1;
 | 
|---|
| 1246 |           }
 | 
|---|
| 1247 |         }
 | 
|---|
| 1248 |         else
 | 
|---|
| 1249 |         {
 | 
|---|
| 1250 |           pci->rc.hptrIcon = hptrFloppy;
 | 
|---|
| 1251 |           strcpy(pci->szFileName,szDrive);
 | 
|---|
| 1252 |           pci->pszFileName = pci->szFileName;
 | 
|---|
| 1253 |           pci->rc.pszIcon = pci->pszFileName;
 | 
|---|
| 1254 |           pci->attrFile = FILE_DIRECTORY;
 | 
|---|
| 1255 |           strcpy(pci->szDispAttr,"----D-");
 | 
|---|
| 1256 |           pci->pszDispAttr = pci->szDispAttr;
 | 
|---|
| 1257 |           driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOLONGNAMES);
 | 
|---|
| 1258 |           driveserial[x] = -1;
 | 
|---|
| 1259 |         }
 | 
|---|
| 1260 |         pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
 | 
|---|
| 1261 |         pci = (PCNRITEM)pci->rc.preccNextRecord;  /* next rec */
 | 
|---|
| 1262 |       }
 | 
|---|
| 1263 |       else if (!(ulDriveMap & (1L << x)))
 | 
|---|
| 1264 |         driveflags[x] |= DRIVE_INVALID;
 | 
|---|
| 1265 |     }
 | 
|---|
| 1266 |     PostMsg(hwndMain,
 | 
|---|
| 1267 |             UM_BUILDDRIVEBAR,
 | 
|---|
| 1268 |             MPVOID,
 | 
|---|
| 1269 |             MPVOID);
 | 
|---|
| 1270 |     drivesbuilt = TRUE;
 | 
|---|
| 1271 |     /* insert the drives */
 | 
|---|
| 1272 |     if (numtoinsert && pciFirst)
 | 
|---|
| 1273 |     {
 | 
|---|
| 1274 |       RECORDINSERT ri;
 | 
|---|
| 1275 | 
 | 
|---|
| 1276 |       memset(&ri,0,sizeof(RECORDINSERT));
 | 
|---|
| 1277 |       ri.cb                 = sizeof(RECORDINSERT);
 | 
|---|
| 1278 |       ri.pRecordOrder       = (PRECORDCORE)CMA_END;
 | 
|---|
| 1279 |       ri.pRecordParent      = (PRECORDCORE)NULL;
 | 
|---|
| 1280 |       ri.zOrder             = (ULONG)CMA_TOP;
 | 
|---|
| 1281 |       ri.cRecordsInsert     = numtoinsert;
 | 
|---|
| 1282 |       ri.fInvalidateRecord  = FALSE;
 | 
|---|
| 1283 |       if (!WinSendMsg(hwndCnr,
 | 
|---|
| 1284 |                       CM_INSERTRECORD,
 | 
|---|
| 1285 |                       MPFROMP(pciFirst),
 | 
|---|
| 1286 |                       MPFROMP(&ri)))
 | 
|---|
| 1287 |         Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__,
 | 
|---|
| 1288 |                   GetPString(IDS_FILLDIRERR5TEXT));
 | 
|---|
| 1289 |     }
 | 
|---|
| 1290 |     /* move cursor onto the default drive rather than the first drive */
 | 
|---|
| 1291 |     if (!fSwitchTree)
 | 
|---|
| 1292 |     {
 | 
|---|
| 1293 |       pci = (PCNRITEM)WinSendMsg(hwndCnr,
 | 
|---|
| 1294 |                                  CM_QUERYRECORD,
 | 
|---|
| 1295 |                                  MPVOID,
 | 
|---|
| 1296 |                                  MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
 | 
|---|
| 1297 |       while(pci && (INT)pci != -1)
 | 
|---|
| 1298 |       {
 | 
|---|
| 1299 |         if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum)
 | 
|---|
| 1300 |         {
 | 
|---|
| 1301 |           WinSendMsg(hwndCnr,
 | 
|---|
| 1302 |                      CM_SETRECORDEMPHASIS,
 | 
|---|
| 1303 |                      MPFROMP(pci),
 | 
|---|
| 1304 |                      MPFROM2SHORT(TRUE,CRA_CURSORED));
 | 
|---|
| 1305 |           break;
 | 
|---|
| 1306 |         }
 | 
|---|
| 1307 |         pci = (PCNRITEM)WinSendMsg(hwndCnr,
 | 
|---|
| 1308 |                                    CM_QUERYRECORD,
 | 
|---|
| 1309 |                                    MPFROMP(pci),
 | 
|---|
| 1310 |                                    MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
 | 
|---|
| 1311 |       }
 | 
|---|
| 1312 |     }
 | 
|---|
| 1313 | 
 | 
|---|
| 1314 |     if (hwndParent)
 | 
|---|
| 1315 |       WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
 | 
|---|
| 1316 |                  MAIN_DRIVELIST),
 | 
|---|
| 1317 |                  LM_DELETEALL,
 | 
|---|
| 1318 |                  MPVOID,
 | 
|---|
| 1319 |                  MPVOID);
 | 
|---|
| 1320 | 
 | 
|---|
| 1321 |     if (fShowEnv)
 | 
|---|
| 1322 |     {
 | 
|---|
| 1323 |       RECORDINSERT ri;
 | 
|---|
| 1324 | 
 | 
|---|
| 1325 |       pciParent = WinSendMsg(hwndCnr,
 | 
|---|
| 1326 |                              CM_ALLOCRECORD,
 | 
|---|
| 1327 |                              MPFROMLONG(EXTRA_RECORD_BYTES2),
 | 
|---|
| 1328 |                              MPFROMLONG(1));
 | 
|---|
| 1329 |       if (pciParent)
 | 
|---|
| 1330 |       {
 | 
|---|
| 1331 |         pciParent->flags |= RECFLAGS_ENV;
 | 
|---|
| 1332 |         strcpy(pciParent->szFileName,GetPString(IDS_ENVVARSTEXT));
 | 
|---|
| 1333 |         pciParent->pszFileName = pciParent->szFileName;
 | 
|---|
| 1334 |         pciParent->rc.hptrIcon = hptrEnv;
 | 
|---|
| 1335 |         pciParent->rc.pszIcon = pciParent->pszFileName;
 | 
|---|
| 1336 |         strcpy(pciParent->szDispAttr,"------");
 | 
|---|
| 1337 |         pciParent->pszDispAttr = pciParent->szDispAttr;
 | 
|---|
| 1338 |         memset(&ri,0,sizeof(RECORDINSERT));
 | 
|---|
| 1339 |         ri.cb                 = sizeof(RECORDINSERT);
 | 
|---|
| 1340 |         ri.pRecordOrder       = (PRECORDCORE)CMA_END;
 | 
|---|
| 1341 |         ri.pRecordParent      = (PRECORDCORE)NULL;
 | 
|---|
| 1342 |         ri.zOrder             = (ULONG)CMA_TOP;
 | 
|---|
| 1343 |         ri.cRecordsInsert     = 1;
 | 
|---|
| 1344 |         ri.fInvalidateRecord  = FALSE;
 | 
|---|
| 1345 |         if (WinSendMsg(hwndCnr,
 | 
|---|
| 1346 |                        CM_INSERTRECORD,
 | 
|---|
| 1347 |                        MPFROMP(pciParent),
 | 
|---|
| 1348 |                        MPFROMP(&ri))) {
 | 
|---|
| 1349 | 
 | 
|---|
| 1350 |           char *p,*pp;
 | 
|---|
| 1351 | 
 | 
|---|
| 1352 |           p = GetPString(IDS_ENVVARNAMES);
 | 
|---|
| 1353 |           while(*p == ' ')
 | 
|---|
| 1354 |             p++;
 | 
|---|
| 1355 |           while (*p)
 | 
|---|
| 1356 |           {
 | 
|---|
| 1357 |             *FileSystem = 0;
 | 
|---|
| 1358 |             pp = FileSystem;
 | 
|---|
| 1359 |             while(*p && *p != ' ')
 | 
|---|
| 1360 |               *pp++ = *p++;
 | 
|---|
| 1361 |             *pp = 0;
 | 
|---|
| 1362 |             while(*p == ' ')
 | 
|---|
| 1363 |               p++;
 | 
|---|
| 1364 |             if (*FileSystem &&
 | 
|---|
| 1365 |                 (!stricmp(FileSystem,"LIBPATH") ||
 | 
|---|
| 1366 |                  getenv(FileSystem)))
 | 
|---|
| 1367 |             {
 | 
|---|
| 1368 |               pci = WinSendMsg(hwndCnr,
 | 
|---|
| 1369 |                                CM_ALLOCRECORD,
 | 
|---|
| 1370 |                                MPFROMLONG(EXTRA_RECORD_BYTES2),
 | 
|---|
| 1371 |                                MPFROMLONG(1));
 | 
|---|
| 1372 |               if (pci)
 | 
|---|
| 1373 |               {
 | 
|---|
| 1374 |                 pci->flags |= RECFLAGS_ENV;
 | 
|---|
| 1375 |                 sprintf(pci->szFileName,
 | 
|---|
| 1376 |                         "%%%s%%",
 | 
|---|
| 1377 |                         FileSystem);
 | 
|---|
| 1378 |                 pci->pszFileName = pci->szFileName;
 | 
|---|
| 1379 |                 pci->rc.hptrIcon = hptrEnv;
 | 
|---|
| 1380 |                 pci->rc.pszIcon = pci->pszFileName;
 | 
|---|
| 1381 |                 strcpy(pci->szDispAttr,"------");
 | 
|---|
| 1382 |                 pci->pszDispAttr = pci->szDispAttr;
 | 
|---|
| 1383 |                 memset(&ri,0,sizeof(RECORDINSERT));
 | 
|---|
| 1384 |                 ri.cb                 = sizeof(RECORDINSERT);
 | 
|---|
| 1385 |                 ri.pRecordOrder       = (PRECORDCORE)CMA_END;
 | 
|---|
| 1386 |                 ri.pRecordParent      = (PRECORDCORE)pciParent;
 | 
|---|
| 1387 |                 ri.zOrder             = (ULONG)CMA_TOP;
 | 
|---|
| 1388 |                 ri.cRecordsInsert     = 1;
 | 
|---|
| 1389 |                 ri.fInvalidateRecord  = FALSE;
 | 
|---|
| 1390 |                 if (!WinSendMsg(hwndCnr,
 | 
|---|
| 1391 |                                 CM_INSERTRECORD,
 | 
|---|
| 1392 |                                 MPFROMP(pci),
 | 
|---|
| 1393 |                                 MPFROMP(&ri))) {
 | 
|---|
| 1394 |                   Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__,
 | 
|---|
| 1395 |                             GetPString(IDS_FILLDIRERR5TEXT));
 | 
|---|
| 1396 |                   WinSendMsg(hwndCnr,
 | 
|---|
| 1397 |                              CM_FREERECORD,
 | 
|---|
| 1398 |                              MPFROMP(&pci),
 | 
|---|
| 1399 |                              MPFROMSHORT(1));
 | 
|---|
| 1400 |                 }
 | 
|---|
| 1401 |               }
 | 
|---|
| 1402 |             }
 | 
|---|
| 1403 |           }
 | 
|---|
| 1404 |           WinSendMsg(hwndCnr,
 | 
|---|
| 1405 |                      CM_INVALIDATERECORD,
 | 
|---|
| 1406 |                      MPFROMP(&pciParent),
 | 
|---|
| 1407 |                      MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
 | 
|---|
| 1408 |         }
 | 
|---|
| 1409 |         else
 | 
|---|
| 1410 |           WinSendMsg(hwndCnr,
 | 
|---|
| 1411 |                      CM_FREERECORD,
 | 
|---|
| 1412 |                      MPFROMP(&pciParent),
 | 
|---|
| 1413 |                      MPFROMSHORT(1));
 | 
|---|
| 1414 |       }
 | 
|---|
| 1415 |     }
 | 
|---|
| 1416 | 
 | 
|---|
| 1417 |     x = 0;
 | 
|---|
| 1418 |     pci = (PCNRITEM)WinSendMsg(hwndCnr,
 | 
|---|
| 1419 |                                CM_QUERYRECORD,
 | 
|---|
| 1420 |                                MPVOID,
 | 
|---|
| 1421 |                                MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
 | 
|---|
| 1422 |     while (pci && (INT)pci != -1)
 | 
|---|
| 1423 |     {
 | 
|---|
| 1424 |       pciNext = (PCNRITEM)WinSendMsg(hwndCnr,
 | 
|---|
| 1425 |                                      CM_QUERYRECORD,
 | 
|---|
| 1426 |                                      MPFROMP(pci),
 | 
|---|
| 1427 |                                      MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
 | 
|---|
| 1428 |       if (!(pci->flags & RECFLAGS_ENV))
 | 
|---|
| 1429 |       {
 | 
|---|
| 1430 |         if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum ||
 | 
|---|
| 1431 |             toupper(*pci->szFileName) > 'B')
 | 
|---|
| 1432 |         {
 | 
|---|
| 1433 |           if (!(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_INVALID) &&
 | 
|---|
| 1434 |              !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOPRESCAN) &&
 | 
|---|
| 1435 |              (!fNoRemovableScan ||
 | 
|---|
| 1436 |               !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE)))
 | 
|---|
| 1437 |           {
 | 
|---|
| 1438 |             if (!Stubby(hwndCnr,pci))
 | 
|---|
| 1439 |             {
 | 
|---|
| 1440 |               WinSendMsg(hwndCnr,
 | 
|---|
| 1441 |                          CM_INVALIDATERECORD,
 | 
|---|
| 1442 |                          MPFROMP(&pci),
 | 
|---|
| 1443 |                          MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
 | 
|---|
| 1444 |               goto SkipBadRec;
 | 
|---|
| 1445 |             }
 | 
|---|
| 1446 |           }
 | 
|---|
| 1447 |         }
 | 
|---|
| 1448 |         else
 | 
|---|
| 1449 |           WinSendMsg(hwndCnr,
 | 
|---|
| 1450 |                      CM_INVALIDATERECORD,
 | 
|---|
| 1451 |                      MPFROMP(&pci),
 | 
|---|
| 1452 |                      MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
 | 
|---|
| 1453 | 
 | 
|---|
| 1454 |         WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
 | 
|---|
| 1455 |                    MAIN_DRIVELIST),
 | 
|---|
| 1456 |                    LM_INSERTITEM,
 | 
|---|
| 1457 |                    MPFROM2SHORT(LIT_SORTASCENDING,0),
 | 
|---|
| 1458 |                    MPFROMP(pci->szFileName));
 | 
|---|
| 1459 |       }
 | 
|---|
| 1460 | SkipBadRec:
 | 
|---|
| 1461 |       x++;
 | 
|---|
| 1462 |       pci = pciNext;
 | 
|---|
| 1463 |     }
 | 
|---|
| 1464 |     if (hwndParent)
 | 
|---|
| 1465 |       WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
 | 
|---|
| 1466 |                  MAIN_DRIVELIST),LM_SELECTITEM,MPFROM2SHORT(0,0),
 | 
|---|
| 1467 |                  MPFROMLONG(TRUE));
 | 
|---|
| 1468 | 
 | 
|---|
| 1469 |     pci = (PCNRITEM)WinSendMsg(hwndCnr,
 | 
|---|
| 1470 |                                CM_QUERYRECORD,
 | 
|---|
| 1471 |                                MPVOID,
 | 
|---|
| 1472 |                                MPFROM2SHORT(CMA_FIRST,
 | 
|---|
| 1473 |                                             CMA_ITEMORDER));
 | 
|---|
| 1474 |     while (pci && (INT)pci != -1)
 | 
|---|
| 1475 |     {
 | 
|---|
| 1476 |       pciNext = (PCNRITEM)WinSendMsg(hwndCnr,
 | 
|---|
| 1477 |                                      CM_QUERYRECORD,
 | 
|---|
| 1478 |                                      MPFROMP(pci),
 | 
|---|
| 1479 |                                      MPFROM2SHORT(CMA_NEXT,
 | 
|---|
| 1480 |                                                   CMA_ITEMORDER));
 | 
|---|
| 1481 |       if (pci->flags & RECFLAGS_ENV)
 | 
|---|
| 1482 |       {
 | 
|---|
| 1483 |         pci = (PCNRITEM)WinSendMsg(hwndCnr,
 | 
|---|
| 1484 |                                    CM_QUERYRECORD,
 | 
|---|
| 1485 |                                    MPFROMP(pci),
 | 
|---|
| 1486 |                                    MPFROM2SHORT(CMA_FIRSTCHILD,
 | 
|---|
| 1487 |                                                 CMA_ITEMORDER));
 | 
|---|
| 1488 |         while (pci && (INT)pci != -1)
 | 
|---|
| 1489 |         {
 | 
|---|
| 1490 |           if (pci->flags & RECFLAGS_ENV)
 | 
|---|
| 1491 |             FleshEnv(hwndCnr,pci);
 | 
|---|
| 1492 |           pci = (PCNRITEM)WinSendMsg(hwndCnr,
 | 
|---|
| 1493 |                                      CM_QUERYRECORD,
 | 
|---|
| 1494 |                                      MPFROMP(pci),
 | 
|---|
| 1495 |                                      MPFROM2SHORT(CMA_NEXT,
 | 
|---|
| 1496 |                                                   CMA_ITEMORDER));
 | 
|---|
| 1497 |         }
 | 
|---|
| 1498 |         break;
 | 
|---|
| 1499 |       }
 | 
|---|
| 1500 |       pci = (PCNRITEM)WinSendMsg(hwndCnr,
 | 
|---|
| 1501 |                                  CM_QUERYRECORD,
 | 
|---|
| 1502 |                                  MPFROMP(pci),
 | 
|---|
| 1503 |                                  MPFROM2SHORT(CMA_NEXT,
 | 
|---|
| 1504 |                                               CMA_ITEMORDER));
 | 
|---|
| 1505 |     }
 | 
|---|
| 1506 | 
 | 
|---|
| 1507 |   }
 | 
|---|
| 1508 |   else
 | 
|---|
| 1509 |   {
 | 
|---|
| 1510 |     Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__,
 | 
|---|
| 1511 |               GetPString(IDS_FILLDIRERR7TEXT));
 | 
|---|
| 1512 |     exit(0);
 | 
|---|
| 1513 |   }
 | 
|---|
| 1514 |   if (!drivesbuilt && hwndMain)
 | 
|---|
| 1515 |     PostMsg(hwndMain,
 | 
|---|
| 1516 |             UM_BUILDDRIVEBAR,
 | 
|---|
| 1517 |             MPVOID,
 | 
|---|
| 1518 |             MPVOID);
 | 
|---|
| 1519 |   DosSleep(33L);
 | 
|---|
| 1520 |   fDummy = FALSE;
 | 
|---|
| 1521 |   DosPostEventSem(CompactSem);
 | 
|---|
| 1522 |   {
 | 
|---|
| 1523 |     BYTE info;
 | 
|---|
| 1524 |     BOOL includesyours = FALSE;
 | 
|---|
| 1525 | 
 | 
|---|
| 1526 |     if (*suggest ||
 | 
|---|
| 1527 |         (!(driveflags[1] & DRIVE_IGNORE) &&
 | 
|---|
| 1528 |          fFirstTime))
 | 
|---|
| 1529 |     {
 | 
|---|
| 1530 |       if (!DosDevConfig(&info,
 | 
|---|
| 1531 |                        DEVINFO_FLOPPY) &&
 | 
|---|
| 1532 |            info == 1)
 | 
|---|
| 1533 |       {
 | 
|---|
| 1534 |         if (!*suggest)
 | 
|---|
| 1535 |         {
 | 
|---|
| 1536 |           *suggest = '/';
 | 
|---|
| 1537 |           suggest[1] = 0;
 | 
|---|
| 1538 |         }
 | 
|---|
| 1539 |         else
 | 
|---|
| 1540 |           memmove(suggest + 2,suggest + 1,strlen(suggest));
 | 
|---|
| 1541 |         suggest[1] = 'B';
 | 
|---|
| 1542 |       }
 | 
|---|
| 1543 |     }
 | 
|---|
| 1544 |     if (*suggest)
 | 
|---|
| 1545 |     {
 | 
|---|
| 1546 |       for(x = 2;x < 26;x++)
 | 
|---|
| 1547 |       {
 | 
|---|
| 1548 |         if (driveflags[x] & DRIVE_IGNORE)
 | 
|---|
| 1549 |         {
 | 
|---|
| 1550 |           includesyours = TRUE;
 | 
|---|
| 1551 |           sprintf(suggest + strlen(suggest),
 | 
|---|
| 1552 |                   "%c",
 | 
|---|
| 1553 |                   (char)(x + 'A'));
 | 
|---|
| 1554 |         }
 | 
|---|
| 1555 |       }
 | 
|---|
| 1556 |       strcat(suggest," %*");
 | 
|---|
| 1557 |       if (saymsg(MB_YESNO | MB_ICONEXCLAMATION,
 | 
|---|
| 1558 |                  (hwndParent) ? hwndParent : hwndCnr,
 | 
|---|
| 1559 |                  GetPString(IDS_SUGGESTTITLETEXT),
 | 
|---|
| 1560 |                  GetPString(IDS_SUGGEST1TEXT),
 | 
|---|
| 1561 |                  (includesyours) ? GetPString(IDS_SUGGEST2TEXT) : NullStr,
 | 
|---|
| 1562 |                  suggest) == MBID_YES)
 | 
|---|
| 1563 |       {
 | 
|---|
| 1564 |         char s[64];
 | 
|---|
| 1565 | 
 | 
|---|
| 1566 |         sprintf(s, "PARAMETERS=%s", suggest);
 | 
|---|
| 1567 |         WinCreateObject(WPProgram,
 | 
|---|
| 1568 |                         "FM/2",
 | 
|---|
| 1569 |                         s,
 | 
|---|
| 1570 |                         FM3Folder,
 | 
|---|
| 1571 |                         CO_UPDATEIFEXISTS);
 | 
|---|
| 1572 |         WinCreateObject(WPProgram,
 | 
|---|
| 1573 |                         "FM/2 Lite",
 | 
|---|
| 1574 |                         s,
 | 
|---|
| 1575 |                         FM3Folder,
 | 
|---|
| 1576 |                         CO_UPDATEIFEXISTS);
 | 
|---|
| 1577 |         WinCreateObject(WPProgram,
 | 
|---|
| 1578 |                         "Archive Viewer/2",
 | 
|---|
| 1579 |                         s,
 | 
|---|
| 1580 |                         FM3Tools,
 | 
|---|
| 1581 |                         CO_UPDATEIFEXISTS);
 | 
|---|
| 1582 |         WinCreateObject(WPProgram,
 | 
|---|
| 1583 |                         "Dir Sizes",
 | 
|---|
| 1584 |                         s,
 | 
|---|
| 1585 |                         FM3Tools,
 | 
|---|
| 1586 |                         CO_UPDATEIFEXISTS);
 | 
|---|
| 1587 |         WinCreateObject(WPProgram,
 | 
|---|
| 1588 |                         "Visual Tree",
 | 
|---|
| 1589 |                         s,
 | 
|---|
| 1590 |                         FM3Tools,
 | 
|---|
| 1591 |                         CO_UPDATEIFEXISTS);
 | 
|---|
| 1592 |         WinCreateObject(WPProgram,
 | 
|---|
| 1593 |                         "Visual Directory",
 | 
|---|
| 1594 |                         s,
 | 
|---|
| 1595 |                         FM3Tools,
 | 
|---|
| 1596 |                         CO_UPDATEIFEXISTS);
 | 
|---|
| 1597 |         WinCreateObject(WPProgram,
 | 
|---|
| 1598 |                         "Global File Viewer",
 | 
|---|
| 1599 |                         s,
 | 
|---|
| 1600 |                         FM3Tools,
 | 
|---|
| 1601 |                         CO_UPDATEIFEXISTS);
 | 
|---|
| 1602 |         WinCreateObject(WPProgram,
 | 
|---|
| 1603 |                         "Databar",
 | 
|---|
| 1604 |                         s,
 | 
|---|
| 1605 |                         FM3Tools,
 | 
|---|
| 1606 |                         CO_UPDATEIFEXISTS);
 | 
|---|
| 1607 |       }
 | 
|---|
| 1608 |     }
 | 
|---|
| 1609 |   }
 | 
|---|
| 1610 |   didonce = TRUE;
 | 
|---|
| 1611 | 
 | 
|---|
| 1612 | } // FillTreeCnr
 | 
|---|
| 1613 | 
 | 
|---|