Changeset 2857 in kBuild
- Timestamp:
- Sep 1, 2016 3:39:51 AM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/dir-nt-bird.c
r2856 r2857 212 212 if (pDirObj->bObjType == KFSOBJ_TYPE_DIR) 213 213 { 214 KMKNTOPENDIR *pDir = xmalloc(sizeof(*pDir)); 215 pDir->pDir = (PKFSDIR)pDirObj; 216 pDir->idxNext = 0; 217 return pDir; 218 } 214 if (kFsCacheDirEnsurePopuplated(g_pFsCache, (PKFSDIR)pDirObj, NULL)) 215 { 216 KMKNTOPENDIR *pDir = xmalloc(sizeof(*pDir)); 217 pDir->pDir = (PKFSDIR)pDirObj; 218 pDir->idxNext = 0; 219 return pDir; 220 } 221 } 222 kFsCacheObjRelease(g_pFsCache, pDirObj); 219 223 } 220 224 return NULL; … … 330 334 } 331 335 kFsCacheObjRelease(g_pFsCache, pPathObj); 332 } 333 errno = ENOENT; 336 errno = ENOENT; 337 } 338 else 339 errno = enmError == KFSLOOKUPERROR_NOT_DIR 340 || enmError == KFSLOOKUPERROR_PATH_COMP_NOT_DIR 341 ? ENOTDIR : ENOENT; 342 334 343 return -1; 335 344 } … … 438 447 } 439 448 449 450 /** 451 * Special stat call used by remake.c 452 * 453 * @returns 0 on success, -1 + errno on failure. 454 * @param pszPath The path to stat. 455 * @param pStat Where to return the mtime field only. 456 */ 457 int stat_only_mtime(const char *pszPath, struct stat *pStat) 458 { 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 473 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 -
trunk/src/kmk/read.c
r2799 r2857 532 532 void *stream_buf = NULL; 533 533 struct stat st; 534 # ifdef KBUILD_OS_WINDOWS 535 if (!birdStatOnFdJustSize(fileno(ebuf.fp), &st.st_size)) 536 # else 534 537 if (!fstat (fileno (ebuf.fp), &st)) 538 # endif 535 539 { 536 540 int stream_buf_size = 256*1024; -
trunk/src/kmk/remake.c
r2754 r2857 1794 1794 int e; 1795 1795 1796 #if defined(KMK) && defined(KBUILD_OS_WINDOWS) 1797 extern int stat_only_mtime(const char *pszPath, struct stat *pStat); 1798 e = stat_only_mtime (name, &st); 1799 #else 1796 1800 EINTRLOOP (e, stat (name, &st)); 1801 #endif 1797 1802 if (e == 0) 1798 1803 mtime = FILE_TIMESTAMP_STAT_MODTIME (name, st); -
trunk/src/lib/nt/kFsCache.c
r2856 r2857 494 494 { 495 495 if (pchDot[1] != '.') 496 pchDot = (const char *)kHlpMemChr(pchDot + 1, '.', &pszPath[cchPath] - pchDot - 1); 496 { 497 pchDot++; 498 pchDot = (const char *)kHlpMemChr(pchDot, '.', &pszPath[cchPath] - pchDot); 499 } 497 500 else 498 501 { 499 502 char ch; 500 if ( (ch = pchDot[2]) == '\0'503 if ( (ch = pchDot[2]) != '\0' 501 504 && IS_SLASH(ch)) 502 505 { … … 529 532 { 530 533 if (pwcDot[1] != '.') 531 pwcDot = wmemchr(pwcDot + 1, '.', &pwszPath[cwcPath] - pwcDot - 1); 534 { 535 pwcDot++; 536 pwcDot = wmemchr(pwcDot, '.', &pwszPath[cwcPath] - pwcDot); 537 } 532 538 else 533 539 { 534 540 wchar_t wch; 535 if ( (wch = pwcDot[2]) == '\0'541 if ( (wch = pwcDot[2]) != '\0' 536 542 && IS_SLASH(wch)) 537 543 { … … 1155 1161 *penmError = KFSLOOKUPERROR_DIR_READ_ERROR; 1156 1162 return K_TRUE; 1163 } 1164 1165 1166 /** 1167 * Does the initial directory populating or refreshes it if it has been 1168 * invalidated. 1169 * 1170 * This assumes the parent directory is opened. 1171 * 1172 * @returns K_TRUE on success, K_FALSE on error. 1173 * @param pCache The cache. 1174 * @param pDir The directory. 1175 * @param penmError Where to store K_FALSE explanation. Optional. 1176 */ 1177 KBOOL kFsCacheDirEnsurePopuplated(PKFSCACHE pCache, PKFSDIR pDir, KFSLOOKUPERROR *penmError) 1178 { 1179 KFSLOOKUPERROR enmIgnored; 1180 if ( pDir->fPopulated 1181 && ( pDir->Obj.uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 1182 || pDir->Obj.uCacheGen == pCache->uGeneration) ) 1183 return K_TRUE; 1184 return kFsCachePopuplateOrRefreshDir(pCache, pDir, penmError ? penmError : &enmIgnored); 1157 1185 } 1158 1186 -
trunk/src/lib/nt/kFsCache.h
r2856 r2857 408 408 409 409 410 KBOOL kFsCacheDirEnsurePopuplated(PKFSCACHE pCache, PKFSDIR pDir, KFSLOOKUPERROR *penmError); 410 411 KBOOL kFsCacheDirAddChild(PKFSCACHE pCache, PKFSDIR pParent, PKFSOBJ pChild, KFSLOOKUPERROR *penmError); 411 412 PKFSOBJ kFsCacheCreateObject(PKFSCACHE pCache, PKFSDIR pParent,
Note:
See TracChangeset
for help on using the changeset viewer.