29 UpperDest = Path.
upper();
36 : Root(
std::move(Root)), OverlayRoot(
std::move(OverlayRoot)) {
40 bool FileCollector::getRealPath(
StringRef SrcPath,
56 RealPath = DirWithSymlink->second;
60 Result.
swap(RealPath);
65 std::lock_guard<std::mutex> lock(
Mutex);
66 std::string FileStr = file.
str();
67 if (markAsSeen(FileStr))
71 void FileCollector::addFileImpl(
StringRef SrcPath) {
90 if (!getRealPath(AbsoluteSrc, CopyFrom))
91 CopyFrom = VirtualPath;
101 addFileToMapping(VirtualPath, DstPath);
106 static std::error_code
128 if (std::error_code EC =
145 if (std::error_code EC =
175 std::lock_guard<std::mutex> lock(
Mutex);
196 std::shared_ptr<FileCollector>
Collector)
197 :
FS(std::move(FS)),
Collector(std::move(Collector)) {}
200 auto Result = FS->
status(Path);
201 if (Result && Result->exists())
202 Collector->addFile(Path);
209 if (Result && *Result)
210 Collector->addFile(Path);
215 std::error_code &EC)
override {
220 Collector->addFile(Dir);
225 Collector->addFile(It->path());
234 std::error_code getRealPath(
const Twine &Path,
238 Collector->addFile(Path);
239 if (Output.
size() > 0)
240 Collector->addFile(Output);
245 std::error_code isLocal(
const Twine &Path,
bool &Result)
override {
246 return FS->
isLocal(Path, Result);
253 std::error_code setCurrentWorkingDirectory(
const llvm::Twine &Path)
override {
259 std::shared_ptr<FileCollector>
Collector;
266 std::shared_ptr<FileCollector>
Collector) {
267 return new FileCollectorFileSystem(std::move(BaseFS), std::move(Collector));
std::error_code create_directories(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create all the non-existent directories in path.
*ViewGraph Emit a dot run run gv on the postscript file
Represents either an error or a value T.
void native(const Twine &path, SmallVectorImpl< char > &result, Style style=Style::native)
Convert path to the native form.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
This class represents lattice values for constants.
std::error_code openFileForRead(const Twine &Name, int &ResultFD, OpenFlags Flags=OF_None, SmallVectorImpl< char > *RealPath=nullptr)
Opens the file with the given name in a read-only mode, returning its open file descriptor.
StringMap< std::string > SymlinkMap
Caches RealPath calls when resolving symlinks.
std::error_code setLastAccessAndModificationTime(int FD, TimePoint<> AccessTime, TimePoint<> ModificationTime)
Set the file modification and access time.
const std::vector< YAMLVFSEntry > & getMappings() const
iterator find(StringRef Key)
static std::error_code copyAccessAndModificationTime(StringRef Filename, const sys::fs::file_status &Stat)
Set the access and modification time for the given file from the given status object.
StringRef remove_leading_dotslash(StringRef path, Style style=Style::native)
Remove redundant leading "./" pieces and consecutive separators.
Represents the result of a call to sys::fs::status().
CD_OpenExisting - When opening a file:
std::error_code copyFiles(bool StopOnError=true)
Copy the files into the root directory.
ErrorOr< perms > getPermissions(const Twine &Path)
Get file permissions.
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void write(llvm::raw_ostream &OS)
void make_absolute(const Twine ¤t_directory, SmallVectorImpl< char > &path)
Make path an absolute path.
std::string OverlayRoot
The root directory where the VFS overlay lives.
StringRef str() const
Explicit conversion to StringRef.
void setCaseSensitivity(bool CaseSensitive)
virtual llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const =0
Get the working directory of this file system.
virtual std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) const
Gets real path of Path e.g.
The file should be opened in text mode on platforms that make this distinction.
LLVM_NODISCARD std::string upper() const
Convert the given ASCII string to uppercase.
FileCollector(std::string Root, std::string OverlayRoot)
std::error_code writeMapping(StringRef mapping_file)
Write the yaml mapping (for the VFS) to the given file.
std::error_code copy_file(const Twine &From, const Twine &To)
Copy the contents of From to To.
std::error_code real_path(const Twine &path, SmallVectorImpl< char > &output, bool expand_tilde=false)
Collapse all .
virtual std::error_code isLocal(const Twine &Path, bool &Result)
Is the file mounted on a local filesystem?
vfs::YAMLVFSWriter VFSWriter
The yaml mapping writer.
void swap(SmallVectorImpl &RHS)
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
virtual llvm::ErrorOr< Status > status(const Twine &Path)=0
Get the status of the entry at Path, if one exists.
TimePoint getLastModificationTime() const
The file modification time as reported from the underlying file system.
virtual std::error_code setCurrentWorkingDirectory(const Twine &Path)=0
Set the working directory.
void addFile(const Twine &file)
std::string Root
The root directory where files are copied.
StringRef parent_path(StringRef path, Style style=Style::native)
Get parent path.
std::error_code openFileForWrite(const Twine &Name, int &ResultFD, CreationDisposition Disp=CD_CreateAlways, OpenFlags Flags=OF_None, unsigned Mode=0666)
Opens the file with the given name in a write-only or read-write mode, returning its open file descri...
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
static bool isCaseSensitivePath(StringRef Path)
An input iterator over the entries in a virtual path, similar to llvm::sys::fs::directory_iterator.
static IntrusiveRefCntPtr< vfs::FileSystem > createCollectorVFS(IntrusiveRefCntPtr< vfs::FileSystem > BaseFS, std::shared_ptr< FileCollector > Collector)
Create a VFS that collects all the paths that might be looked at by the file system accesses...
bool remove_dots(SmallVectorImpl< char > &path, bool remove_dot_dot=false, Style style=Style::native)
In-place remove any '.
void setUseExternalNames(bool UseExtNames)
The virtual file system interface.
virtual directory_iterator dir_begin(const Twine &Dir, std::error_code &EC)=0
Get a directory_iterator for Dir.
std::error_code setPermissions(const Twine &Path, perms Permissions)
Set file permissions.
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Provides a library for accessing information about this process and other processes on the operating ...
A raw_ostream that writes to a file descriptor.
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
virtual llvm::ErrorOr< std::unique_ptr< File > > openFileForRead(const Twine &Path)=0
Get a File object for the file at Path, if one exists.
std::string str() const
Return the twine contents as a std::string.
StringRef relative_path(StringRef path, Style style=Style::native)
Get relative path.
static std::error_code SafelyCloseFileDescriptor(int FD)
print Instructions which execute on loop entry
void setOverlayDir(StringRef OverlayDirectory)
StringRef - Represent a constant reference to a string, i.e.
TimePoint getLastAccessedTime() const
The file access time as reported from the underlying file system.
Register Usage Information Collector