@@ -20,6 +20,35 @@ namespace llvm {
20
20
class FileCollectorFileSystem ;
21
21
class Twine ;
22
22
23
+ class FileCollectorBase {
24
+ public:
25
+ FileCollectorBase ();
26
+ virtual ~FileCollectorBase ();
27
+
28
+ void addFile (const Twine &file);
29
+ void addDirectory (const Twine &Dir);
30
+
31
+ protected:
32
+ bool markAsSeen (StringRef Path) {
33
+ if (Path.empty ())
34
+ return false ;
35
+ return Seen.insert (Path).second ;
36
+ }
37
+
38
+ virtual void addFileImpl (StringRef SrcPath) = 0;
39
+
40
+ virtual llvm::vfs::directory_iterator
41
+ addDirectoryImpl (const llvm::Twine &Dir,
42
+ IntrusiveRefCntPtr<vfs::FileSystem> FS,
43
+ std::error_code &EC) = 0 ;
44
+
45
+ // / Synchronizes access to internal data structures.
46
+ std::mutex Mutex;
47
+
48
+ // / Tracks already seen files so they can be skipped.
49
+ StringSet<> Seen;
50
+ };
51
+
23
52
// / Captures file system interaction and generates data to be later replayed
24
53
// / with the RedirectingFileSystem.
25
54
// /
@@ -38,16 +67,13 @@ class Twine;
38
67
// /
39
68
// / In order to preserve the relative topology of files we use their real paths
40
69
// / as relative paths inside of the Root.
41
- class FileCollector {
70
+ class FileCollector : public FileCollectorBase {
42
71
public:
43
72
// / \p Root is the directory where collected files are will be stored.
44
73
// / \p OverlayRoot is VFS mapping root.
45
74
// / \p Root directory gets created in copyFiles unless it already exists.
46
75
FileCollector (std::string Root, std::string OverlayRoot);
47
76
48
- void addFile (const Twine &file);
49
- void addDirectory (const Twine &Dir);
50
-
51
77
// / Write the yaml mapping (for the VFS) to the given file.
52
78
std::error_code writeMapping (StringRef MappingFile);
53
79
@@ -67,12 +93,6 @@ class FileCollector {
67
93
private:
68
94
friend FileCollectorFileSystem;
69
95
70
- bool markAsSeen (StringRef Path) {
71
- if (Path.empty ())
72
- return false ;
73
- return Seen.insert (Path).second ;
74
- }
75
-
76
96
bool getRealPath (StringRef SrcPath, SmallVectorImpl<char > &Result);
77
97
78
98
void addFileToMapping (StringRef VirtualPath, StringRef RealPath) {
@@ -83,24 +103,19 @@ class FileCollector {
83
103
}
84
104
85
105
protected:
86
- void addFileImpl (StringRef SrcPath);
106
+ void addFileImpl (StringRef SrcPath) override ;
87
107
88
108
llvm::vfs::directory_iterator
89
109
addDirectoryImpl (const llvm::Twine &Dir,
90
- IntrusiveRefCntPtr<vfs::FileSystem> FS, std::error_code &EC);
91
-
92
- // / Synchronizes access to Seen, VFSWriter and SymlinkMap.
93
- std::mutex Mutex;
110
+ IntrusiveRefCntPtr<vfs::FileSystem> FS,
111
+ std::error_code &EC) override ;
94
112
95
113
// / The directory where collected files are copied to in copyFiles().
96
114
const std::string Root;
97
115
98
116
// / The root directory where the VFS overlay lives.
99
117
const std::string OverlayRoot;
100
118
101
- // / Tracks already seen files so they can be skipped.
102
- StringSet<> Seen;
103
-
104
119
// / The yaml mapping writer.
105
120
vfs::YAMLVFSWriter VFSWriter;
106
121
0 commit comments