Go to the documentation of this file.
22 std::lock_guard<std::mutex> lock(
Mutex);
23 std::string FileStr = File.str();
46 UpperDest = Path.upper();
56 void FileCollector::PathCanonicalizer::updateWithRealPath(
58 StringRef SrcPath(Path.begin(), Path.size());
66 auto DirWithSymlink = CachedDirs.
find(Directory);
67 if (DirWithSymlink == CachedDirs.
end()) {
72 CachedDirs[Directory] = std::string(RealPath.
str());
74 RealPath = DirWithSymlink->second;
137 std::error_code &EC) {
138 auto It =
FS->dir_begin(Dir, EC);
152 return FS->dir_begin(Dir, EC);
157 static std::error_code
167 FD, Stat.getLastAccessedTime(), Stat.getLastModificationTime()))
182 std::lock_guard<std::mutex> lock(
Mutex);
198 if (std::error_code EC =
207 if (std::error_code EC =
237 std::lock_guard<std::mutex> lock(
Mutex);
258 std::shared_ptr<FileCollector>
Collector)
262 auto Result =
FS->status(Path);
263 if (Result && Result->exists())
270 auto Result =
FS->openFileForRead(Path);
271 if (Result && *Result)
277 std::error_code &EC)
override {
283 auto EC =
FS->getRealPath(Path, Output);
286 if (Output.size() > 0)
293 return FS->isLocal(Path, Result);
297 return FS->getCurrentWorkingDirectory();
301 return FS->setCurrentWorkingDirectory(Path);
306 std::shared_ptr<FileCollector>
Collector;
313 std::shared_ptr<FileCollector>
Collector) {
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...
This is an optimization pass for GlobalISel generic memory operations.
const std::string Root
The directory where collected files are copied to in copyFiles().
bool markAsSeen(StringRef Path)
StringRef remove_leading_dotslash(StringRef path, Style style=Style::native)
Remove redundant leading "./" pieces and consecutive separators.
const std::string OverlayRoot
The root directory where the VFS overlay lives.
void addFileImpl(StringRef SrcPath) override
static bool isCaseSensitivePath(StringRef Path)
static IntrusiveRefCntPtr< vfs::FileSystem > createCollectorVFS(IntrusiveRefCntPtr< vfs::FileSystem > BaseFS, std::shared_ptr< FileCollector > Collector)
Create a VFS that uses Collector to collect files accessed via BaseFS.
An input iterator over the entries in a virtual path, similar to llvm::sys::fs::directory_iterator.
@ CD_OpenExisting
CD_OpenExisting - When opening a file:
void native(const Twine &path, SmallVectorImpl< char > &result, Style style=Style::native)
Convert path to the native form.
static void makeAbsolute(SmallVectorImpl< char > &Path)
Make Path absolute.
llvm::ErrorOr< llvm::vfs::Status > status(const Twine &Path) override
Get the status of the entry at Path, if one exists.
iterator find(StringRef Key)
std::error_code setLastAccessAndModificationTime(int FD, TimePoint<> AccessTime, TimePoint<> ModificationTime)
Set the file modification and access time.
std::error_code isLocal(const Twine &Path, bool &Result) override
Is the file mounted on a local filesystem?
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.
Register Usage Information Collector
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
virtual void addFileImpl(StringRef SrcPath)=0
std::error_code writeMapping(StringRef MappingFile)
Write the yaml mapping (for the VFS) to the given file.
std::error_code real_path(const Twine &path, SmallVectorImpl< char > &output, bool expand_tilde=false)
Collapse all .
llvm::vfs::directory_iterator addDirectoryImpl(const llvm::Twine &Dir, IntrusiveRefCntPtr< vfs::FileSystem > FS, std::error_code &EC) override
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.
std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) const override
Gets real path of Path e.g.
PathCanonicalizer Canonicalizer
Helper utility for canonicalizing paths.
FileCollectorFileSystem(IntrusiveRefCntPtr< vfs::FileSystem > FS, std::shared_ptr< FileCollector > Collector)
virtual ~FileCollectorBase()
@ OF_TextWithCRLF
The file should be opened in text mode and use a carriage linefeed '\r '.
std::error_code copyFiles(bool StopOnError=true)
Copy the files into the root directory.
static std::error_code SafelyCloseFileDescriptor(int FD)
Represents the result of a call to sys::fs::status().
bool remove_dots(SmallVectorImpl< char > &path, bool remove_dot_dot=false, Style style=Style::native)
In-place remove any '.
IntrusiveRefCntPtr< FileSystem > getRealFileSystem()
Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef parent_path(StringRef path, Style style=Style::native)
Get parent path.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
std::error_code setPermissions(const Twine &Path, perms Permissions)
Set file permissions.
llvm::vfs::directory_iterator dir_begin(const llvm::Twine &Dir, std::error_code &EC) override
Get a directory_iterator for Dir.
void make_absolute(const Twine ¤t_directory, SmallVectorImpl< char > &path)
Make path an absolute path.
void addFile(const Twine &file)
std::error_code setCurrentWorkingDirectory(const llvm::Twine &Path) override
Set the working directory.
llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const override
Get the working directory of this file system.
void setCaseSensitivity(bool CaseSensitive)
StringRef - Represent a constant reference to a string, i.e.
ErrorOr< perms > getPermissions(const Twine &Path)
Get file permissions.
void write(llvm::raw_ostream &OS)
A raw_ostream that writes to a file descriptor.
void setOverlayDir(StringRef OverlayDirectory)
SmallString< 256 > VirtualPath
void setUseExternalNames(bool UseExtNames)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The virtual file system interface.
bool is_directory(const basic_file_status &status)
Does status represent a directory?
virtual llvm::vfs::directory_iterator addDirectoryImpl(const llvm::Twine &Dir, IntrusiveRefCntPtr< vfs::FileSystem > FS, std::error_code &EC)=0
SmallString< 256 > CopyFrom
StringRef str() const
Explicit conversion to StringRef.
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
PathStorage canonicalize(StringRef SrcPath)
Canonicalize a pair of virtual and real paths.
const std::vector< YAMLVFSEntry > & getMappings() const
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
Represents either an error or a value T.
llvm::ErrorOr< std::unique_ptr< llvm::vfs::File > > openFileForRead(const Twine &Path) override
Get a File object for the file at Path, if one exists.
FileCollector(std::string Root, std::string OverlayRoot)
Root is the directory where collected files are will be stored.
StringRef relative_path(StringRef path, Style style=Style::native)
Get relative path.
void addDirectory(const Twine &Dir)
vfs::YAMLVFSWriter VFSWriter
The yaml mapping writer.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
print Instructions which execute on loop entry
std::error_code copy_file(const Twine &From, const Twine &To)
Copy the contents of From to To.