Ignore:
Timestamp:
Dec 9, 2000, 5:16:27 PM (25 years ago)
Author:
phaller
Message:

Accelerated FindFirst/FindNext calls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/oslibdos.cpp

    r4763 r4771  
    1 /* $Id: oslibdos.cpp,v 1.53 2000-12-07 12:00:23 sandervl Exp $ */
     1/* $Id: oslibdos.cpp,v 1.54 2000-12-09 16:16:26 phaller Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
     
    584584BOOL pmDateTimeToFileTime(FDATE *pDate,FTIME *pTime,FILETIME *pFT)
    585585{
    586   USHORT dosTime, dosDate;
     586  register USHORT dosTime, dosDate;
    587587
    588588  dosTime = *(USHORT*)pTime;
    589589  dosDate = *(USHORT*)pDate;
    590 
     590 
     591  // PH: probably replace with faster implementation than calling Open32
     592  // through the external interface!
    591593  return DosDateTimeToFileTime(dosDate,dosTime,pFT);
    592594}
     
    616618
    617619  //CB: not used: FILE_ATTRIBUTE_COMPRESSED_W
     620  //PH: NT server will serve appropriate sizes for compressed files
     621  //    over network. So if realSize < allocatedSize, the file must
     622  //    be compressed.
    618623
    619624  return res;
     
    16791684}
    16801685
    1681 VOID long2ShortName(CHAR* longName,CHAR* shortName)
    1682 {
     1686VOID long2ShortName(CHAR* longName, CHAR* shortName)
     1687{
     1688  // check for uplink / root: "." and ".."
     1689  if (longName[0] == '.')
     1690  {
     1691    // if ((strcmp(longName,".") == 0) || (strcmp(longName,"..") == 0))
     1692    if (longName[1] == 0) // "."
     1693    {
     1694      shortName[0] = '.';
     1695      shortName[1] = 0;
     1696      return;
     1697    }
     1698   
     1699    if (longName[1] == '.' && longName[2] == 0) // ".."
     1700    {
     1701      shortName[0] = '.';
     1702      shortName[1] = '.';
     1703      shortName[2] = 0;
     1704      return;
     1705    }
     1706  }
     1707  else
     1708    // check for empty name
     1709    if(longName[0] == 0)
     1710    {
     1711      shortName[0] = 0;
     1712      return;
     1713    }
     1714 
    16831715  INT x;
    1684   CHAR *source = longName,*dest = shortName,*ext = strrchr(longName,'.');
    1685 
    1686   if ((strcmp(longName,".") == 0) || (strcmp(longName,"..") == 0))
    1687   {
    1688     strcpy(shortName,longName);
    1689     return;
    1690   }
    1691 
     1716  CHAR *source = longName;
     1717
     1718  // Test if longName is 8:3 compliant and simply copy
     1719  // the filename.
     1720  BOOL flag83 = TRUE;
     1721 
     1722  // verify forbidden characters
     1723  for (x = 0;
     1724       (x < 8) &&
     1725       (flag83 == TRUE);
     1726       x++)
     1727  {
     1728    switch (*source++)
     1729    {
     1730      case '.': // a period will cause the loop to abort!
     1731        x=1000;
     1732        break;
     1733     
     1734      case '/':      case '?':
     1735      case '*':      case ':':
     1736      case '\\':     case '"':
     1737      case ' ':
     1738        flag83 = FALSE;
     1739        break;
     1740    }
     1741  }
     1742 
     1743  // verify we're on a period now
     1744  if (flag83 == TRUE)
     1745    if (*source != '.')
     1746      flag83 = FALSE;
     1747 
     1748  // verify extension
     1749  if (flag83 == TRUE)
     1750    for (INT y = 0;
     1751         (y < 3) && (flag83 == TRUE);
     1752         y++)
     1753    {
     1754      switch (*source)
     1755      {
     1756        case '/':      case '?':
     1757        case '*':      case ':':
     1758        case '\\':     case '"':
     1759        case ' ':      case '.':
     1760          flag83 = FALSE;
     1761          break;
     1762      }
     1763    }
     1764 
     1765  // verify we're at the end of the string now
     1766  if (flag83 == TRUE)
     1767    if (*source != 0)
     1768      flag83 = FALSE;
     1769 
     1770  // OK, done
     1771  if (flag83 == TRUE)
     1772  {
     1773    // we might not alter any character here, since
     1774    // an app opening a specific file with an 8:3 "alias",
     1775    // would surely fail.
     1776    strcpy(longName,
     1777           shortName);
     1778   
     1779    return; // Done
     1780  }
     1781 
     1782 
     1783  // @@@PH
     1784  shortName[0] = 0; // this function is disabled anyway ...
     1785  return;
     1786 
     1787  CHAR *dest = shortName;
     1788  CHAR *ext = strrchr(longName,'.');
     1789 
    16921790  //CB: quick and dirty, real FILE~12.EXT is too slow
     1791  //PH: We'd have to count the number of non-8:3-compliant files
     1792  //    within a directory. Or simpler: the number of files within
     1793  //    the current directory.
    16931794
    16941795  //8 character file name
     
    17491850    name++;
    17501851    strcpy(pFind->cFileName,name);
    1751   } else pFind->cFileName[0] = 0;
     1852  }
     1853  else
     1854    pFind->cFileName[0] = 0;
     1855 
    17521856  long2ShortName(pFind->cFileName,pFind->cAlternateFileName);
    17531857}
     
    17801884  DosError(FERR_DISABLEHARDERR | FERR_DISABLEEXCEPTION);
    17811885  APIRET rc = DosFindFirst((PSZ)lpFileName,&hDir,attrs,&result,sizeof(result),&searchCount,FIL_STANDARD);
    1782   DosError(FERR_ENABLEHARDERR | FERR_ENABLEEXCEPTION);
     1886  //PH: DosError(FERR_ENABLEHARDERR | FERR_ENABLEEXCEPTION);
    17831887
    17841888  //check root: skip "." and ".." (HPFS, not on FAT)
     
    17861890  if ((rc == 0) && isRoot((LPSTR)lpFileName))
    17871891  {
    1788     while ((strcmp(result.achName,".") == 0) || (strcmp(result.achName,"..") == 0))
     1892    while ((strcmp(result.achName,".") == 0) ||
     1893           (strcmp(result.achName,"..") == 0))
    17891894    {
    17901895      result.achName[0] = 0;
    1791       DosError(FERR_DISABLEHARDERR | FERR_DISABLEEXCEPTION);
     1896      //PH: DosError(FERR_DISABLEHARDERR | FERR_DISABLEEXCEPTION);
    17921897      searchCount = 1;
    17931898      APIRET rc = DosFindNext(hDir,&result,sizeof(result),&searchCount);
    1794       DosError(FERR_ENABLEHARDERR | FERR_ENABLEEXCEPTION);
     1899      //PH: DosError(FERR_ENABLEHARDERR | FERR_ENABLEEXCEPTION);
    17951900      if (rc)
    17961901      {
     
    17981903        SetLastError(error2WinError(rc));
    17991904
     1905        DosError(FERR_ENABLEHARDERR | FERR_ENABLEEXCEPTION);
    18001906        return INVALID_HANDLE_VALUE_W;
    18011907      }
    18021908    }
    18031909  }
    1804   if(rc) {
    1805         DosFindClose(hDir);
    1806         SetLastError(error2WinError(rc));
    1807         return INVALID_HANDLE_VALUE_W;
     1910
     1911  // enable i/o kernel exceptions again
     1912  DosError(FERR_ENABLEHARDERR | FERR_ENABLEEXCEPTION);
     1913
     1914  if(rc)
     1915  {
     1916    DosFindClose(hDir);
     1917    SetLastError(error2WinError(rc));
     1918    return INVALID_HANDLE_VALUE_W;
    18081919  }
    18091920  translateFindResults(&result,lpFindFileData);
Note: See TracChangeset for help on using the changeset viewer.