summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2014-02-19 03:29:17 +0000
committerBen Langmuir <blangmuir@apple.com>2014-02-19 03:29:17 +0000
commit87ba87bc4d200f64bbf56673f3a6f01c13943d1f (patch)
treeb485bd5c88b06c1d4ca4de3cc4cfcdb2f2c2348b /clang/lib
parent141a7b5402f54952994e265cedcc4e8ceeaba328 (diff)
downloadbcm5719-llvm-87ba87bc4d200f64bbf56673f3a6f01c13943d1f.tar.gz
bcm5719-llvm-87ba87bc4d200f64bbf56673f3a6f01c13943d1f.zip
Add an OverlayFileSystem class
Provides a way to merge multiple vfs::FileSystem objects into a single filesystem. llvm-svn: 201635
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/VirtualFileSystem.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp
index 0345ed153e3..7afdac864b9 100644
--- a/clang/lib/Basic/VirtualFileSystem.cpp
+++ b/clang/lib/Basic/VirtualFileSystem.cpp
@@ -160,3 +160,36 @@ IntrusiveRefCntPtr<FileSystem> vfs::getRealFileSystem() {
static IntrusiveRefCntPtr<FileSystem> FS = new RealFileSystem();
return FS;
}
+
+//===-----------------------------------------------------------------------===/
+// OverlayFileSystem implementation
+//===-----------------------------------------------------------------------===/
+OverlayFileSystem::OverlayFileSystem(
+ IntrusiveRefCntPtr<FileSystem> BaseFS) {
+ pushOverlay(BaseFS);
+}
+
+void OverlayFileSystem::pushOverlay(IntrusiveRefCntPtr<FileSystem> FS) {
+ FSList.push_back(FS);
+}
+
+ErrorOr<Status> OverlayFileSystem::status(const Twine &Path) {
+ // FIXME: handle symlinks that cross file systems
+ for (iterator I = overlays_begin(), E = overlays_end(); I != E; ++I) {
+ ErrorOr<Status> Status = (*I)->status(Path);
+ if (Status || Status.getError() != errc::no_such_file_or_directory)
+ return Status;
+ }
+ return error_code(errc::no_such_file_or_directory, system_category());
+}
+
+error_code OverlayFileSystem::openFileForRead(const llvm::Twine &Path,
+ OwningPtr<File> &Result) {
+ // FIXME: handle symlinks that cross file systems
+ for (iterator I = overlays_begin(), E = overlays_end(); I != E; ++I) {
+ error_code EC = (*I)->openFileForRead(Path, Result);
+ if (!EC || EC != errc::no_such_file_or_directory)
+ return EC;
+ }
+ return error_code(errc::no_such_file_or_directory, system_category());
+}
OpenPOWER on IntegriCloud