@@ -549,7 +549,10 @@ class RedirectingFileSystemParser;
549
549
// / 'case-sensitive': <boolean, default=(true for Posix, false for Windows)>
550
550
// / 'use-external-names': <boolean, default=true>
551
551
// / 'overlay-relative': <boolean, default=false>
552
- // / 'fallthrough': <boolean, default=true>
552
+ // / 'fallthrough': <boolean, default=true, deprecated - use 'redirecting-with'
553
+ // / instead>
554
+ // / 'redirecting-with': <string, one of 'fallthrough', 'fallback', or
555
+ // / 'redirect-only', default='fallthrough'>
553
556
// /
554
557
// / Virtual directories that list their contents are represented as
555
558
// / \verbatim
@@ -620,6 +623,20 @@ class RedirectingFileSystem : public vfs::FileSystem {
620
623
enum EntryKind { EK_Directory, EK_DirectoryRemap, EK_File };
621
624
enum NameKind { NK_NotSet, NK_External, NK_Virtual };
622
625
626
+ // / The type of redirection to perform.
627
+ enum class RedirectKind {
628
+ // / Lookup the redirected path first (ie. the one specified in
629
+ // / 'external-contents') and if that fails "fallthrough" to a lookup of the
630
+ // / originally provided path.
631
+ Fallthrough,
632
+ // / Lookup the provided path first and if that fails, "fallback" to a
633
+ // / lookup of the redirected path.
634
+ Fallback,
635
+ // / Only lookup the redirected path, do not lookup the originally provided
636
+ // / path.
637
+ RedirectOnly
638
+ };
639
+
623
640
// / A single file or directory in the VFS.
624
641
class Entry {
625
642
EntryKind Kind;
@@ -754,17 +771,11 @@ class RedirectingFileSystem : public vfs::FileSystem {
754
771
friend class RedirectingFSDirIterImpl ;
755
772
friend class RedirectingFileSystemParser ;
756
773
757
- bool shouldUseExternalFS () const { return IsFallthrough; }
758
-
759
774
// / Canonicalize path by removing ".", "..", "./", components. This is
760
775
// / a VFS request, do not bother about symlinks in the path components
761
776
// / but canonicalize in order to perform the correct entry search.
762
777
std::error_code makeCanonical (SmallVectorImpl<char > &Path) const ;
763
778
764
- // / Whether to fall back to the external file system when an operation fails
765
- // / with the given error code on a path associated with the provided Entry.
766
- bool shouldFallBackToExternalFS (std::error_code EC, Entry *E = nullptr ) const ;
767
-
768
779
// / Get the File status, or error, from the underlying external file system.
769
780
// / This returns the status with the originally requested name, while looking
770
781
// / up the entry using the canonical path.
@@ -817,9 +828,9 @@ class RedirectingFileSystem : public vfs::FileSystem {
817
828
// / names of files. This global value is overridable on a per-file basis.
818
829
bool UseExternalNames = true ;
819
830
820
- // / Whether to attempt a file lookup in external file system after it wasn't
821
- // / found in VFS .
822
- bool IsFallthrough = true ;
831
+ // / Determines the lookups to perform, as well as their order. See
832
+ // / \c RedirectKind for details .
833
+ RedirectKind Redirection = RedirectKind::Fallthrough ;
823
834
// / @}
824
835
825
836
RedirectingFileSystem (IntrusiveRefCntPtr<FileSystem> ExternalFS);
@@ -874,8 +885,12 @@ class RedirectingFileSystem : public vfs::FileSystem {
874
885
875
886
StringRef getExternalContentsPrefixDir () const ;
876
887
888
+ // / Sets the redirection kind to \c Fallthrough if true or \c RedirectOnly
889
+ // / otherwise. Will removed in the future, use \c setRedirection instead.
877
890
void setFallthrough (bool Fallthrough);
878
891
892
+ void setRedirection (RedirectingFileSystem::RedirectKind Kind);
893
+
879
894
std::vector<llvm::StringRef> getRoots () const ;
880
895
881
896
void dump (raw_ostream &OS) const ;
0 commit comments