[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
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user