Changeset 214


Ignore:
Timestamp:
Jun 18, 2005, 5:51:49 AM (20 years ago)
Author:
root
Message:

Rework WinLoadFileIcon enables
Rework IDFile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/filldir.c

    r188 r214  
    2020  28 May 05 SHL Drop stale debug code
    2121  05 Jun 05 SHL Comments
     22  09 Jun 05 SHL Rework WinLoadFileIcon enables
     23  09 Jun 05 SHL Rework IDFile
    2224
    2325***********************************************************************/
     
    4244
    4345
    44 static HPOINTER IDFile(ULONG cmp)
     46static HPOINTER IDFile(PSZ p)
    4547{
    4648  HPOINTER hptr;
    47 
    48   hptr = (HPOINTER)0;
    49   if (cmp == *(ULONG *)".EXE" || cmp == *(ULONG *)".CMD" ||
    50       cmp == *(ULONG *)".BAT" || cmp == *(ULONG *)".COM")
    51     hptr = hptrApp;
    52   else if (cmp == *(ULONG *)".ZIP" || cmp == *(ULONG *)".LZH" ||
    53            cmp == *(ULONG *)".ARJ" || cmp == *(ULONG *)".ARC" ||
    54            cmp == *(ULONG *)".ZOO" || cmp == *(ULONG *)".RAR")
    55     hptr = hptrArc;
    56   else if (cmp == *(ULONG *)".BMP" || cmp == *(ULONG *)".ICO" ||
    57            cmp == *(ULONG *)".PTR" || cmp == *(ULONG *)".GIF" ||
    58            cmp == *(ULONG *)".TIF" || cmp == *(ULONG *)".PCX" ||
    59            cmp == *(ULONG *)".TGA" || cmp == *(ULONG *)".XBM")
    60     hptr = hptrArt;
     49  ULONG    cmp;
     50  CHAR     cmps[4];
     51
     52  p = strrchr(p,'.');
     53  if (p && !p[4])
     54  {
     55    cmps[0] = '.';
     56    cmps[1] = toupper(p[1]);
     57    cmps[2] = toupper(p[2]);
     58    cmps[3] = toupper(p[3]);
     59
     60    cmp = *(ULONG *)cmps;
     61
     62    if (cmp == *(ULONG *)".EXE" || cmp == *(ULONG *)".CMD" ||
     63        cmp == *(ULONG *)".BAT" || cmp == *(ULONG *)".COM")
     64      hptr = hptrApp;
     65    else if (cmp == *(ULONG *)".ZIP" || cmp == *(ULONG *)".LZH" ||
     66             cmp == *(ULONG *)".ARJ" || cmp == *(ULONG *)".ARC" ||
     67             cmp == *(ULONG *)".ZOO" || cmp == *(ULONG *)".RAR")
     68      hptr = hptrArc;
     69    else if (cmp == *(ULONG *)".BMP" || cmp == *(ULONG *)".ICO" ||
     70             cmp == *(ULONG *)".PTR" || cmp == *(ULONG *)".GIF" ||
     71             cmp == *(ULONG *)".TIF" || cmp == *(ULONG *)".PCX" ||
     72             cmp == *(ULONG *)".TGA" || cmp == *(ULONG *)".XBM")
     73      hptr = hptrArt;
     74    else
     75      hptr = (HPOINTER)0;
     76  }
     77  else
     78    hptr = (HPOINTER)0;
     79
    6180  return hptr;
    6281}
    6382
    6483
     84static BOOL IsDefaultIcon(HPOINTER hptr)
     85{
     86  HPOINTER hptr2;
     87  HPOINTER hptr3;
     88  LONG l;
     89  UINT u;
     90
     91  static HPOINTER hptrPMFile;
     92  static HPOINTER hptrWPSFile;
     93
     94  if (!hptrPMFile)
     95  {
     96#   if 0 // fixme to be gone
     97    for (l = 1; l <= SPTR_CPTR; l++)
     98    {
     99      hptr3 = WinQuerySysPointer(HWND_DESKTOP,l,FALSE);
     100      fprintf(stderr, "0x%08lx SPTR %ld\n", hptr3, l);
     101    }
     102#   endif // fixme to be gone
     103    hptrPMFile = WinQuerySysPointer(HWND_DESKTOP,SPTR_FILE,FALSE);
     104  }
     105# if 0 // fixme to be gone
     106  else
     107  {
     108    hptr2 = WinQuerySysPointer(HWND_DESKTOP,SPTR_FILE,FALSE);
     109    if (hptr2 != hptrPMFile)
     110    {
     111      saymsg(0, NULLHANDLE, "*Debug*", "ptr changed from %lx to %lx", hptrPMFile, hptr2);
     112      hptrPMFile = hptr2;
     113      fprintf(stderr, "0x%08lx SPTR_FILE changed\n", hptrPMFile);
     114    }
     115  }
     116# endif // fixme to be gone
     117
     118  // try to guess WPS default file icon
     119  hptr2 = (HPOINTER)0;
     120  for (u = 0; !hptrWPSFile && u < 10; u++)
     121  {
     122    char szFileName[CCHMAXPATH];
     123    char *psz;
     124
     125    psz = getenv("TMP");
     126    if (!psz && *psz)
     127      psz = getenv("TEMP");
     128    if (psz && *psz)
     129    {
     130      strcpy(szFileName, psz);
     131      psz = szFileName + strlen(szFileName) - 1;
     132      if (*psz != '\\')
     133      {
     134        psz++;
     135        *psz++ = '\\';
     136      }
     137    }
     138    else
     139      psz = szFileName;
     140
     141    sprintf(psz,"%08x.%03x",rand() & 0xffffffff, rand() & 0xfff);
     142    if (IsFile(szFileName) != 1)
     143    {
     144      FILE *fp = fopen(szFileName,"w");
     145      if (fp)
     146      {
     147        fclose(fp);
     148        hptr3 = WinLoadFileIcon(szFileName, FALSE);
     149#       if 0  // fixme to be gone
     150        fprintf(stderr, "0x%08lx %s\n", hptr3, szFileName);
     151#       endif // fixme to be gone
     152        unlinkf("%s", szFileName);
     153        if (!hptr2)
     154          hptr2 = hptr3;
     155        else if (hptr3 == hptr3)
     156        {
     157          hptrWPSFile = hptr3;          // Got same icon twice
     158          break;
     159        }
     160      }
     161    }
     162    DosSleep(rand() % 100);
     163
     164  } // for
     165
     166  return hptr == hptrPMFile || hptr == hptrWPSFile;
     167
     168} // IsDefaultIcon
     169
     170
    65171ULONGLONG FillInRecordFromFFB(HWND hwndCnr,PCNRITEM pci, const PSZ pszDirectory,
    66                               const PFILEFINDBUF4 pffb,const BOOL partial,
    67                               DIRCNRDATA *dcd)
     172                              const PFILEFINDBUF4 pffb,const BOOL partial,
     173                              DIRCNRDATA *dcd)
    68174{
    69175  /* fill in a container record from a FILEFINDBUF4 structure */
    70176
    71177  CHAR          attrstring[] = "RHS\0DA";
    72   CHAR          cmps[] = ".xxx";
    73178  CHAR         *p;
    74179  HPOINTER      hptr;
     
    76181  UINT          y;
    77182  UINT          t;
    78   ULONG         cmp;
    79   BOOL          rc;
    80183
    81184  pci->hwndCnr = hwndCnr;
     
    122225      if (pfealist)
    123226      {
    124         memset(pfealist,0,1532);
    125         pfealist->cbList = 1024;
    126         eaop.fpGEA2List = pgealist;
    127         eaop.fpFEA2List = pfealist;
    128         eaop.oError = 0;
    129         rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
    130                               (PVOID)&eaop,(ULONG)sizeof(EAOP2));
    131         if (!rc) {
    132           pfea = &eaop.fpFEA2List->list[0];
    133           value = pfea->szName + pfea->cbName + 1;
    134           value[pfea->cbValue] = 0;
    135           if (*(USHORT *)value == EAT_ASCII)
    136             strncpy(pci->szSubject,value + (sizeof(USHORT) * 2),39);
    137           pci->szSubject[39] = 0;
    138         }
    139         free(pfealist);
     227        memset(pfealist,0,1532);
     228        pfealist->cbList = 1024;
     229        eaop.fpGEA2List = pgealist;
     230        eaop.fpFEA2List = pfealist;
     231        eaop.oError = 0;
     232        rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
     233                              (PVOID)&eaop,(ULONG)sizeof(EAOP2));
     234        if (!rc) {
     235          pfea = &eaop.fpFEA2List->list[0];
     236          value = pfea->szName + pfea->cbName + 1;
     237          value[pfea->cbValue] = 0;
     238          if (*(USHORT *)value == EAT_ASCII)
     239            strncpy(pci->szSubject,value + (sizeof(USHORT) * 2),39);
     240          pci->szSubject[39] = 0;
     241        }
     242        free(pfealist);
    140243      }
    141244      free(pgealist);
     
    170273      pfealist = malloc(1532);
    171274      if (pfealist) {
    172         memset(pfealist,0,1532);
    173         pfealist->cbList = 1024;
    174         eaop.fpGEA2List = pgealist;
    175         eaop.fpFEA2List = pfealist;
    176         eaop.oError = 0;
    177         rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
    178                               (PVOID)&eaop,(ULONG)sizeof(EAOP2));
    179         if (!rc)
     275        memset(pfealist,0,1532);
     276        pfealist->cbList = 1024;
     277        eaop.fpGEA2List = pgealist;
     278        eaop.fpFEA2List = pfealist;
     279        eaop.oError = 0;
     280        rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
     281                              (PVOID)&eaop,(ULONG)sizeof(EAOP2));
     282        if (!rc)
    180283        {
    181           pfea = &eaop.fpFEA2List->list[0];
    182           value = pfea->szName + pfea->cbName + 1;
    183           value[pfea->cbValue] = 0;
    184           if (*(USHORT *)value == EAT_ASCII)
    185             strncpy(pci->szLongname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP);
    186           pci->szLongname[CCHMAXPATHCOMP - 1] = 0;
    187         }
    188         free(pfealist);
     284          pfea = &eaop.fpFEA2List->list[0];
     285          value = pfea->szName + pfea->cbName + 1;
     286          value[pfea->cbValue] = 0;
     287          if (*(USHORT *)value == EAT_ASCII)
     288            strncpy(pci->szLongname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP);
     289          pci->szLongname[CCHMAXPATHCOMP - 1] = 0;
     290        }
     291        free(pfealist);
    189292      }
    190293      free(pgealist);
     
    202305  if (pffb->attrFile & FILE_DIRECTORY)
    203306  {
    204     if (!fNoIconsDirs && (!isalpha(*pci->szFileName) ||
    205         !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))
     307    // is directory
     308    if (fNoIconsDirs ||
     309        (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS) ||
     310        !isalpha(*pci->szFileName))
     311    {
     312      hptr = (HPOINTER)0;
     313    }
     314    else
    206315      hptr = WinLoadFileIcon(pci->szFileName, FALSE);
     316  }
     317  else
     318  {
     319    // is file
     320    if (fNoIconsFiles ||
     321        (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS) ||
     322        !isalpha(*pci->szFileName))
     323    {
     324      hptr = (HPOINTER)0;
     325    }
    207326    else
    208       hptr = (HPOINTER)0;
    209   }
    210   else
    211   {
    212     if (!fNoIconsFiles && (!isalpha(*pci->szFileName) ||
    213        !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))
    214     {
    215327      hptr = WinLoadFileIcon(pci->szFileName, FALSE);
    216     }
    217     else
    218       hptr = (HPOINTER)0;
    219 
    220     if (!hptr || hptr == WinQuerySysPointer(HWND_DESKTOP,SPTR_FILE,FALSE))
    221     {
    222       p = strrchr(pci->szFileName,'.');
    223       if (p && !p[4])
    224       {
    225         cmps[1] = toupper(p[1]);
    226         cmps[2] = toupper(p[2]);
    227         cmps[3] = toupper(p[3]);
    228         cmp = *(ULONG *)cmps;
    229         hptr = IDFile(cmp);
    230       }
    231       else
    232         hptr = (HPOINTER)0;
    233     }
    234   }
     328
     329    if (!hptr || IsDefaultIcon(hptr))
     330      hptr = IDFile(pci->szFileName);
     331  }
     332
    235333  if (!hptr)
    236334  {
    237     hptr = ((pffb->attrFile & FILE_DIRECTORY) != 0) ? hptrDir :
    238             ((pffb->attrFile & FILE_SYSTEM) != 0)   ? hptrSystem :
    239             ((pffb->attrFile & FILE_HIDDEN) != 0)   ? hptrHidden :
    240             ((pffb->attrFile & FILE_READONLY) != 0) ? hptrReadonly :
    241             hptrFile;
     335    hptr = pffb->attrFile & FILE_DIRECTORY ?
     336             hptrDir :
     337             pffb->attrFile & FILE_SYSTEM ?
     338                hptrSystem :
     339                pffb->attrFile & FILE_HIDDEN ?
     340                   hptrHidden :
     341                   pffb->attrFile & FILE_READONLY ?
     342                     hptrReadonly :
     343                     hptrFile;
    242344  }
    243345
     
    250352      p = strrchr(pci->szFileName,':');
    251353      if (!p)
    252         p = pci->szFileName;
     354        p = pci->szFileName;
    253355      else
    254         p++;
     356        p++;
    255357    }
    256358    else if ((dcd && dcd->type == TREE_FRAME) ||
    257              (!(pffb->attrFile & FILE_DIRECTORY) || !*(p + 1)))
     359             (!(pffb->attrFile & FILE_DIRECTORY) || !*(p + 1)))
    258360    {
    259361      p++;
     
    294396    {
    295397      pci->szDispAttr[y++] =
    296         (CHAR)((pci->attrFile & (1 << x)) ? attrstring[x] : '-');
     398        (CHAR)((pci->attrFile & (1 << x)) ? attrstring[x] : '-');
    297399    }
    298400  }
     
    311413    {
    312414      if(!Filter((PMINIRECORDCORE)pci,(PVOID)&dcd->mask))
    313         pci->rc.flRecordAttr |= CRA_FILTERED;
     415        pci->rc.flRecordAttr |= CRA_FILTERED;
    314416    }
    315417    else if((!(dcd->mask.attrFile & FILE_HIDDEN) &&
    316              (pci->attrFile & FILE_HIDDEN)) ||
    317             (!(dcd->mask.attrFile & FILE_SYSTEM) &&
    318              (pci->attrFile & FILE_SYSTEM)) ||
    319             (!(dcd->mask.attrFile & FILE_READONLY) &&
    320              (pci->attrFile & FILE_READONLY)) ||
    321             (!(dcd->mask.attrFile & FILE_ARCHIVED) &&
    322              (pci->attrFile & FILE_ARCHIVED)))
     418             (pci->attrFile & FILE_HIDDEN)) ||
     419            (!(dcd->mask.attrFile & FILE_SYSTEM) &&
     420             (pci->attrFile & FILE_SYSTEM)) ||
     421            (!(dcd->mask.attrFile & FILE_READONLY) &&
     422             (pci->attrFile & FILE_READONLY)) ||
     423            (!(dcd->mask.attrFile & FILE_ARCHIVED) &&
     424             (pci->attrFile & FILE_ARCHIVED)))
    323425    {
    324426      pci->rc.flRecordAttr |= CRA_FILTERED;
     
    332434
    333435ULONGLONG FillInRecordFromFSA(HWND hwndCnr,
    334                               PCNRITEM pci,
     436                              PCNRITEM pci,
    335437                              const PSZ pszFileName,
    336                               const PFILESTATUS4 pfsa4,
    337                               const BOOL partial,
    338                               DIRCNRDATA *dcd)          // Optional
     438                              const PFILESTATUS4 pfsa4,
     439                              const BOOL partial,
     440                              DIRCNRDATA *dcd)          // Optional
    339441{
    340442  HPOINTER       hptr;
    341443  CHAR           attrstring[] = "RHS\0DA";
    342   CHAR           cmps[] = ".xxx";
    343444  register CHAR *p;
    344445  register INT   x;
    345446  register INT   y;
    346   ULONG          cmp;
    347447
    348448  /* fill in a container record from a FILESTATUS4 structure */
     
    375475      pfealist = malloc(1532);
    376476      if (pfealist) {
    377         memset(pfealist,0,1532);
    378         pfealist->cbList = 1024;
    379         eaop.fpGEA2List = pgealist;
    380         eaop.fpFEA2List = pfealist;
    381         eaop.oError = 0;
    382         rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
    383                               (PVOID)&eaop,
    384                               (ULONG)sizeof(EAOP2));
    385         if (!rc) {
    386           pfea = &eaop.fpFEA2List->list[0];
    387           value = pfea->szName + pfea->cbName + 1;
    388           value[pfea->cbValue] = 0;
    389           if (*(USHORT *)value == EAT_ASCII)
    390             strncpy(pci->szSubject,value + (sizeof(USHORT) * 2),39);
    391           pci->szSubject[39] = 0;
    392         }
    393         free(pfealist);
     477        memset(pfealist,0,1532);
     478        pfealist->cbList = 1024;
     479        eaop.fpGEA2List = pgealist;
     480        eaop.fpFEA2List = pfealist;
     481        eaop.oError = 0;
     482        rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
     483                              (PVOID)&eaop,
     484                              (ULONG)sizeof(EAOP2));
     485        if (!rc) {
     486          pfea = &eaop.fpFEA2List->list[0];
     487          value = pfea->szName + pfea->cbName + 1;
     488          value[pfea->cbValue] = 0;
     489          if (*(USHORT *)value == EAT_ASCII)
     490            strncpy(pci->szSubject,value + (sizeof(USHORT) * 2),39);
     491          pci->szSubject[39] = 0;
     492        }
     493        free(pfealist);
    394494      }
    395495      free(pgealist);
     
    423523      pfealist = malloc(1532);
    424524      if (pfealist) {
    425         memset(pfealist,0,1532);
    426         pfealist->cbList = 1024;
    427         eaop.fpGEA2List = pgealist;
    428         eaop.fpFEA2List = pfealist;
    429         eaop.oError = 0;
    430         rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
    431                               (PVOID)&eaop,(ULONG)sizeof(EAOP2));
    432         if (!rc) {
    433           pfea = &eaop.fpFEA2List->list[0];
    434           value = pfea->szName + pfea->cbName + 1;
    435           value[pfea->cbValue] = 0;
    436           if (*(USHORT *)value == EAT_ASCII)
    437             strncpy(pci->szLongname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP);
    438           pci->szLongname[CCHMAXPATHCOMP - 1] = 0;
    439         }
    440         free(pfealist);
     525        memset(pfealist,0,1532);
     526        pfealist->cbList = 1024;
     527        eaop.fpGEA2List = pgealist;
     528        eaop.fpFEA2List = pfealist;
     529        eaop.oError = 0;
     530        rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST,
     531                              (PVOID)&eaop,(ULONG)sizeof(EAOP2));
     532        if (!rc) {
     533          pfea = &eaop.fpFEA2List->list[0];
     534          value = pfea->szName + pfea->cbName + 1;
     535          value[pfea->cbValue] = 0;
     536          if (*(USHORT *)value == EAT_ASCII)
     537            strncpy(pci->szLongname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP);
     538          pci->szLongname[CCHMAXPATHCOMP - 1] = 0;
     539        }
     540        free(pfealist);
    441541      }
    442542      free(pgealist);
     
    449549    strlwr(pci->szFileName);
    450550
    451   if (pfsa4->attrFile & FILE_DIRECTORY) {
    452     if (!fNoIconsDirs && (!isalpha(*pci->szFileName) ||
    453         !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))
     551  if (pfsa4->attrFile & FILE_DIRECTORY)
     552  {
     553    if (fNoIconsDirs ||
     554        (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS) ||
     555        !isalpha(*pci->szFileName))
     556    {
     557      hptr = (HPOINTER)0;
     558    }
     559    else
    454560      hptr = WinLoadFileIcon(pci->szFileName, FALSE);
     561  }
     562  else
     563  {
     564    if (fNoIconsFiles ||
     565        (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS) ||
     566        !isalpha(*pci->szFileName))
     567    {
     568      hptr = IDFile(pci->szFileName);
     569    }
    455570    else
    456       hptr = (HPOINTER)0;
    457   }
    458   else
    459   {
    460     if (!fNoIconsFiles && (!isalpha(*pci->szFileName) ||
    461         !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))
    462571      hptr = WinLoadFileIcon(pci->szFileName, FALSE);
    463     else
    464     {
    465       p = strrchr(pci->szFileName,'.');
    466       if (p && !p[4]) {
    467         cmps[1] = toupper(p[1]);
    468         cmps[2] = toupper(p[2]);
    469         cmps[3] = toupper(p[3]);
    470         cmp = *(ULONG *)cmps;
    471         hptr = IDFile(cmp);
    472       }
    473       else
    474         hptr = (HPOINTER)0;
    475     }
    476572  }
    477573  if (!hptr)
    478     hptr = ((pfsa4->attrFile & FILE_DIRECTORY) != 0) ? hptrDir :
    479             ((pfsa4->attrFile & FILE_SYSTEM) != 0)   ? hptrSystem :
    480             ((pfsa4->attrFile & FILE_HIDDEN) != 0)   ? hptrHidden :
    481             ((pfsa4->attrFile & FILE_READONLY) != 0) ? hptrReadonly :
    482             hptrFile;
    483 
    484   if (partial) {
     574  {
     575    hptr = pfsa4->attrFile & FILE_DIRECTORY ?
     576             hptrDir :
     577             pfsa4->attrFile & FILE_SYSTEM ?
     578                hptrSystem :
     579                pfsa4->attrFile & FILE_HIDDEN ?
     580                  hptrHidden :
     581                  pfsa4->attrFile & FILE_READONLY ?
     582                     hptrReadonly :
     583                     hptrFile;
     584  }
     585
     586  if (partial)
     587  {
    485588    p = strrchr(pci->szFileName,'\\');
    486589    if (!p) {
    487         p = strrchr(pci->szFileName,':');
     590        p = strrchr(pci->szFileName,':');
    488591      if (!p)
    489         p = pci->szFileName;
     592        p = pci->szFileName;
    490593      else
    491         p++;
     594        p++;
    492595    }
    493596    else if ((dcd && dcd->type == TREE_FRAME) ||
    494              !(pfsa4->attrFile & FILE_DIRECTORY) ||
     597             !(pfsa4->attrFile & FILE_DIRECTORY) ||
    495598             !*(p + 1))
    496599      p++;
     
    526629    if (attrstring[x])
    527630      pci->szDispAttr[y++] = (CHAR)((pci->attrFile & (1 << x)) ?
    528                              attrstring[x] : '-');
     631                             attrstring[x] : '-');
    529632  pci->szDispAttr[5]  = 0;
    530633  pci->pszDispAttr    = pci->szDispAttr;
     
    535638      (*dcd->mask.szMask || dcd->mask.antiattr ||
    536639       ((dcd->mask.attrFile &
    537         (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) !=
    538         (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED))))
     640        (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) !=
     641        (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED))))
    539642  {
    540643    if (*dcd->mask.szMask || dcd->mask.antiattr)
    541644    {
    542645      if (!Filter((PMINIRECORDCORE)pci,(PVOID)&dcd->mask))
    543         pci->rc.flRecordAttr |= CRA_FILTERED;
     646        pci->rc.flRecordAttr |= CRA_FILTERED;
    544647    }
    545648    else if ((!(dcd->mask.attrFile & FILE_HIDDEN) &&
    546               (pci->attrFile & FILE_HIDDEN)) ||
    547              (!(dcd->mask.attrFile & FILE_SYSTEM) &&
    548               (pci->attrFile & FILE_SYSTEM)) ||
    549              (!(dcd->mask.attrFile & FILE_READONLY) &&
    550               (pci->attrFile & FILE_READONLY)) ||
    551              (!(dcd->mask.attrFile & FILE_ARCHIVED) &&
    552               (pci->attrFile & FILE_ARCHIVED)))
     649              (pci->attrFile & FILE_HIDDEN)) ||
     650             (!(dcd->mask.attrFile & FILE_SYSTEM) &&
     651              (pci->attrFile & FILE_SYSTEM)) ||
     652             (!(dcd->mask.attrFile & FILE_READONLY) &&
     653              (pci->attrFile & FILE_READONLY)) ||
     654             (!(dcd->mask.attrFile & FILE_ARCHIVED) &&
     655              (pci->attrFile & FILE_ARCHIVED)))
    553656      pci->rc.flRecordAttr |= CRA_FILTERED;
    554657  }
     
    560663
    561664VOID ProcessDirectory(const HWND hwndCnr, const PCNRITEM pciParent,
    562                       const CHAR *szDirBase, const BOOL filestoo,
    563                       const BOOL recurse,const BOOL partial,
    564                       CHAR *stopflag,
     665                      const CHAR *szDirBase, const BOOL filestoo,
     666                      const BOOL recurse,const BOOL partial,
     667                      CHAR *stopflag,
    565668                      DIRCNRDATA *dcd,                  // Optional
    566669                      ULONG *pulTotalFiles,             // Optional
     
    605708    // ulExtraBytes = EXTRA_RECORD_BYTES2;
    606709    if ((driveflags[toupper(*szDirBase) - 'A'] & DRIVE_REMOTE) && fRemoteBug)
    607       ulM = 1;                          /* file system gets confused */
     710      ulM = 1;          /* file system gets confused */
    608711    else if (driveflags[toupper(*szDirBase) - 'A'] & DRIVE_ZIPSTREAM)
    609712      ulM = min(FilesToGet,225);        /* anything more is wasted */
     
    634737    DosError(FERR_DISABLEHARDERR);
    635738    rc = DosFindFirst(pszFileSpec, &hdir,
    636                       FILE_NORMAL | ((filestoo) ? FILE_DIRECTORY :
    637                       MUST_HAVE_DIRECTORY) | FILE_READONLY |
    638                       FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
    639                       paffbFound, ulM * sizeof(FILEFINDBUF4),
    640                       &ulFileCnt, FIL_QUERYEASIZE);
     739                      FILE_NORMAL | ((filestoo) ? FILE_DIRECTORY :
     740                      MUST_HAVE_DIRECTORY) | FILE_READONLY |
     741                      FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
     742                      paffbFound, ulM * sizeof(FILEFINDBUF4),
     743                      &ulFileCnt, FIL_QUERYEASIZE);
    641744    priority_normal();
    642745    *pchEndPath = 0;
     
    645748      while (!rc)
    646749      {
    647         /*
    648         * remove . and .. from list if present
    649         * also counter file system bugs that sometimes
    650         * allows normal files to slip through when
    651         * only directories should appear (only a few
    652         * network file systems exhibit such a problem).
    653         */
    654         register ULONG x;
    655 
    656         if (stopflag && *stopflag)
    657           goto Abort;
    658         pByte = (PBYTE)paffbFound;
    659         for (x = 0;;x < ulFileCnt)
     750        /*
     751        * remove . and .. from list if present
     752        * also counter file system bugs that sometimes
     753        * allows normal files to slip through when
     754        * only directories should appear (only a few
     755        * network file systems exhibit such a problem).
     756        */
     757        register ULONG x;
     758
     759        if (stopflag && *stopflag)
     760          goto Abort;
     761        pByte = (PBYTE)paffbFound;
     762        for (x = 0;x < ulFileCnt;)
    660763        {
    661           pffbFile = (PFILEFINDBUF4)pByte;
    662           if (!*pffbFile->achName ||
    663               (!filestoo && !(pffbFile->attrFile & FILE_DIRECTORY)) ||
    664               (((pffbFile->attrFile & FILE_DIRECTORY) &&
    665                 pffbFile->achName[0] == '.') &&
    666                (!pffbFile->achName[1] || (pffbFile->achName[1] == '.' &&
    667                 !pffbFile->achName[2]))))
     764          pffbFile = (PFILEFINDBUF4)pByte;
     765          if (!*pffbFile->achName ||
     766              (!filestoo && !(pffbFile->attrFile & FILE_DIRECTORY)) ||
     767              (((pffbFile->attrFile & FILE_DIRECTORY) &&
     768                pffbFile->achName[0] == '.') &&
     769               (!pffbFile->achName[1] || (pffbFile->achName[1] == '.' &&
     770                !pffbFile->achName[2]))))
    668771          {
    669             ulFileCnt--;
     772            ulFileCnt--;                // Got . or ..
    670773          }
    671           else
    672             papffbSelected[x++] = pffbFile;
    673           if (!pffbFile->oNextEntryOffset)
     774          else
     775            papffbSelected[x++] = pffbFile;     // Count file
     776          if (!pffbFile->oNextEntryOffset)
    674777          {
    675             ulFileCnt = x;
    676             break;
    677           }
    678           pByte += pffbFile->oNextEntryOffset;
    679         }
    680         if (ulFileCnt)
     778            ulFileCnt = x;                      // Adjust count
     779            break;
     780          }
     781          pByte += pffbFile->oNextEntryOffset;
     782        }
     783        if (ulFileCnt)
    681784        {
    682           if (stopflag && *stopflag)
    683             goto Abort;
    684           if (fSyncUpdates)
     785          if (stopflag && *stopflag)
     786            goto Abort;
     787          if (fSyncUpdates)
    685788          {
    686             pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
    687                                   MPFROMLONG(ulExtraBytes),
    688                                   MPFROMLONG(ulFileCnt));
    689             if (pciFirst)
     789            pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
     790                                  MPFROMLONG(ulExtraBytes),
     791                                  MPFROMLONG(ulFileCnt));
     792            if (pciFirst)
    690793            {
    691               register INT   i;
    692 
    693               pci = pciFirst;
    694               ullTotalBytes = 0;
    695               for(i = 0; i < ulFileCnt; i++) {
    696                 pffbFile = papffbSelected[i];
    697                 ullBytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec,
    698                                         pffbFile,partial,dcd);
    699                 pci = (PCNRITEM)pci->rc.preccNextRecord;
    700                 ullTotalBytes += ullBytes;
    701               }
    702               if (ulFileCnt)
     794              register INT   i;
     795
     796              pci = pciFirst;
     797              ullTotalBytes = 0;
     798              for(i = 0; i < ulFileCnt; i++) {
     799                pffbFile = papffbSelected[i];
     800                ullBytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec,
     801                                        pffbFile,partial,dcd);
     802                pci = (PCNRITEM)pci->rc.preccNextRecord;
     803                ullTotalBytes += ullBytes;
     804              }
     805              if (ulFileCnt)
    703806              {
    704                 memset(&ri,0,sizeof(RECORDINSERT));
    705                 ri.cb                 = sizeof(RECORDINSERT);
    706                 ri.pRecordOrder       = (PRECORDCORE) CMA_END;
    707                 ri.pRecordParent      = (PRECORDCORE) pciParent;
    708                 ri.zOrder             = (ULONG) CMA_TOP;
    709                 ri.cRecordsInsert     = ulFileCnt;
    710                 ri.fInvalidateRecord  = (!fSyncUpdates && dcd &&
    711                                         dcd->type == DIR_FRAME) ?
    712                                           FALSE : TRUE;
    713                 if (!WinSendMsg(hwndCnr,
    714                                 CM_INSERTRECORD,
    715                                 MPFROMP(pciFirst),
    716                                 MPFROMP(&ri)))
     807                memset(&ri,0,sizeof(RECORDINSERT));
     808                ri.cb                 = sizeof(RECORDINSERT);
     809                ri.pRecordOrder       = (PRECORDCORE) CMA_END;
     810                ri.pRecordParent      = (PRECORDCORE) pciParent;
     811                ri.zOrder             = (ULONG) CMA_TOP;
     812                ri.cRecordsInsert     = ulFileCnt;
     813                ri.fInvalidateRecord  = (!fSyncUpdates && dcd &&
     814                                        dcd->type == DIR_FRAME) ?
     815                                          FALSE : TRUE;
     816                if (!WinSendMsg(hwndCnr,
     817                                CM_INSERTRECORD,
     818                                MPFROMP(pciFirst),
     819                                MPFROMP(&ri)))
    717820                {
    718                   DosSleep(100);
    719                   WinSetFocus(HWND_DESKTOP,hwndCnr);
    720                   if (!WinSendMsg(hwndCnr,
    721                                   CM_INSERTRECORD,
    722                                   MPFROMP(pciFirst),
    723                                   MPFROMP(&ri)))
     821                  DosSleep(100);
     822                  WinSetFocus(HWND_DESKTOP,hwndCnr);
     823                  if (!WinSendMsg(hwndCnr,
     824                                  CM_INSERTRECORD,
     825                                  MPFROMP(pciFirst),
     826                                  MPFROMP(&ri)))
    724827                  {
    725                     Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
    726                               GetPString(IDS_FILLDIRERR2TEXT));
    727                     ok = FALSE;
    728                     ullTotalBytes = 0;
    729                     if (WinIsWindow((HAB)0,hwndCnr))
     828                    Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
     829                              GetPString(IDS_FILLDIRERR2TEXT));
     830                    ok = FALSE;
     831                    ullTotalBytes = 0;
     832                    if (WinIsWindow((HAB)0,hwndCnr))
    730833                    {
    731                       pci = pciFirst;
    732                       while (pci)
     834                      pci = pciFirst;
     835                      while (pci)
    733836                      {
    734                         pcit = (PCNRITEM)pci->rc.preccNextRecord;
    735                         WinSendMsg(hwndCnr,
    736                                    CM_FREERECORD,
    737                                    MPFROMP(&pci),
    738                                    MPFROMSHORT(1));
    739                         pci = pcit;
    740                       }
    741                     }
    742                   }
    743                 }
    744               }
    745             }
    746             else
     837                        pcit = (PCNRITEM)pci->rc.preccNextRecord;
     838                        WinSendMsg(hwndCnr,
     839                                   CM_FREERECORD,
     840                                   MPFROMP(&pci),
     841                                   MPFROMSHORT(1));
     842                        pci = pcit;
     843                      }
     844                    }
     845                  }
     846                }
     847              }
     848            }
     849            else
    747850            {
    748               Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
    749                         GetPString(IDS_FILLDIRERR3TEXT));
    750               ok = FALSE;
    751               ullTotalBytes = 0;
    752             }
    753             if (ok)
     851              Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
     852                        GetPString(IDS_FILLDIRERR3TEXT));
     853              ok = FALSE;
     854              ullTotalBytes = 0;
     855            }
     856            if (ok)
    754857            {
    755               ullReturnBytes += ullTotalBytes;
    756               ulReturnFiles += ulFileCnt;
    757             }
    758           }
    759           else
     858              ullReturnBytes += ullTotalBytes;
     859              ulReturnFiles += ulFileCnt;
     860            }
     861          }
     862          else
    760863          {
    761             paffbTemp = realloc(paffbTotal,sizeof(FILEFINDBUF4) *
    762                                      (ulFileCnt + ulTotal));
    763             if (paffbTemp)
     864            paffbTemp = realloc(paffbTotal,sizeof(FILEFINDBUF4) *
     865                                     (ulFileCnt + ulTotal));
     866            if (paffbTemp)
    764867            {
    765               paffbTotal = paffbTemp;
    766               for(x = 0;x < ulFileCnt;x++)
    767                 paffbTotal[x + ulTotal] = *papffbSelected[x];
    768               ulTotal += ulFileCnt;
    769             }
    770             else
     868              paffbTotal = paffbTemp;
     869              for(x = 0;x < ulFileCnt;x++)
     870                paffbTotal[x + ulTotal] = *papffbSelected[x];
     871              ulTotal += ulFileCnt;
     872            }
     873            else
    771874            {
    772               saymsg(MB_ENTER,
    773                      HWND_DESKTOP,
    774                      GetPString(IDS_ERRORTEXT),
    775                      GetPString(IDS_OUTOFMEMORY));
    776               break;
    777             }
    778           }
    779         }
    780         if (stopflag && *stopflag)
    781             goto Abort;
    782         ulFileCnt = ulM;
    783         DosError(FERR_DISABLEHARDERR);
    784         rc = DosFindNext(hdir, paffbFound, ulM * sizeof(FILEFINDBUF4),
    785                         &ulFileCnt);
    786         priority_normal();
    787         if (rc)
    788           DosError(FERR_DISABLEHARDERR);
     875              saymsg(MB_ENTER,
     876                     HWND_DESKTOP,
     877                     GetPString(IDS_ERRORTEXT),
     878                     GetPString(IDS_OUTOFMEMORY));
     879              break;
     880            }
     881          }
     882        }
     883        if (stopflag && *stopflag)
     884            goto Abort;
     885        ulFileCnt = ulM;
     886        DosError(FERR_DISABLEHARDERR);
     887        rc = DosFindNext(hdir, paffbFound, ulM * sizeof(FILEFINDBUF4),
     888                        &ulFileCnt);
     889        priority_normal();
     890        if (rc)
     891          DosError(FERR_DISABLEHARDERR);
    789892      }
    790893      DosFindClose(hdir);
    791894
    792895      if (paffbFound || papffbSelected) {
    793         if (paffbFound)
    794           free(paffbFound);
    795         if (papffbSelected)
    796           free(papffbSelected);
    797         papffbSelected = NULL;
    798         paffbFound = NULL;
     896        if (paffbFound)
     897          free(paffbFound);
     898        if (papffbSelected)
     899          free(papffbSelected);
     900        papffbSelected = NULL;
     901        paffbFound = NULL;
    799902      }
    800903
     
    802905      {
    803906
    804         if (stopflag && *stopflag)
    805           goto Abort;
    806 
    807         pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
    808                               MPFROMLONG(ulExtraBytes),
    809                               MPFROMLONG(ulTotal));
    810         if (pciFirst)
     907        if (stopflag && *stopflag)
     908          goto Abort;
     909
     910        pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
     911                              MPFROMLONG(ulExtraBytes),
     912                              MPFROMLONG(ulTotal));
     913        if (pciFirst)
    811914        {
    812           register INT   i;
    813 
    814           pci = pciFirst;
    815           ullTotalBytes = 0;
    816           pByte2 = (PBYTE)paffbTotal;
    817           for(i = 0; i < ulTotal; i++)
     915          register INT   i;
     916
     917          pci = pciFirst;
     918          ullTotalBytes = 0;
     919          pByte2 = (PBYTE)paffbTotal;
     920          for(i = 0; i < ulTotal; i++)
    818921          {
    819             pffbFile = (PFILEFINDBUF4)pByte2;
    820             ullBytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec,
    821                                            pffbFile,partial,dcd);
    822             pci = (PCNRITEM)pci->rc.preccNextRecord;
    823             ullTotalBytes += ullBytes;
    824 
    825             pByte2 += sizeof(FILEFINDBUF4);
    826           }
    827           if (ulTotal)
     922            pffbFile = (PFILEFINDBUF4)pByte2;
     923            ullBytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec,
     924                                           pffbFile,partial,dcd);
     925            pci = (PCNRITEM)pci->rc.preccNextRecord;
     926            ullTotalBytes += ullBytes;
     927
     928            pByte2 += sizeof(FILEFINDBUF4);
     929          }
     930          if (ulTotal)
    828931          {
    829             memset(&ri,0,sizeof(RECORDINSERT));
    830             ri.cb                 = sizeof(RECORDINSERT);
    831             ri.pRecordOrder       = (PRECORDCORE) CMA_END;
    832             ri.pRecordParent      = (PRECORDCORE) pciParent;
    833             ri.zOrder             = (ULONG) CMA_TOP;
    834             ri.cRecordsInsert     = ulTotal;
    835             ri.fInvalidateRecord  = (!fSyncUpdates && dcd &&
    836                                      dcd->type == DIR_FRAME) ?
    837                                       FALSE : TRUE;
    838             if (!WinSendMsg(hwndCnr,CM_INSERTRECORD,
    839                             MPFROMP(pciFirst),MPFROMP(&ri)))
     932            memset(&ri,0,sizeof(RECORDINSERT));
     933            ri.cb                 = sizeof(RECORDINSERT);
     934            ri.pRecordOrder       = (PRECORDCORE) CMA_END;
     935            ri.pRecordParent      = (PRECORDCORE) pciParent;
     936            ri.zOrder             = (ULONG) CMA_TOP;
     937            ri.cRecordsInsert     = ulTotal;
     938            ri.fInvalidateRecord  = (!fSyncUpdates && dcd &&
     939                                     dcd->type == DIR_FRAME) ?
     940                                      FALSE : TRUE;
     941            if (!WinSendMsg(hwndCnr,CM_INSERTRECORD,
     942                            MPFROMP(pciFirst),MPFROMP(&ri)))
    840943            {
    841               DosSleep(100);
    842               WinSetFocus(HWND_DESKTOP,hwndCnr);
    843               if (!WinSendMsg(hwndCnr,CM_INSERTRECORD,
    844                              MPFROMP(pciFirst),MPFROMP(&ri)))
    845               {
    846                 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
    847                           GetPString(IDS_FILLDIRERR5TEXT));
    848                 ok = FALSE;
    849                 ullTotalBytes = 0;
    850                 if (WinIsWindow((HAB)0,hwndCnr))
     944              DosSleep(100);
     945              WinSetFocus(HWND_DESKTOP,hwndCnr);
     946              if (!WinSendMsg(hwndCnr,CM_INSERTRECORD,
     947                             MPFROMP(pciFirst),MPFROMP(&ri)))
     948              {
     949                Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
     950                          GetPString(IDS_FILLDIRERR5TEXT));
     951                ok = FALSE;
     952                ullTotalBytes = 0;
     953                if (WinIsWindow((HAB)0,hwndCnr))
    851954                {
    852                   pci = pciFirst;
    853                   while (pci)
     955                  pci = pciFirst;
     956                  while (pci)
    854957                  {
    855                     pcit = (PCNRITEM)pci->rc.preccNextRecord;
    856                     WinSendMsg(hwndCnr,CM_FREERECORD,
    857                                MPFROMP(&pci),MPFROMSHORT(1));
    858                     pci = pcit;
    859                   }
    860                 }
    861               }
    862             }
    863           }
    864         }
    865         else
     958                    pcit = (PCNRITEM)pci->rc.preccNextRecord;
     959                    WinSendMsg(hwndCnr,CM_FREERECORD,
     960                               MPFROMP(&pci),MPFROMSHORT(1));
     961                    pci = pcit;
     962                  }
     963                }
     964              }
     965            }
     966          }
     967        }
     968        else
    866969        {
    867           Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
    868                     GetPString(IDS_FILLDIRERR3TEXT));
    869           ok = FALSE;
    870           ullTotalBytes = 0;
    871         }
    872         if (ok)
     970          Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__,
     971                    GetPString(IDS_FILLDIRERR3TEXT));
     972          ok = FALSE;
     973          ullTotalBytes = 0;
     974        }
     975        if (ok)
    873976        {
    874           ullReturnBytes += ullTotalBytes;
    875           ulReturnFiles += ulFileCnt;
    876         }
     977          ullReturnBytes += ullTotalBytes;
     978          ulReturnFiles += ulFileCnt;
     979        }
    877980      }
    878981    }
     
    880983    if (!fSyncUpdates && dcd && dcd->type == DIR_FRAME)
    881984      WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID,
    882                 MPFROM2SHORT(0,CMA_ERASE));
     985                MPFROM2SHORT(0,CMA_ERASE));
    883986  }
    884987Abort:
     
    8971000  {
    8981001    pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent),
    899                      MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
     1002                     MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    9001003    while (pci && (INT)pci != -1)
    9011004    {
    9021005      if (pci->attrFile & FILE_DIRECTORY)
    903         Stubby(hwndCnr,pci);
     1006        Stubby(hwndCnr,pci);
    9041007      pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
    905                        MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
     1008                       MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    9061009    }
    9071010  }
     
    9171020
    9181021VOID FillDirCnr(HWND hwndCnr,
    919                 CHAR *pszDirectory,
    920                 DIRCNRDATA *dcd,
    921                 PULONGLONG pullTotalBytes)
     1022                CHAR *pszDirectory,
     1023                DIRCNRDATA *dcd,
     1024                PULONGLONG pullTotalBytes)
    9221025{
    9231026  ProcessDirectory(hwndCnr,
    924                    (PCNRITEM)NULL,
     1027                   (PCNRITEM)NULL,
    9251028                   pszDirectory,
    9261029                   TRUE,
    9271030                   FALSE,
    9281031                   TRUE,
    929                    dcd ? &dcd->stopflag : NULL,
     1032                   dcd ? &dcd->stopflag : NULL,
    9301033                   dcd,
    9311034                   NULL,
     
    9511054  for (x = 0;x < 26;x++)
    9521055    driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS |
    953                       DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS |
    954                       DRIVE_INCLUDEFILES | DRIVE_SLOW);
     1056                      DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS |
     1057                      DRIVE_INCLUDEFILES | DRIVE_SLOW);
    9551058  memset(driveserial,-1,sizeof(driveserial));
    9561059  {
     
    9591062    DosError(FERR_DISABLEHARDERR);
    9601063    if (!DosQuerySysInfo(QSV_BOOT_DRIVE,
    961                         QSV_BOOT_DRIVE,
    962                         (PVOID)&startdrive,
    963                         (ULONG)sizeof(ULONG)) &&
     1064                        QSV_BOOT_DRIVE,
     1065                        (PVOID)&startdrive,
     1066                        (ULONG)sizeof(ULONG)) &&
    9641067       startdrive)
    9651068      driveflags[startdrive - 1] |= DRIVE_BOOT;
     
    9671070  DosError(FERR_DISABLEHARDERR);
    9681071  rc = DosQCurDisk(&ulDriveNum,
    969                    &ulDriveMap);
     1072                   &ulDriveMap);
    9701073  if (rc)
    9711074  {
    9721075    Dos_Error(MB_CANCEL,
    973               rc,
    974               HWND_DESKTOP,
    975               __FILE__,
    976               __LINE__,
    977               GetPString(IDS_FILLDIRERR6TEXT));
     1076              rc,
     1077              HWND_DESKTOP,
     1078              __FILE__,
     1079              __LINE__,
     1080              GetPString(IDS_FILLDIRERR6TEXT));
    9781081    exit(0);
    9791082  }
     
    9831086  if (numtoinsert)
    9841087    pciFirst = WinSendMsg(hwndCnr,
    985                           CM_ALLOCRECORD,
    986                           MPFROMLONG(EXTRA_RECORD_BYTES2),
    987                           MPFROMLONG((ULONG)numtoinsert));
     1088                          CM_ALLOCRECORD,
     1089                          MPFROMLONG(EXTRA_RECORD_BYTES2),
     1090                          MPFROMLONG((ULONG)numtoinsert));
    9881091  if (pciFirst)
    9891092  {
     
    9921095      if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE))
    9931096      {
    994         *szDrive = (CHAR)x + 'A';
    995 
    996         {
    997           CHAR  s[80];
    998           ULONG flags = 0;
     1097        *szDrive = (CHAR)x + 'A';
     1098
     1099        {
     1100          CHAR  s[80];
     1101          ULONG flags = 0;
    9991102          ULONG size = sizeof(ULONG);
    10001103
    1001           sprintf(s,"%c.DriveFlags",toupper(*szDrive));
    1002           if (PrfQueryProfileData(fmprof,appname,s,&flags,&size) &&
    1003               size == sizeof(ULONG))
     1104          sprintf(s,"%c.DriveFlags",toupper(*szDrive));
     1105          if (PrfQueryProfileData(fmprof,appname,s,&flags,&size) &&
     1106              size == sizeof(ULONG))
    10041107          {
    1005             driveflags[toupper(*szDrive) - 'A'] |= flags;
     1108            driveflags[toupper(*szDrive) - 'A'] |= flags;
    10061109          }
    1007         }
    1008 
    1009         if (x > 1)
     1110        }
     1111
     1112        if (x > 1)
    10101113        {
    1011           if (!(driveflags[x] & DRIVE_NOPRESCAN))
     1114          if (!(driveflags[x] & DRIVE_NOPRESCAN))
    10121115          {
    1013             *FileSystem = 0;
    1014             drvtype = 0;
    1015             removable = CheckDrive(*szDrive,FileSystem,&drvtype);
    1016             driveserial[x] = -1;
    1017             if (removable != -1)
     1116            *FileSystem = 0;
     1117            drvtype = 0;
     1118            removable = CheckDrive(*szDrive,FileSystem,&drvtype);
     1119            driveserial[x] = -1;
     1120            if (removable != -1)
    10181121            {
    1019               struct {
    1020                 ULONG serial;
    1021                 CHAR  volumelength;
    1022                 CHAR  volumelabel[CCHMAXPATH];
    1023               } volser;
    1024 
    1025               DosError(FERR_DISABLEHARDERR);
    1026               if (!DosQueryFSInfo((ULONG)x,
    1027                                   FSIL_VOLSER,
    1028                                   &volser,
    1029                                   sizeof(volser)))
    1030               {
    1031                 driveserial[x] = volser.serial;
     1122              struct {
     1123                ULONG serial;
     1124                CHAR  volumelength;
     1125                CHAR  volumelabel[CCHMAXPATH];
     1126              } volser;
     1127
     1128              DosError(FERR_DISABLEHARDERR);
     1129              if (!DosQueryFSInfo((ULONG)x,
     1130                                  FSIL_VOLSER,
     1131                                  &volser,
     1132                                  sizeof(volser)))
     1133              {
     1134                driveserial[x] = volser.serial;
    10321135              }
    1033             }
    1034             else
    1035               driveflags[x] |= DRIVE_INVALID;
    1036             memset(&fsa4,0,sizeof(FILESTATUS4));
    1037             driveflags[x] |= ((removable == -1 || removable == 1) ?
    1038                                                DRIVE_REMOVABLE : 0);
    1039             if (drvtype & DRIVE_REMOTE)
    1040               driveflags[x] |= DRIVE_REMOTE;
    1041             if (strcmp(FileSystem,HPFS) &&
    1042                 strcmp(FileSystem,JFS) &&
    1043                 strcmp(FileSystem,CDFS) &&
    1044                 strcmp(FileSystem,FAT32) &&
    1045                 strcmp(FileSystem,HPFS386))
     1136            }
     1137            else
     1138              driveflags[x] |= DRIVE_INVALID;
     1139            memset(&fsa4,0,sizeof(FILESTATUS4));
     1140            driveflags[x] |= ((removable == -1 || removable == 1) ?
     1141                                               DRIVE_REMOVABLE : 0);
     1142            if (drvtype & DRIVE_REMOTE)
     1143              driveflags[x] |= DRIVE_REMOTE;
     1144            if (strcmp(FileSystem,HPFS) &&
     1145                strcmp(FileSystem,JFS) &&
     1146                strcmp(FileSystem,CDFS) &&
     1147                strcmp(FileSystem,FAT32) &&
     1148                strcmp(FileSystem,HPFS386))
    10461149            {
    1047               driveflags[x] |= DRIVE_NOLONGNAMES;
     1150              driveflags[x] |= DRIVE_NOLONGNAMES;
    10481151            }
    1049             if (!strcmp(FileSystem,CDFS))
     1152            if (!strcmp(FileSystem,CDFS))
    10501153            {
    1051               removable = 1;
    1052               driveflags[x] |= DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE |
    1053                                 DRIVE_CDROM;
    1054             }
    1055             else if (!stricmp(FileSystem,CBSIFS))
     1154              removable = 1;
     1155              driveflags[x] |= DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE |
     1156                                DRIVE_CDROM;
     1157            }
     1158            else if (!stricmp(FileSystem,CBSIFS))
    10561159            {
    1057               driveflags[x] |= DRIVE_ZIPSTREAM;
    1058               driveflags[x] &= ~DRIVE_REMOTE;
    1059               if (drvtype & DRIVE_REMOVABLE)
    1060                 driveflags[x] |= DRIVE_REMOVABLE;
    1061               if (!(drvtype & DRIVE_NOLONGNAMES))
    1062                 driveflags[x] &= ~DRIVE_NOLONGNAMES;
    1063             }
    1064 
    1065             pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
    1066             if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum)
    1067               pci->rc.flRecordAttr |= (CRA_CURSORED | CRA_SELECTED);
    1068 
    1069             if (removable == 0)
     1160              driveflags[x] |= DRIVE_ZIPSTREAM;
     1161              driveflags[x] &= ~DRIVE_REMOTE;
     1162              if (drvtype & DRIVE_REMOVABLE)
     1163                driveflags[x] |= DRIVE_REMOVABLE;
     1164              if (!(drvtype & DRIVE_NOLONGNAMES))
     1165                driveflags[x] &= ~DRIVE_NOLONGNAMES;
     1166            }
     1167
     1168            pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
     1169            if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum)
     1170              pci->rc.flRecordAttr |= (CRA_CURSORED | CRA_SELECTED);
     1171
     1172            if (removable == 0)
    10701173            {
    1071               pci->attrFile |= FILE_DIRECTORY;
    1072               DosError(FERR_DISABLEHARDERR);
    1073               rc = DosQueryPathInfo(szDrive,
    1074                                     FIL_QUERYEASIZE,
    1075                                     &fsa4,
    1076                                     (ULONG)sizeof(FILESTATUS4));
    1077               if (rc == 58)
     1174              pci->attrFile |= FILE_DIRECTORY;
     1175              DosError(FERR_DISABLEHARDERR);
     1176              rc = DosQueryPathInfo(szDrive,
     1177                                    FIL_QUERYEASIZE,
     1178                                    &fsa4,
     1179                                    (ULONG)sizeof(FILESTATUS4));
     1180              if (rc == 58)
    10781181              {
    1079                 DosError(FERR_DISABLEHARDERR);
    1080                 rc = DosQueryPathInfo(szDrive,
    1081                                       FIL_STANDARD,
    1082                                       &fsa4,
    1083                                       (ULONG)sizeof(FILESTATUS3));
    1084                 fsa4.cbList = 0;
    1085               }
    1086               if (rc && !didonce)
     1182                DosError(FERR_DISABLEHARDERR);
     1183                rc = DosQueryPathInfo(szDrive,
     1184                                      FIL_STANDARD,
     1185                                      &fsa4,
     1186                                      (ULONG)sizeof(FILESTATUS3));
     1187                fsa4.cbList = 0;
     1188              }
     1189              if (rc && !didonce)
    10871190              {
    1088                 if (!*suggest)
     1191                if (!*suggest)
    10891192                {
    1090                   *suggest = '/';
    1091                   suggest[1] = 0;
    1092                 }
    1093                 sprintf(suggest + strlen(suggest),
    1094                         "%c",
    1095                         toupper(*szDrive));
    1096                 strcpy(pci->szFileName,szDrive);
    1097                 pci->pszFileName = pci->szFileName;
    1098                 pci->rc.pszIcon = pci->pszFileName;
    1099                 pci->attrFile = FILE_DIRECTORY;
    1100                 strcpy(pci->szDispAttr,"----D-");
    1101                 pci->pszDispAttr = pci->szDispAttr;
    1102                 driveserial[x] = -1;
    1103               }
    1104               else
    1105                 FillInRecordFromFSA(hwndCnr,
    1106                                     pci,
    1107                                     szDrive,
    1108                                     &fsa4,
    1109                                     TRUE,
    1110                                     NULL);
    1111             }
    1112             else
     1193                  *suggest = '/';
     1194                  suggest[1] = 0;
     1195                }
     1196                sprintf(suggest + strlen(suggest),
     1197                        "%c",
     1198                        toupper(*szDrive));
     1199                strcpy(pci->szFileName,szDrive);
     1200                pci->pszFileName = pci->szFileName;
     1201                pci->rc.pszIcon = pci->pszFileName;
     1202                pci->attrFile = FILE_DIRECTORY;
     1203                strcpy(pci->szDispAttr,"----D-");
     1204                pci->pszDispAttr = pci->szDispAttr;
     1205                driveserial[x] = -1;
     1206              }
     1207              else
     1208                FillInRecordFromFSA(hwndCnr,
     1209                                    pci,
     1210                                    szDrive,
     1211                                    &fsa4,
     1212                                    TRUE,
     1213                                    NULL);
     1214            }
     1215            else
    11131216            {
    1114               strcpy(pci->szFileName,szDrive);
    1115               pci->pszFileName = pci->szFileName;
    1116               pci->rc.pszIcon = pci->pszFileName;
    1117               pci->attrFile = FILE_DIRECTORY;
    1118               strcpy(pci->szDispAttr,"----D-");
    1119               pci->pszDispAttr = pci->szDispAttr;
    1120             }
    1121             *pci->szFileName = toupper(*pci->szFileName);
    1122             if (driveflags[x] & DRIVE_CDROM)
    1123               pci->rc.hptrIcon = hptrCDROM;
    1124             else
    1125               pci->rc.hptrIcon = (driveflags[x] & DRIVE_REMOVABLE) ?
    1126                                   hptrRemovable :
    1127                                   (driveflags[x] & DRIVE_REMOTE) ?
    1128                                   hptrRemote :
    1129                                   (driveflags[x] & DRIVE_ZIPSTREAM) ?
    1130                                   hptrZipstrm : hptrDrive;
    1131           }
    1132           else
     1217              strcpy(pci->szFileName,szDrive);
     1218              pci->pszFileName = pci->szFileName;
     1219              pci->rc.pszIcon = pci->pszFileName;
     1220              pci->attrFile = FILE_DIRECTORY;
     1221              strcpy(pci->szDispAttr,"----D-");
     1222              pci->pszDispAttr = pci->szDispAttr;
     1223            }
     1224            *pci->szFileName = toupper(*pci->szFileName);
     1225            if (driveflags[x] & DRIVE_CDROM)
     1226              pci->rc.hptrIcon = hptrCDROM;
     1227            else
     1228              pci->rc.hptrIcon = (driveflags[x] & DRIVE_REMOVABLE) ?
     1229                                  hptrRemovable :
     1230                                  (driveflags[x] & DRIVE_REMOTE) ?
     1231                                  hptrRemote :
     1232                                  (driveflags[x] & DRIVE_ZIPSTREAM) ?
     1233                                  hptrZipstrm : hptrDrive;
     1234          }
     1235          else
    11331236          {
    1134             pci->rc.hptrIcon = hptrDunno;
    1135             strcpy(pci->szFileName,szDrive);
    1136             pci->pszFileName = pci->szFileName;
    1137             pci->rc.pszIcon = pci->pszFileName;
    1138             pci->attrFile = FILE_DIRECTORY;
    1139             strcpy(pci->szDispAttr,"----D-");
    1140             pci->pszDispAttr = pci->szDispAttr;
    1141             driveserial[x] = -1;
    1142           }
    1143         }
    1144         else
     1237            pci->rc.hptrIcon = hptrDunno;
     1238            strcpy(pci->szFileName,szDrive);
     1239            pci->pszFileName = pci->szFileName;
     1240            pci->rc.pszIcon = pci->pszFileName;
     1241            pci->attrFile = FILE_DIRECTORY;
     1242            strcpy(pci->szDispAttr,"----D-");
     1243            pci->pszDispAttr = pci->szDispAttr;
     1244            driveserial[x] = -1;
     1245          }
     1246        }
     1247        else
    11451248        {
    1146           pci->rc.hptrIcon = hptrFloppy;
    1147           strcpy(pci->szFileName,szDrive);
    1148           pci->pszFileName = pci->szFileName;
    1149           pci->rc.pszIcon = pci->pszFileName;
    1150           pci->attrFile = FILE_DIRECTORY;
    1151           strcpy(pci->szDispAttr,"----D-");
    1152           pci->pszDispAttr = pci->szDispAttr;
    1153           driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOLONGNAMES);
    1154           driveserial[x] = -1;
    1155         }
    1156         pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
    1157         pci = (PCNRITEM)pci->rc.preccNextRecord;  /* next rec */
     1249          pci->rc.hptrIcon = hptrFloppy;
     1250          strcpy(pci->szFileName,szDrive);
     1251          pci->pszFileName = pci->szFileName;
     1252          pci->rc.pszIcon = pci->pszFileName;
     1253          pci->attrFile = FILE_DIRECTORY;
     1254          strcpy(pci->szDispAttr,"----D-");
     1255          pci->pszDispAttr = pci->szDispAttr;
     1256          driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOLONGNAMES);
     1257          driveserial[x] = -1;
     1258        }
     1259        pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
     1260        pci = (PCNRITEM)pci->rc.preccNextRecord;  /* next rec */
    11581261      }
    11591262      else if (!(ulDriveMap & (1L << x)))
    1160         driveflags[x] |= DRIVE_INVALID;
     1263        driveflags[x] |= DRIVE_INVALID;
    11611264    }
    11621265    PostMsg(hwndMain,
    1163             UM_BUILDDRIVES,
    1164             MPVOID,
    1165             MPVOID);
     1266            UM_BUILDDRIVES,
     1267            MPVOID,
     1268            MPVOID);
    11661269    drivesbuilt = TRUE;
    11671270    /* insert the drives */
     
    11781281      ri.fInvalidateRecord  = FALSE;
    11791282      if (!WinSendMsg(hwndCnr,
    1180                       CM_INSERTRECORD,
    1181                       MPFROMP(pciFirst),
    1182                       MPFROMP(&ri)))
    1183         Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__,
    1184                   GetPString(IDS_FILLDIRERR5TEXT));
     1283                      CM_INSERTRECORD,
     1284                      MPFROMP(pciFirst),
     1285                      MPFROMP(&ri)))
     1286        Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__,
     1287                  GetPString(IDS_FILLDIRERR5TEXT));
    11851288    }
    11861289    /* move cursor onto the default drive rather than the first drive */
     
    11881291    {
    11891292      pci = (PCNRITEM)WinSendMsg(hwndCnr,
    1190                                 CM_QUERYRECORD,
    1191                                 MPVOID,
    1192                                 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
     1293                                CM_QUERYRECORD,
     1294                                MPVOID,
     1295                                MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
    11931296      while(pci && (INT)pci != -1)
    11941297      {
    1195         if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum)
     1298        if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum)
    11961299        {
    1197           WinSendMsg(hwndCnr,
    1198                      CM_SETRECORDEMPHASIS,
    1199                      MPFROMP(pci),
    1200                      MPFROM2SHORT(TRUE,CRA_CURSORED));
    1201           break;
    1202         }
    1203         pci = (PCNRITEM)WinSendMsg(hwndCnr,
    1204                                    CM_QUERYRECORD,
    1205                                    MPFROMP(pci),
    1206                                    MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
     1300          WinSendMsg(hwndCnr,
     1301                     CM_SETRECORDEMPHASIS,
     1302                     MPFROMP(pci),
     1303                     MPFROM2SHORT(TRUE,CRA_CURSORED));
     1304          break;
     1305        }
     1306        pci = (PCNRITEM)WinSendMsg(hwndCnr,
     1307                                   CM_QUERYRECORD,
     1308                                   MPFROMP(pci),
     1309                                   MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
    12071310      }
    12081311    }
     
    12101313    if (hwndParent)
    12111314      WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
    1212                 MAIN_DRIVELIST),
    1213                 LM_DELETEALL,
    1214                 MPVOID,
    1215                 MPVOID);
     1315                MAIN_DRIVELIST),
     1316                LM_DELETEALL,
     1317                MPVOID,
     1318                MPVOID);
    12161319
    12171320    if (fShowEnv)
     
    12201323
    12211324      pciParent = WinSendMsg(hwndCnr,
    1222                              CM_ALLOCRECORD,
    1223                              MPFROMLONG(EXTRA_RECORD_BYTES2),
    1224                              MPFROMLONG(1));
     1325                             CM_ALLOCRECORD,
     1326                             MPFROMLONG(EXTRA_RECORD_BYTES2),
     1327                             MPFROMLONG(1));
    12251328      if (pciParent)
    12261329      {
    1227         pciParent->flags |= RECFLAGS_ENV;
    1228         strcpy(pciParent->szFileName,GetPString(IDS_ENVVARSTEXT));
    1229         pciParent->pszFileName = pciParent->szFileName;
    1230         pciParent->rc.hptrIcon = hptrEnv;
    1231         pciParent->rc.pszIcon = pciParent->pszFileName;
    1232         strcpy(pciParent->szDispAttr,"------");
    1233         pciParent->pszDispAttr = pciParent->szDispAttr;
    1234         memset(&ri,0,sizeof(RECORDINSERT));
    1235         ri.cb                 = sizeof(RECORDINSERT);
    1236         ri.pRecordOrder       = (PRECORDCORE)CMA_END;
    1237         ri.pRecordParent      = (PRECORDCORE)NULL;
    1238         ri.zOrder             = (ULONG)CMA_TOP;
    1239         ri.cRecordsInsert     = 1;
    1240         ri.fInvalidateRecord  = FALSE;
    1241         if (WinSendMsg(hwndCnr,
    1242                        CM_INSERTRECORD,
    1243                        MPFROMP(pciParent),
    1244                        MPFROMP(&ri))) {
    1245 
    1246           char *p,*pp;
    1247 
    1248           p = GetPString(IDS_ENVVARNAMES);
    1249           while(*p == ' ')
    1250             p++;
    1251           while (*p)
     1330        pciParent->flags |= RECFLAGS_ENV;
     1331        strcpy(pciParent->szFileName,GetPString(IDS_ENVVARSTEXT));
     1332        pciParent->pszFileName = pciParent->szFileName;
     1333        pciParent->rc.hptrIcon = hptrEnv;
     1334        pciParent->rc.pszIcon = pciParent->pszFileName;
     1335        strcpy(pciParent->szDispAttr,"------");
     1336        pciParent->pszDispAttr = pciParent->szDispAttr;
     1337        memset(&ri,0,sizeof(RECORDINSERT));
     1338        ri.cb                 = sizeof(RECORDINSERT);
     1339        ri.pRecordOrder       = (PRECORDCORE)CMA_END;
     1340        ri.pRecordParent      = (PRECORDCORE)NULL;
     1341        ri.zOrder             = (ULONG)CMA_TOP;
     1342        ri.cRecordsInsert     = 1;
     1343        ri.fInvalidateRecord  = FALSE;
     1344        if (WinSendMsg(hwndCnr,
     1345                       CM_INSERTRECORD,
     1346                       MPFROMP(pciParent),
     1347                       MPFROMP(&ri))) {
     1348
     1349          char *p,*pp;
     1350
     1351          p = GetPString(IDS_ENVVARNAMES);
     1352          while(*p == ' ')
     1353            p++;
     1354          while (*p)
    12521355          {
    1253             *FileSystem = 0;
    1254             pp = FileSystem;
    1255             while(*p && *p != ' ')
    1256               *pp++ = *p++;
    1257             *pp = 0;
    1258             while(*p == ' ')
    1259               p++;
    1260             if (*FileSystem &&
    1261                 (!stricmp(FileSystem,"LIBPATH") ||
    1262                 getenv(FileSystem)))
     1356            *FileSystem = 0;
     1357            pp = FileSystem;
     1358            while(*p && *p != ' ')
     1359              *pp++ = *p++;
     1360            *pp = 0;
     1361            while(*p == ' ')
     1362              p++;
     1363            if (*FileSystem &&
     1364                (!stricmp(FileSystem,"LIBPATH") ||
     1365                getenv(FileSystem)))
    12631366            {
    1264               pci = WinSendMsg(hwndCnr,
    1265                                CM_ALLOCRECORD,
    1266                                MPFROMLONG(EXTRA_RECORD_BYTES2),
    1267                                MPFROMLONG(1));
    1268               if (pci)
     1367              pci = WinSendMsg(hwndCnr,
     1368                               CM_ALLOCRECORD,
     1369                               MPFROMLONG(EXTRA_RECORD_BYTES2),
     1370                               MPFROMLONG(1));
     1371              if (pci)
    12691372              {
    1270                 pci->flags |= RECFLAGS_ENV;
    1271                 sprintf(pci->szFileName,
    1272                         "%%%s%%",
    1273                         FileSystem);
    1274                 pci->pszFileName = pci->szFileName;
    1275                 pci->rc.hptrIcon = hptrEnv;
    1276                 pci->rc.pszIcon = pci->pszFileName;
    1277                 strcpy(pci->szDispAttr,"------");
    1278                 pci->pszDispAttr = pci->szDispAttr;
    1279                 memset(&ri,0,sizeof(RECORDINSERT));
    1280                 ri.cb                 = sizeof(RECORDINSERT);
    1281                 ri.pRecordOrder       = (PRECORDCORE)CMA_END;
    1282                 ri.pRecordParent      = (PRECORDCORE)pciParent;
    1283                 ri.zOrder             = (ULONG)CMA_TOP;
    1284                 ri.cRecordsInsert     = 1;
    1285                 ri.fInvalidateRecord  = FALSE;
    1286                 if (!WinSendMsg(hwndCnr,
    1287                                 CM_INSERTRECORD,
    1288                                 MPFROMP(pci),
    1289                                 MPFROMP(&ri))) {
    1290                   Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__,
    1291                             GetPString(IDS_FILLDIRERR5TEXT));
    1292                   WinSendMsg(hwndCnr,
    1293                              CM_FREERECORD,
    1294                              MPFROMP(&pci),
    1295                              MPFROMSHORT(1));
    1296                 }
    1297               }
    1298             }
    1299           }
    1300           WinSendMsg(hwndCnr,
    1301                      CM_INVALIDATERECORD,
    1302                      MPFROMP(&pciParent),
    1303                      MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
    1304         }
    1305         else
    1306           WinSendMsg(hwndCnr,
    1307                      CM_FREERECORD,
    1308                      MPFROMP(&pciParent),
    1309                      MPFROMSHORT(1));
     1373                pci->flags |= RECFLAGS_ENV;
     1374                sprintf(pci->szFileName,
     1375                        "%%%s%%",
     1376                        FileSystem);
     1377                pci->pszFileName = pci->szFileName;
     1378                pci->rc.hptrIcon = hptrEnv;
     1379                pci->rc.pszIcon = pci->pszFileName;
     1380                strcpy(pci->szDispAttr,"------");
     1381                pci->pszDispAttr = pci->szDispAttr;
     1382                memset(&ri,0,sizeof(RECORDINSERT));
     1383                ri.cb                 = sizeof(RECORDINSERT);
     1384                ri.pRecordOrder       = (PRECORDCORE)CMA_END;
     1385                ri.pRecordParent      = (PRECORDCORE)pciParent;
     1386                ri.zOrder             = (ULONG)CMA_TOP;
     1387                ri.cRecordsInsert     = 1;
     1388                ri.fInvalidateRecord  = FALSE;
     1389                if (!WinSendMsg(hwndCnr,
     1390                                CM_INSERTRECORD,
     1391                                MPFROMP(pci),
     1392                                MPFROMP(&ri))) {
     1393                  Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__,
     1394                            GetPString(IDS_FILLDIRERR5TEXT));
     1395                  WinSendMsg(hwndCnr,
     1396                             CM_FREERECORD,
     1397                             MPFROMP(&pci),
     1398                             MPFROMSHORT(1));
     1399                }
     1400              }
     1401            }
     1402          }
     1403          WinSendMsg(hwndCnr,
     1404                     CM_INVALIDATERECORD,
     1405                     MPFROMP(&pciParent),
     1406                     MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
     1407        }
     1408        else
     1409          WinSendMsg(hwndCnr,
     1410                     CM_FREERECORD,
     1411                     MPFROMP(&pciParent),
     1412                     MPFROMSHORT(1));
    13101413      }
    13111414    }
     
    13131416    x = 0;
    13141417    pci = (PCNRITEM)WinSendMsg(hwndCnr,
    1315                                CM_QUERYRECORD,
    1316                                MPVOID,
    1317                                MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
     1418                               CM_QUERYRECORD,
     1419                               MPVOID,
     1420                               MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    13181421    while (pci && (INT)pci != -1)
    13191422    {
    13201423      pciNext = (PCNRITEM)WinSendMsg(hwndCnr,
    1321                                      CM_QUERYRECORD,
    1322                                      MPFROMP(pci),
    1323                                      MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
     1424                                     CM_QUERYRECORD,
     1425                                     MPFROMP(pci),
     1426                                     MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    13241427      if (!(pci->flags & RECFLAGS_ENV))
    13251428      {
    1326         if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum ||
    1327             toupper(*pci->szFileName) > 'B')
     1429        if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum ||
     1430            toupper(*pci->szFileName) > 'B')
    13281431        {
    1329           if (!(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_INVALID) &&
    1330              !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOPRESCAN) &&
    1331              (!fNoRemovableScan ||
    1332               !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE)))
     1432          if (!(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_INVALID) &&
     1433             !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOPRESCAN) &&
     1434             (!fNoRemovableScan ||
     1435              !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE)))
    13331436          {
    1334             if (!Stubby(hwndCnr,pci))
     1437            if (!Stubby(hwndCnr,pci))
    13351438            {
    1336               WinSendMsg(hwndCnr,
    1337                         CM_INVALIDATERECORD,
    1338                         MPFROMP(&pci),
    1339                         MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
    1340               goto SkipBadRec;
    1341             }
    1342           }
    1343         }
    1344         else
    1345           WinSendMsg(hwndCnr,
    1346                      CM_INVALIDATERECORD,
    1347                      MPFROMP(&pci),
    1348                      MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
    1349 
    1350         WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
    1351                    MAIN_DRIVELIST),
    1352                    LM_INSERTITEM,
    1353                    MPFROM2SHORT(LIT_SORTASCENDING,0),
    1354                    MPFROMP(pci->szFileName));
     1439              WinSendMsg(hwndCnr,
     1440                        CM_INVALIDATERECORD,
     1441                        MPFROMP(&pci),
     1442                        MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
     1443              goto SkipBadRec;
     1444            }
     1445          }
     1446        }
     1447        else
     1448          WinSendMsg(hwndCnr,
     1449                     CM_INVALIDATERECORD,
     1450                     MPFROMP(&pci),
     1451                     MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
     1452
     1453        WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
     1454                   MAIN_DRIVELIST),
     1455                   LM_INSERTITEM,
     1456                   MPFROM2SHORT(LIT_SORTASCENDING,0),
     1457                   MPFROMP(pci->szFileName));
    13551458      }
    13561459SkipBadRec:
     
    13601463    if (hwndParent)
    13611464      WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT),
    1362                 MAIN_DRIVELIST),LM_SELECTITEM,MPFROM2SHORT(0,0),
    1363                 MPFROMLONG(TRUE));
     1465                MAIN_DRIVELIST),LM_SELECTITEM,MPFROM2SHORT(0,0),
     1466                MPFROMLONG(TRUE));
    13641467
    13651468    pci = (PCNRITEM)WinSendMsg(hwndCnr,
    1366                                CM_QUERYRECORD,
    1367                                MPVOID,
    1368                                MPFROM2SHORT(CMA_FIRST,
    1369                                             CMA_ITEMORDER));
     1469                               CM_QUERYRECORD,
     1470                               MPVOID,
     1471                               MPFROM2SHORT(CMA_FIRST,
     1472                                            CMA_ITEMORDER));
    13701473    while (pci && (INT)pci != -1)
    13711474    {
    13721475      pciNext = (PCNRITEM)WinSendMsg(hwndCnr,
    1373                                      CM_QUERYRECORD,
    1374                                      MPFROMP(pci),
    1375                                      MPFROM2SHORT(CMA_NEXT,
    1376                                                   CMA_ITEMORDER));
     1476                                     CM_QUERYRECORD,
     1477                                     MPFROMP(pci),
     1478                                     MPFROM2SHORT(CMA_NEXT,
     1479                                                  CMA_ITEMORDER));
    13771480      if (pci->flags & RECFLAGS_ENV)
    13781481      {
    1379         pci = (PCNRITEM)WinSendMsg(hwndCnr,
    1380                                    CM_QUERYRECORD,
    1381                                    MPFROMP(pci),
    1382                                    MPFROM2SHORT(CMA_FIRSTCHILD,
    1383                                                 CMA_ITEMORDER));
    1384         while (pci && (INT)pci != -1)
     1482        pci = (PCNRITEM)WinSendMsg(hwndCnr,
     1483                                   CM_QUERYRECORD,
     1484                                   MPFROMP(pci),
     1485                                   MPFROM2SHORT(CMA_FIRSTCHILD,
     1486                                                CMA_ITEMORDER));
     1487        while (pci && (INT)pci != -1)
    13851488        {
    1386           if (pci->flags & RECFLAGS_ENV)
    1387             FleshEnv(hwndCnr,pci);
    1388           pci = (PCNRITEM)WinSendMsg(hwndCnr,
    1389                                      CM_QUERYRECORD,
    1390                                      MPFROMP(pci),
    1391                                      MPFROM2SHORT(CMA_NEXT,
    1392                                                   CMA_ITEMORDER));
    1393         }
    1394         break;
     1489          if (pci->flags & RECFLAGS_ENV)
     1490            FleshEnv(hwndCnr,pci);
     1491          pci = (PCNRITEM)WinSendMsg(hwndCnr,
     1492                                     CM_QUERYRECORD,
     1493                                     MPFROMP(pci),
     1494                                     MPFROM2SHORT(CMA_NEXT,
     1495                                                  CMA_ITEMORDER));
     1496        }
     1497        break;
    13951498      }
    13961499      pci = (PCNRITEM)WinSendMsg(hwndCnr,
    1397                                 CM_QUERYRECORD,
    1398                                 MPFROMP(pci),
    1399                                 MPFROM2SHORT(CMA_NEXT,
    1400                                               CMA_ITEMORDER));
     1500                                CM_QUERYRECORD,
     1501                                MPFROMP(pci),
     1502                                MPFROM2SHORT(CMA_NEXT,
     1503                                              CMA_ITEMORDER));
    14011504    }
    14021505
     
    14051508  {
    14061509    Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__,
    1407               GetPString(IDS_FILLDIRERR7TEXT));
     1510              GetPString(IDS_FILLDIRERR7TEXT));
    14081511    exit(0);
    14091512  }
    14101513  if (!drivesbuilt && hwndMain)
    14111514    PostMsg(hwndMain,
    1412             UM_BUILDDRIVES,
    1413             MPVOID,
    1414             MPVOID);
     1515            UM_BUILDDRIVES,
     1516            MPVOID,
     1517            MPVOID);
    14151518  DosSleep(33L);
    14161519  fDummy = FALSE;
     
    14211524
    14221525    if (*suggest ||
    1423         (!(driveflags[1] & DRIVE_IGNORE) &&
    1424         fFirstTime))
     1526        (!(driveflags[1] & DRIVE_IGNORE) &&
     1527        fFirstTime))
    14251528    {
    14261529      if (!DosDevConfig(&info,
    1427                        DEVINFO_FLOPPY) &&
    1428            info == 1)
     1530                       DEVINFO_FLOPPY) &&
     1531           info == 1)
    14291532      {
    1430         if (!*suggest)
     1533        if (!*suggest)
    14311534        {
    1432           *suggest = '/';
    1433           suggest[1] = 0;
    1434         }
    1435         else
    1436           memmove(suggest + 2,suggest + 1,strlen(suggest));
    1437         suggest[1] = 'B';
     1535          *suggest = '/';
     1536          suggest[1] = 0;
     1537        }
     1538        else
     1539          memmove(suggest + 2,suggest + 1,strlen(suggest));
     1540        suggest[1] = 'B';
    14381541      }
    14391542    }
     
    14421545      for(x = 2;x < 26;x++)
    14431546      {
    1444         if (driveflags[x] & DRIVE_IGNORE)
     1547        if (driveflags[x] & DRIVE_IGNORE)
    14451548        {
    1446           includesyours = TRUE;
    1447           sprintf(suggest + strlen(suggest),
    1448                   "%c",
    1449                   (char)(x + 'A'));
    1450         }
     1549          includesyours = TRUE;
     1550          sprintf(suggest + strlen(suggest),
     1551                  "%c",
     1552                  (char)(x + 'A'));
     1553        }
    14511554      }
    14521555      strcat(suggest," %*");
    14531556      if (saymsg(MB_YESNO | MB_ICONEXCLAMATION,
    1454                 (hwndParent) ? hwndParent : hwndCnr,
    1455                 GetPString(IDS_SUGGESTTITLETEXT),
    1456                 GetPString(IDS_SUGGEST1TEXT),
    1457                 (includesyours) ? GetPString(IDS_SUGGEST2TEXT) : NullStr,
    1458                 suggest) == MBID_YES)
     1557                (hwndParent) ? hwndParent : hwndCnr,
     1558                GetPString(IDS_SUGGESTTITLETEXT),
     1559                GetPString(IDS_SUGGEST1TEXT),
     1560                (includesyours) ? GetPString(IDS_SUGGEST2TEXT) : NullStr,
     1561                suggest) == MBID_YES)
    14591562      {
    1460         char s[64];
    1461 
    1462         sprintf(s, "PARAMETERS=%s", suggest);
    1463         WinCreateObject(WPProgram,
    1464                         "FM/2",
    1465                         s,
    1466                         FM3Folder,
    1467                         CO_UPDATEIFEXISTS);
    1468         WinCreateObject(WPProgram,
    1469                         "FM/2 Lite",
    1470                         s,
    1471                         FM3Folder,
    1472                         CO_UPDATEIFEXISTS);
    1473         WinCreateObject(WPProgram,
    1474                         "Archive Viewer/2",
    1475                         s,
    1476                         FM3Tools,
    1477                         CO_UPDATEIFEXISTS);
    1478         WinCreateObject(WPProgram,
    1479                         "Dir Sizes",
    1480                         s,
    1481                         FM3Tools,
    1482                         CO_UPDATEIFEXISTS);
    1483         WinCreateObject(WPProgram,
    1484                         "Visual Tree",
    1485                         s,
    1486                         FM3Tools,
    1487                         CO_UPDATEIFEXISTS);
    1488         WinCreateObject(WPProgram,
    1489                         "Visual Directory",
    1490                         s,
    1491                         FM3Tools,
    1492                         CO_UPDATEIFEXISTS);
    1493         WinCreateObject(WPProgram,
    1494                         "Global File Viewer",
    1495                         s,
    1496                         FM3Tools,
    1497                         CO_UPDATEIFEXISTS);
    1498         WinCreateObject(WPProgram,
    1499                         "Databar",
    1500                         s,
    1501                         FM3Tools,
    1502                         CO_UPDATEIFEXISTS);
     1563        char s[64];
     1564
     1565        sprintf(s, "PARAMETERS=%s", suggest);
     1566        WinCreateObject(WPProgram,
     1567                        "FM/2",
     1568                        s,
     1569                        FM3Folder,
     1570                        CO_UPDATEIFEXISTS);
     1571        WinCreateObject(WPProgram,
     1572                        "FM/2 Lite",
     1573                        s,
     1574                        FM3Folder,
     1575                        CO_UPDATEIFEXISTS);
     1576        WinCreateObject(WPProgram,
     1577                        "Archive Viewer/2",
     1578                        s,
     1579                        FM3Tools,
     1580                        CO_UPDATEIFEXISTS);
     1581        WinCreateObject(WPProgram,
     1582                        "Dir Sizes",
     1583                        s,
     1584                        FM3Tools,
     1585                        CO_UPDATEIFEXISTS);
     1586        WinCreateObject(WPProgram,
     1587                        "Visual Tree",
     1588                        s,
     1589                        FM3Tools,
     1590                        CO_UPDATEIFEXISTS);
     1591        WinCreateObject(WPProgram,
     1592                        "Visual Directory",
     1593                        s,
     1594                        FM3Tools,
     1595                        CO_UPDATEIFEXISTS);
     1596        WinCreateObject(WPProgram,
     1597                        "Global File Viewer",
     1598                        s,
     1599                        FM3Tools,
     1600                        CO_UPDATEIFEXISTS);
     1601        WinCreateObject(WPProgram,
     1602                        "Databar",
     1603                        s,
     1604                        FM3Tools,
     1605                        CO_UPDATEIFEXISTS);
    15031606      }
    15041607    }
Note: See TracChangeset for help on using the changeset viewer.