Ignore:
Timestamp:
Nov 21, 2013, 11:26:40 AM (12 years ago)
Author:
bird
Message:

Optimized ftsfake.c for windows (similar things can be done for OS/2, if we care).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/nt/ntdir.c

    r2702 r2708  
    9292
    9393
     94/**
     95 * Alternative opendir, with extra stat() info returned by readdir().
     96 */
     97BirdDir_T *birdDirOpenExtraInfo(const char *pszPath)
     98{
     99    return birdDirOpenInternal(pszPath, NULL, 0 /*fMinimalInfo*/);
     100}
     101
     102
    94103static int birdDirReadMore(BirdDir_T *pDir)
    95104{
     
    229238                {
    230239                    fSkipEntry = 1;
     240                    pDir->fHaveData = 0;
    231241                    continue;
    232242                }
    233243
    234                 pEntry->d_ino           = 0;
    235                 pEntry->d_size          = 0;
     244                memset(&pEntry->d_stat, 0, sizeof(pEntry->d_stat));
     245                pEntry->d_stat.st_mode  = S_IFMT;
    236246                pEntry->d_type          = DT_UNKNOWN;
    237                 pEntry->d_dirsymlink    = 0;
    238247                pEntry->d_reclen        = 0;
    239248                pEntry->d_namlen        = 0;
     
    246255            }
    247256
    248             //case MyFileIdBothDirectoryInformation:
    249             //{
    250             //    MY_FILE_BOTH_DIR_INFORMATION
    251             //
    252             //}
     257            case MyFileIdFullDirectoryInformation:
     258            {
     259                MY_FILE_ID_FULL_DIR_INFORMATION *pInfo = (MY_FILE_ID_FULL_DIR_INFORMATION *)&pDir->pabBuf[pDir->offBuf];
     260                if (   pDir->offBuf          >= pDir->cbBuf - MIN_SIZEOF_MY_FILE_ID_FULL_DIR_INFORMATION
     261                    || pInfo->FileNameLength >= pDir->cbBuf
     262                    || pDir->offBuf + pInfo->FileNameLength + MIN_SIZEOF_MY_FILE_ID_FULL_DIR_INFORMATION > pDir->cbBuf)
     263                {
     264                    fSkipEntry = 1;
     265                    pDir->fHaveData = 0;
     266                    continue;
     267                }
     268
     269                pEntry->d_type          = DT_UNKNOWN;
     270                pEntry->d_reclen        = 0;
     271                pEntry->d_namlen        = 0;
     272                if (birdDirCopyNameToEntry(pInfo->FileName, pInfo->FileNameLength, pEntry) != 0)
     273                    fSkipEntry = 1;
     274                birdStatFillFromFileIdFullDirInfo(&pEntry->d_stat, pInfo, pEntry->d_name);
     275                pEntry->d_stat.st_dev   = pDir->uDev;
     276                switch (pEntry->d_stat.st_mode & S_IFMT)
     277                {
     278                    case S_IFREG:       pEntry->d_type = DT_REG; break;
     279                    case S_IFDIR:       pEntry->d_type = DT_DIR; break;
     280                    case S_IFLNK:       pEntry->d_type = DT_LNK; break;
     281                    case S_IFIFO:       pEntry->d_type = DT_FIFO; break;
     282                    case S_IFCHR:       pEntry->d_type = DT_CHR; break;
     283                    default:
     284#ifndef NDEBUG
     285                        __debugbreak();
     286#endif
     287                        pEntry->d_type = DT_UNKNOWN;
     288                        break;
     289                }
     290
     291                cbMinCur = MIN_SIZEOF_MY_FILE_ID_FULL_DIR_INFORMATION + pInfo->FileNameLength;
     292                offNext  = pInfo->NextEntryOffset;
     293                break;
     294            }
    253295
    254296            default:
Note: See TracChangeset for help on using the changeset viewer.