]> granicus.if.org Git - clang/commitdiff
Add FileManager::getNoncachedStatValue, which will resolve relative paths against...
authorAnders Carlsson <andersca@mac.com>
Fri, 18 Mar 2011 19:23:19 +0000 (19:23 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 18 Mar 2011 19:23:19 +0000 (19:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127893 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/FileManager.h
lib/Basic/FileManager.cpp

index 40f6d8656368e8593946c926d2de8aac07c526ae..465f856f94630e1415de1b11bb6cc42eb5af9202 100644 (file)
@@ -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.
index 1a8b01938ede9ef3164b9532920314029bec3d8e..4e5a129082f4cea6b6c3297018bc5364c57a38c4 100644 (file)
@@ -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<const FileEntry *> &UIDToFiles) const {
   UIDToFiles.clear();