diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-11-08 00:01:32 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-11-08 00:01:32 +0000 |
commit | cbb5c86837d419b7be6d0b840c92c4209b757428 (patch) | |
tree | a00e39ccb8363abd2fb64b556be9199e6f3aea38 /llvm/lib/Support/VirtualFileSystem.cpp | |
parent | 4f36c7ad90f2d4322156455528a1e27e55c13b30 (diff) | |
download | llvm-cbb5c86837d419b7be6d0b840c92c4209b757428.zip llvm-cbb5c86837d419b7be6d0b840c92c4209b757428.tar.gz llvm-cbb5c86837d419b7be6d0b840c92c4209b757428.tar.bz2 |
Extend virtual file system with `isLocal` method
Expose the `llvm::sys::fs::is_local` function through the VFS.
Differential revision: https://reviews.llvm.org/D54127
llvm-svn: 346372
Diffstat (limited to 'llvm/lib/Support/VirtualFileSystem.cpp')
-rw-r--r-- | llvm/lib/Support/VirtualFileSystem.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index 9440eac..e8b0435 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -136,6 +136,10 @@ std::error_code FileSystem::getRealPath(const Twine &Path, return errc::operation_not_permitted; } +std::error_code FileSystem::isLocal(const Twine &Path, bool &Result) { + return errc::operation_not_permitted; +} + bool FileSystem::exists(const Twine &Path) { auto Status = status(Path); return Status && Status->exists(); @@ -233,6 +237,7 @@ public: llvm::ErrorOr<std::string> getCurrentWorkingDirectory() const override; std::error_code setCurrentWorkingDirectory(const Twine &Path) override; + std::error_code isLocal(const Twine &Path, bool &Result) override; std::error_code getRealPath(const Twine &Path, SmallVectorImpl<char> &Output) const override; @@ -288,6 +293,10 @@ std::error_code RealFileSystem::setCurrentWorkingDirectory(const Twine &Path) { return std::error_code(); } +std::error_code RealFileSystem::isLocal(const Twine &Path, bool &Result) { + return llvm::sys::fs::is_local(Path, Result); +} + std::error_code RealFileSystem::getRealPath(const Twine &Path, SmallVectorImpl<char> &Output) const { @@ -377,6 +386,13 @@ OverlayFileSystem::setCurrentWorkingDirectory(const Twine &Path) { return {}; } +std::error_code OverlayFileSystem::isLocal(const Twine &Path, bool &Result) { + for (auto &FS : FSList) + if (FS->exists(Path)) + return FS->isLocal(Path, Result); + return errc::no_such_file_or_directory; +} + std::error_code OverlayFileSystem::getRealPath(const Twine &Path, SmallVectorImpl<char> &Output) const { @@ -913,6 +929,11 @@ InMemoryFileSystem::getRealPath(const Twine &Path, return {}; } +std::error_code InMemoryFileSystem::isLocal(const Twine &Path, bool &Result) { + Result = false; + return {}; +} + } // namespace vfs } // namespace llvm @@ -1170,6 +1191,10 @@ public: return ExternalFS->setCurrentWorkingDirectory(Path); } + std::error_code isLocal(const Twine &Path, bool &Result) override { + return ExternalFS->isLocal(Path, Result); + } + directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override { ErrorOr<Entry *> E = lookupPath(Dir); if (!E) { |