14#include "llvm/Support/ErrorOr.h"
15#include "llvm/Support/Path.h"
16#include "llvm/Support/VirtualFileSystem.h"
21void FileSystemStatCache::anchor() {}
33 llvm::vfs::Status &Status,
bool isFile,
34 std::unique_ptr<llvm::vfs::File> *F,
36 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;
62 IsText ? FS.openFileForRead(
Path) : FS.openFileForReadBinary(
Path);
66 RetCode = OwnedFile.getError();
71 llvm::ErrorOr<llvm::vfs::Status> StatusOrErr = (*OwnedFile)->status();
73 Status = *StatusOrErr;
74 *F = std::move(*OwnedFile);
79 RetCode = StatusOrErr.getError();
90 if (Status.isDirectory() != isForDir) {
94 return std::make_error_code(
95 Status.isDirectory() ?
96 std::errc::is_a_directory : std::errc::not_a_directory);
99 return std::error_code();
105 std::unique_ptr<llvm::vfs::File> *F,
106 llvm::vfs::FileSystem &FS) {
107 auto err =
get(
Path, Status, isFile, F,
nullptr, FS);
117 if (!Status.isDirectory() || llvm::sys::path::is_absolute(
Path))
120 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, bool IsText=true)
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.