aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/FileSystemStatCache.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-23 21:17:56 +0000
committerChris Lattner <sabre@nondot.org>2010-11-23 21:17:56 +0000
commit898a061f69e1145bf89a987c08203132b9922a3c (patch)
treebde19ba5ef8b70e02451772ced8e6d09920ee4e0 /include/clang/Basic/FileSystemStatCache.h
parentf9f7766846a205bc900b578f944567e679b221aa (diff)
change the 'is directory' indicator to be a null-or-not
pointer that is passed down through the APIs, and make FileSystemStatCache::get be the one that filters out directory lookups that hit files. This also paves the way to have stat queries be able to return opened files. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120060 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/FileSystemStatCache.h')
-rw-r--r--include/clang/Basic/FileSystemStatCache.h29
1 files changed, 17 insertions, 12 deletions
diff --git a/include/clang/Basic/FileSystemStatCache.h b/include/clang/Basic/FileSystemStatCache.h
index e9da8cf15c..77828b3ecb 100644
--- a/include/clang/Basic/FileSystemStatCache.h
+++ b/include/clang/Basic/FileSystemStatCache.h
@@ -39,13 +39,15 @@ public:
/// FileSystemStatCache::get - Get the 'stat' information for the specified
/// path, using the cache to accellerate it if possible. This returns true if
/// the path does not exist or false if it exists.
- static bool get(const char *Path, struct stat &StatBuf,
- FileSystemStatCache *Cache) {
- if (Cache)
- return Cache->getStat(Path, StatBuf) == CacheMissing;
-
- return ::stat(Path, &StatBuf) != 0;
- }
+ ///
+ /// If FileDescriptor is non-null, then this lookup should only return success
+ /// for files (not directories). If it is null this lookup should only return
+ /// success for directories (not files). On a successful file lookup, the
+ /// implementation can optionally fill in FileDescriptor with a valid
+ /// descriptor and the client guarantees that it will close it.
+ static bool get(const char *Path, struct stat &StatBuf, int *FileDescriptor,
+ FileSystemStatCache *Cache);
+
/// \brief Sets the next stat call cache in the chain of stat caches.
/// Takes ownership of the given stat cache.
@@ -62,15 +64,17 @@ public:
FileSystemStatCache *takeNextStatCache() { return NextStatCache.take(); }
protected:
- virtual LookupResult getStat(const char *Path, struct stat &StatBuf) = 0;
+ virtual LookupResult getStat(const char *Path, struct stat &StatBuf,
+ int *FileDescriptor) = 0;
- LookupResult statChained(const char *Path, struct stat &StatBuf) {
+ LookupResult statChained(const char *Path, struct stat &StatBuf,
+ int *FileDescriptor) {
if (FileSystemStatCache *Next = getNextStatCache())
- return Next->getStat(Path, StatBuf);
+ return Next->getStat(Path, StatBuf, FileDescriptor);
// If we hit the end of the list of stat caches to try, just compute and
// return it without a cache.
- return get(Path, StatBuf, 0) ? CacheMissing : CacheExists;
+ return get(Path, StatBuf, FileDescriptor, 0) ? CacheMissing : CacheExists;
}
};
@@ -88,7 +92,8 @@ public:
iterator begin() const { return StatCalls.begin(); }
iterator end() const { return StatCalls.end(); }
- virtual LookupResult getStat(const char *Path, struct stat &StatBuf);
+ virtual LookupResult getStat(const char *Path, struct stat &StatBuf,
+ int *FileDescriptor);
};
} // end namespace clang