class FileCollector
Declaration
class FileCollector : public FileCollectorBase { /* full declaration omitted */ };
Description
Captures file system interaction and generates data to be later replayed with the RedirectingFileSystem. For any file that gets accessed we eventually create: - a copy of the file inside Root - a record in RedirectingFileSystem mapping that maps: current real path -> path to the copy in Root That intent is that later when the mapping is used by RedirectingFileSystem it simulates the state of FS that we collected. We generate file copies and mapping lazily - see writeMapping and copyFiles. We don't try to capture the state of the file at the exact time when it's accessed. Files might get changed, deleted ... we record only the "final" state. In order to preserve the relative topology of files we use their real paths as relative paths inside of the Root.
Declared at: llvm/include/llvm/Support/FileCollector.h:69
Inherits from: FileCollectorBase
Member Variables
- protected const std::string Root
- The directory where collected files are copied to in copyFiles().
- protected const std::string OverlayRoot
- The root directory where the VFS overlay lives.
- protected vfs::YAMLVFSWriter VFSWriter
- The yaml mapping writer.
- protected llvm::FileCollector::PathCanonicalizer Canonicalizer
- Helper utility for canonicalizing paths.
Inherited from FileCollectorBase:
Method Overview
- public FileCollector(std::string Root, std::string OverlayRoot)
- protected llvm::vfs::directory_iterator addDirectoryImpl(const llvm::Twine & Dir, IntrusiveRefCntPtr<vfs::FileSystem> FS, std::error_code & EC)
- protected void addFileImpl(llvm::StringRef SrcPath)
- private void addFileToMapping(llvm::StringRef VirtualPath, llvm::StringRef RealPath)
- public std::error_code copyFiles(bool StopOnError = true)
- public static IntrusiveRefCntPtr<vfs::FileSystem> createCollectorVFS(IntrusiveRefCntPtr<vfs::FileSystem> BaseFS, std::shared_ptr<FileCollector> Collector)
- public std::error_code writeMapping(llvm::StringRef MappingFile)
Inherited from FileCollectorBase:
- public addDirectory
- protected addDirectoryImpl
- public addFile
- protected addFileImpl
- protected markAsSeen
Methods
¶FileCollector(std::string Root,
std::string OverlayRoot)
FileCollector(std::string Root,
std::string OverlayRoot)
Description
\p Root is the directory where collected files are will be stored.\p OverlayRoot is VFS mapping root.\p Root directory gets created in copyFiles unless it already exists.
Declared at: llvm/include/llvm/Support/FileCollector.h:95
Parameters
- std::string Root
- std::string OverlayRoot
¶llvm::vfs::directory_iterator addDirectoryImpl(
const llvm::Twine& Dir,
IntrusiveRefCntPtr<vfs::FileSystem> FS,
std::error_code& EC)
llvm::vfs::directory_iterator addDirectoryImpl(
const llvm::Twine& Dir,
IntrusiveRefCntPtr<vfs::FileSystem> FS,
std::error_code& EC)
Declared at: llvm/include/llvm/Support/FileCollector.h:127
Parameters
- const llvm::Twine& Dir
- IntrusiveRefCntPtr<vfs::FileSystem> FS
- std::error_code& EC
¶void addFileImpl(llvm::StringRef SrcPath)
void addFileImpl(llvm::StringRef SrcPath)
Declared at: llvm/include/llvm/Support/FileCollector.h:124
Parameters
- llvm::StringRef SrcPath
¶void addFileToMapping(llvm::StringRef VirtualPath,
llvm::StringRef RealPath)
void addFileToMapping(llvm::StringRef VirtualPath,
llvm::StringRef RealPath)
Declared at: llvm/include/llvm/Support/FileCollector.h:116
Parameters
- llvm::StringRef VirtualPath
- llvm::StringRef RealPath
¶std::error_code copyFiles(bool StopOnError = true)
std::error_code copyFiles(bool StopOnError = true)
Description
Copy the files into the root directory. When StopOnError is true (the default) we abort as soon as one file cannot be copied. This is relatively common, for example when a file was removed after it was added to the mapping.
Declared at: llvm/include/llvm/Support/FileCollector.h:105
Parameters
- bool StopOnError = true
¶static IntrusiveRefCntPtr<vfs::FileSystem>
createCollectorVFS(
IntrusiveRefCntPtr<vfs::FileSystem> BaseFS,
std::shared_ptr<FileCollector> Collector)
static IntrusiveRefCntPtr<vfs::FileSystem>
createCollectorVFS(
IntrusiveRefCntPtr<vfs::FileSystem> BaseFS,
std::shared_ptr<FileCollector> Collector)
Description
Create a VFS that uses \p Collector to collect files accessed via \p BaseFS.
Declared at: llvm/include/llvm/Support/FileCollector.h:110
Parameters
- IntrusiveRefCntPtr<vfs::FileSystem> BaseFS
- std::shared_ptr<FileCollector> Collector
¶std::error_code writeMapping(
llvm::StringRef MappingFile)
std::error_code writeMapping(
llvm::StringRef MappingFile)
Description
Write the yaml mapping (for the VFS) to the given file.
Declared at: llvm/include/llvm/Support/FileCollector.h:98
Parameters
- llvm::StringRef MappingFile