Ignore:
Timestamp:
Sep 2, 2016, 12:42:55 AM (9 years ago)
Author:
bird
Message:

Updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/dir-nt-bird.c

    r2857 r2861  
    235235{
    236236    KMKNTOPENDIR *pDir = (KMKNTOPENDIR *)pvDir;
    237     while (pDir->idxNext < pDir->pDir->cChildren)
     237    KU32 const    cChildren = pDir->pDir->cChildren;
     238    while (pDir->idxNext < cChildren)
    238239    {
    239240        PKFSOBJ pEntry = pDir->pDir->papChildren[pDir->idxNext++];
     
    267268        }
    268269    }
     270
     271    /*
     272     * Fake the '.' and '..' directories because they're not part of papChildren above.
     273     */
     274    if (pDir->idxNext < cChildren + 2)
     275    {
     276        pDir->idxNext++;
     277        pDir->DirEnt.d_type    = DT_DIR;
     278        pDir->DirEnt.d_namlen  = pDir->idxNext - cChildren;
     279        pDir->DirEnt.d_reclen  = offsetof(struct dirent, d_name) + pDir->DirEnt.d_namlen;
     280        pDir->DirEnt.d_name[0] = '.';
     281        pDir->DirEnt.d_name[1] = '.';
     282        pDir->DirEnt.d_name[pDir->DirEnt.d_namlen] = '\0';
     283        return &pDir->DirEnt;
     284    }
     285
    269286    return NULL;
    270287}
     
    457474int stat_only_mtime(const char *pszPath, struct stat *pStat)
    458475{
    459     if (commands_started == 0)
    460     {
    461         KFSLOOKUPERROR  enmError;
    462         PKFSOBJ         pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError);
    463         if (pPathObj)
    464         {
    465             if (pPathObj->bObjType != KFSOBJ_TYPE_MISSING)
    466             {
    467                 kHlpAssert(pPathObj->fHaveStats); /* currently always true. */
    468                 pStat->st_mtime = pPathObj->Stats.st_mtime;
    469                 kFsCacheObjRelease(g_pFsCache, pPathObj);
    470                 return 0;
    471             }
    472 
     476    KFSLOOKUPERROR  enmError;
     477    PKFSOBJ         pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError);
     478    if (pPathObj)
     479    {
     480        if (pPathObj->bObjType != KFSOBJ_TYPE_MISSING)
     481        {
     482            kHlpAssert(pPathObj->fHaveStats); /* currently always true. */
     483            pStat->st_mtime = pPathObj->Stats.st_mtime;
    473484            kFsCacheObjRelease(g_pFsCache, pPathObj);
    474             errno = ENOENT;
    475         }
    476         else
    477             errno =    enmError == KFSLOOKUPERROR_NOT_DIR
    478                     || enmError == KFSLOOKUPERROR_PATH_COMP_NOT_DIR
    479                   ? ENOTDIR : ENOENT;
    480         return -1;
    481     }
    482     /** @todo implement cache refreshing.   */
    483     return birdStatFollowLink(pszPath, pStat);
    484 }
    485 
     485            return 0;
     486        }
     487
     488        kFsCacheObjRelease(g_pFsCache, pPathObj);
     489        errno = ENOENT;
     490    }
     491    else
     492        errno =    enmError == KFSLOOKUPERROR_NOT_DIR
     493                || enmError == KFSLOOKUPERROR_PATH_COMP_NOT_DIR
     494              ? ENOTDIR : ENOENT;
     495    return -1;
     496}
     497
     498
     499/**
     500 * Invalidate missing bits of the directory cache.
     501 *
     502 * This is called each time a make job completes.
     503 */
     504void dir_cache_invalid_missing(void)
     505{
     506    kFsCacheInvalidateMissing(g_pFsCache);
     507}
     508
Note: See TracChangeset for help on using the changeset viewer.