ioeric created this revision. ioeric added reviewers: ilya-biryukov, sammccall. Herald added a subscriber: cfe-commits.
This is useful when derived file systems want to override some calls and still proxy other calls. Repository: rC Clang https://reviews.llvm.org/D52462 Files: include/clang/Basic/VirtualFileSystem.h Index: include/clang/Basic/VirtualFileSystem.h =================================================================== --- include/clang/Basic/VirtualFileSystem.h +++ include/clang/Basic/VirtualFileSystem.h @@ -335,6 +335,41 @@ const_iterator overlays_end() const { return FSList.rend(); } }; +/// By default, this delegates all calls to the underlying file system. This +/// is useful when derived file systems want to override some calls and still +/// proxy other calls. +class ProxyFileSystem : public FileSystem { +public: + ProxyFileSystem(IntrusiveRefCntPtr<FileSystem> FS) : FS(std::move(FS)) {} + + virtual llvm::ErrorOr<Status> status(const Twine &Path) override { + return FS->status(Path); + } + virtual llvm::ErrorOr<std::unique_ptr<File>> + openFileForRead(const Twine &Path) override { + return FS->openFileForRead(Path); + } + virtual directory_iterator dir_begin(const Twine &Dir, + std::error_code &EC) override { + return FS->dir_begin(Dir, EC); + } + virtual llvm::ErrorOr<std::string> + getCurrentWorkingDirectory() const override { + return FS->getCurrentWorkingDirectory(); + } + virtual std::error_code + setCurrentWorkingDirectory(const Twine &Path) override { + return FS->setCurrentWorkingDirectory(Path); + } + virtual std::error_code getRealPath(const Twine &Path, + SmallVectorImpl<char> &Output) const override { + return FS->getRealPath(Path, Output); + } + +private: + IntrusiveRefCntPtr<FileSystem> FS; +}; + namespace detail { class InMemoryDirectory;
Index: include/clang/Basic/VirtualFileSystem.h =================================================================== --- include/clang/Basic/VirtualFileSystem.h +++ include/clang/Basic/VirtualFileSystem.h @@ -335,6 +335,41 @@ const_iterator overlays_end() const { return FSList.rend(); } }; +/// By default, this delegates all calls to the underlying file system. This +/// is useful when derived file systems want to override some calls and still +/// proxy other calls. +class ProxyFileSystem : public FileSystem { +public: + ProxyFileSystem(IntrusiveRefCntPtr<FileSystem> FS) : FS(std::move(FS)) {} + + virtual llvm::ErrorOr<Status> status(const Twine &Path) override { + return FS->status(Path); + } + virtual llvm::ErrorOr<std::unique_ptr<File>> + openFileForRead(const Twine &Path) override { + return FS->openFileForRead(Path); + } + virtual directory_iterator dir_begin(const Twine &Dir, + std::error_code &EC) override { + return FS->dir_begin(Dir, EC); + } + virtual llvm::ErrorOr<std::string> + getCurrentWorkingDirectory() const override { + return FS->getCurrentWorkingDirectory(); + } + virtual std::error_code + setCurrentWorkingDirectory(const Twine &Path) override { + return FS->setCurrentWorkingDirectory(Path); + } + virtual std::error_code getRealPath(const Twine &Path, + SmallVectorImpl<char> &Output) const override { + return FS->getRealPath(Path, Output); + } + +private: + IntrusiveRefCntPtr<FileSystem> FS; +}; + namespace detail { class InMemoryDirectory;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits