14#include "llvm/Support/Chrono.h"
15#include "llvm/Support/ErrorOr.h"
16#include "llvm/Support/Path.h"
17#include "llvm/Support/VirtualFileSystem.h"
22void FileSystemStatCache::anchor() {}
35 bool isFile, std::unique_ptr<llvm::vfs::File> *F,
37 llvm::vfs::FileSystem &FS) {
38 bool isForDir = !isFile;
39 std::error_code RetCode;
43 RetCode =
Cache->getStat(
Path, Status, isFile, F, FS);
44 else if (isForDir || !F) {
47 llvm::ErrorOr<llvm::vfs::Status> StatusOrErr = FS.status(
Path);
49 RetCode = StatusOrErr.getError();
51 Status = *StatusOrErr;
61 auto OwnedFile = FS.openFileForRead(
Path);
65 RetCode = OwnedFile.getError();
70 llvm::ErrorOr<llvm::vfs::Status> StatusOrErr = (*OwnedFile)->status();
72 Status = *StatusOrErr;
73 *F = std::move(*OwnedFile);
78 RetCode = StatusOrErr.getError();
89 if (Status.isDirectory() != isForDir) {
93 return std::make_error_code(
94 Status.isDirectory() ?
95 std::errc::is_a_directory : std::errc::not_a_directory);
98 return std::error_code();
104 std::unique_ptr<llvm::vfs::File> *F,
105 llvm::vfs::FileSystem &FS) {
106 auto err =
get(
Path, Status, isFile, F,
nullptr, FS);
116 if (!Status.isDirectory() || llvm::sys::path::is_absolute(
Path))
119 return std::error_code();
Defines the FileSystemStatCache interface.
Abstract interface for introducing a FileManager cache for 'stat' system calls, which is used by prec...
static std::error_code get(StringRef Path, llvm::vfs::Status &Status, bool isFile, std::unique_ptr< llvm::vfs::File > *F, FileSystemStatCache *Cache, llvm::vfs::FileSystem &FS)
Get the 'stat' information for the specified path, using the cache to accelerate it if possible.
llvm::StringMap< llvm::vfs::Status, llvm::BumpPtrAllocator > StatCalls
The set of stat() calls that have been seen.
std::error_code getStat(StringRef Path, llvm::vfs::Status &Status, bool isFile, std::unique_ptr< llvm::vfs::File > *F, llvm::vfs::FileSystem &FS) override
The JSON file list parser is used to communicate input to InstallAPI.