From 7dbafb3ade491a41100c97597209455ee10c537d Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Fri, 18 Mar 2011 19:23:19 +0000 Subject: [PATCH] Add FileManager::getNoncachedStatValue, which will resolve relative paths against the working directory specified in the file system options. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127893 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/FileManager.h | 5 +++++ lib/Basic/FileManager.cpp | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index 40f6d86563..465f856f94 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -195,6 +195,11 @@ public: llvm::MemoryBuffer *getBufferForFile(llvm::StringRef Filename, std::string *ErrorStr = 0); + // getNoncachedStatValue - Will get the 'stat' information for the given path. + // If the path is relative, it will be resolved against the WorkingDir of the + // FileManager's FileSystemOptions. + bool getNoncachedStatValue(llvm::StringRef Path, struct stat &StatBuf); + /// \brief If path is not absolute and FileSystemOptions set the working /// directory, the path is modified to be relative to the given /// working directory. diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp index 1a8b01938e..4e5a129082 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -541,6 +541,14 @@ bool FileManager::getStatValue(const char *Path, struct stat &StatBuf, StatCache.get()); } +bool FileManager::getNoncachedStatValue(llvm::StringRef Path, + struct stat &StatBuf) { + llvm::SmallString<128> FilePath(Path); + FixupRelativePath(FilePath); + + return ::stat(FilePath.c_str(), &StatBuf) != 0; +} + void FileManager::GetUniqueIDMapping( llvm::SmallVectorImpl &UIDToFiles) const { UIDToFiles.clear(); -- 2.40.0