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() {}
34 llvm::vfs::Status &Status,
bool isFile,
35 std::unique_ptr<llvm::vfs::File> *F,
37 llvm::vfs::FileSystem &FS,
39 bool isForDir = !isFile;
40 std::error_code RetCode;
44 RetCode =
Cache->getStat(
Path, Status, isFile, F, FS);
45 else if (isForDir || !F) {
48 llvm::ErrorOr<llvm::vfs::Status> StatusOrErr = FS.status(
Path);
50 RetCode = StatusOrErr.getError();
52 Status = *StatusOrErr;
63 IsText ? FS.openFileForRead(
Path) : FS.openFileForReadBinary(
Path);
67 RetCode = OwnedFile.getError();
72 llvm::ErrorOr<llvm::vfs::Status> StatusOrErr = (*OwnedFile)->status();
74 Status = *StatusOrErr;
75 *F = std::move(*OwnedFile);
80 RetCode = StatusOrErr.getError();
91 if (Status.isDirectory() != isForDir) {
95 return std::make_error_code(
96 Status.isDirectory() ?
97 std::errc::is_a_directory : std::errc::not_a_directory);
100 return std::error_code();
106 std::unique_ptr<llvm::vfs::File> *F,
107 llvm::vfs::FileSystem &FS) {
108 auto err =
get(
Path, Status, isFile, F,
nullptr, FS);
118 if (!Status.isDirectory() || llvm::sys::path::is_absolute(
Path))
121 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.