diff options
| author | Nathan Hawes <nhawes@apple.com> | 2021-01-15 17:33:52 +1000 |
|---|---|---|
| committer | Nathan Hawes <nhawes@apple.com> | 2021-02-02 14:56:17 +1000 |
| commit | ecb00a77624c94ce38fccf9b4095e026ecf14aed (patch) | |
| tree | f7340754decba9d921fee8f7e0993b8dd7afdcd3 /lldb/source/Host/common/FileSystem.cpp | |
| parent | b167303b772d1d07fb831b2110cd26d541138bf7 (diff) | |
[VFS] Add support to RedirectingFileSystem for mapping a virtual directory to one in the external FS.
Previously file entries in the -ivfsoverlay yaml could map to a file in the
external file system, but directories had to list their contents in the form of
other file entries or directories. Allowing directory entries to map to a
directory in the external file system makes it possible to present an external
directory's contents in a different location and (in combination with the
'fallthrough' option) overlay one directory's contents on top of another.
rdar://problem/72485443
Differential Revision: https://reviews.llvm.org/D94844
Diffstat (limited to 'lldb/source/Host/common/FileSystem.cpp')
| -rw-r--r-- | lldb/source/Host/common/FileSystem.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp index a89020100ca7..64ecf27858ab 100644 --- a/lldb/source/Host/common/FileSystem.cpp +++ b/lldb/source/Host/common/FileSystem.cpp @@ -478,20 +478,18 @@ ErrorOr<std::string> FileSystem::GetExternalPath(const llvm::Twine &path) { return path.str(); // If VFS mapped we know the underlying FS is a RedirectingFileSystem. - ErrorOr<vfs::RedirectingFileSystem::Entry *> E = + ErrorOr<vfs::RedirectingFileSystem::LookupResult> Result = static_cast<vfs::RedirectingFileSystem &>(*m_fs).lookupPath(path.str()); - if (!E) { - if (E.getError() == llvm::errc::no_such_file_or_directory) { + if (!Result) { + if (Result.getError() == llvm::errc::no_such_file_or_directory) { return path.str(); } - return E.getError(); + return Result.getError(); } - auto *F = dyn_cast<vfs::RedirectingFileSystem::FileEntry>(*E); - if (!F) - return make_error_code(llvm::errc::not_supported); - - return F->getExternalContentsPath().str(); + if (Optional<StringRef> ExtRedirect = Result->getExternalRedirect()) + return std::string(*ExtRedirect); + return make_error_code(llvm::errc::not_supported); } ErrorOr<std::string> FileSystem::GetExternalPath(const FileSpec &file_spec) { |
