class InMemoryFileSystem
Declaration
class InMemoryFileSystem : public FileSystem { /* full declaration omitted */ };
Description
An in-memory file system.
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:502
Inherits from: FileSystem
Member Variables
- private std::unique_ptr<detail::InMemoryDirectory> Root
- private std::string WorkingDirectory
- private bool UseNormalizedPaths = true
- public static const size_t MaxSymlinkDepth = 16
- Arbitrary max depth to search through symlinks. We can get into problems if a link links to a link that links back to the link, for example.
Method Overview
- public InMemoryFileSystem(bool UseNormalizedPaths = true)
- private bool addFile(const llvm::Twine & Path, time_t ModificationTime, std::unique_ptr<llvm::MemoryBuffer> Buffer, Optional<uint32_t> User, Optional<uint32_t> Group, Optional<llvm::sys::fs::file_type> Type, Optional<llvm::sys::fs::perms> Perms, llvm::vfs::InMemoryFileSystem::MakeNodeFn MakeNode)
- public bool addFile(const llvm::Twine & Path, time_t ModificationTime, std::unique_ptr<llvm::MemoryBuffer> Buffer, Optional<uint32_t> User = None, Optional<uint32_t> Group = None, Optional<llvm::sys::fs::file_type> Type = None, Optional<llvm::sys::fs::perms> Perms = None)
- public bool addFileNoOwn(const llvm::Twine & Path, time_t ModificationTime, const llvm::MemoryBufferRef & Buffer, Optional<uint32_t> User = None, Optional<uint32_t> Group = None, Optional<llvm::sys::fs::file_type> Type = None, Optional<llvm::sys::fs::perms> Perms = None)
- public bool addHardLink(const llvm::Twine & NewLink, const llvm::Twine & Target)
- public bool addSymbolicLink(const llvm::Twine & NewLink, const llvm::Twine & Target, time_t ModificationTime, Optional<uint32_t> User = None, Optional<uint32_t> Group = None, Optional<llvm::sys::fs::perms> Perms = None)
- public llvm::vfs::directory_iterator dir_begin(const llvm::Twine & Dir, std::error_code & EC)
- public llvm::ErrorOr<std::string> getCurrentWorkingDirectory() const
- public std::error_code getRealPath(const llvm::Twine & Path, SmallVectorImpl<char> & Output) const
- public std::error_code isLocal(const llvm::Twine & Path, bool & Result)
- private detail::NamedNodeOrError lookupNode(const llvm::Twine & P, bool FollowFinalSymlink, size_t SymlinkDepth = 0) const
- public llvm::ErrorOr<std::unique_ptr<File>> openFileForRead(const llvm::Twine & Path)
- protected void printImpl(llvm::raw_ostream & OS, llvm::vfs::FileSystem::PrintType Type, unsigned int IndentLevel) const
- public std::error_code setCurrentWorkingDirectory(const llvm::Twine & Path)
- public llvm::ErrorOr<Status> status(const llvm::Twine & Path)
- public std::string toString() const
- public bool useNormalizedPaths() const
- public ~InMemoryFileSystem()
Inherited from FileSystem:
- public dir_begin
- public dump
- public exists
- public getBufferForFile
- public getCurrentWorkingDirectory
- public getRealPath
- public isLocal
- public makeAbsolute
- public openFileForRead
- public print
- protected printImpl
- protected printIndent
- public setCurrentWorkingDirectory
- public status
Methods
¶InMemoryFileSystem(bool UseNormalizedPaths = true)
InMemoryFileSystem(bool UseNormalizedPaths = true)
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:526
Parameters
- bool UseNormalizedPaths = true
¶bool addFile(
const llvm::Twine& Path,
time_t ModificationTime,
std::unique_ptr<llvm::MemoryBuffer> Buffer,
Optional<uint32_t> User,
Optional<uint32_t> Group,
Optional<llvm::sys::fs::file_type> Type,
Optional<llvm::sys::fs::perms> Perms,
llvm::vfs::InMemoryFileSystem::MakeNodeFn
MakeNode)
bool addFile(
const llvm::Twine& Path,
time_t ModificationTime,
std::unique_ptr<llvm::MemoryBuffer> Buffer,
Optional<uint32_t> User,
Optional<uint32_t> Group,
Optional<llvm::sys::fs::file_type> Type,
Optional<llvm::sys::fs::perms> Perms,
llvm::vfs::InMemoryFileSystem::MakeNodeFn
MakeNode)
Description
Create node with \p MakeNode and add it into this filesystem at \p Path.
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:511
Parameters
- const llvm::Twine& Path
- time_t ModificationTime
- std::unique_ptr<llvm::MemoryBuffer> Buffer
- Optional<uint32_t> User
- Optional<uint32_t> Group
- Optional<llvm::sys::fs::file_type> Type
- Optional<llvm::sys::fs::perms> Perms
- llvm::vfs::InMemoryFileSystem::MakeNodeFn MakeNode
¶bool addFile(
const llvm::Twine& Path,
time_t ModificationTime,
std::unique_ptr<llvm::MemoryBuffer> Buffer,
Optional<uint32_t> User = None,
Optional<uint32_t> Group = None,
Optional<llvm::sys::fs::file_type> Type =
None,
Optional<llvm::sys::fs::perms> Perms = None)
bool addFile(
const llvm::Twine& Path,
time_t ModificationTime,
std::unique_ptr<llvm::MemoryBuffer> Buffer,
Optional<uint32_t> User = None,
Optional<uint32_t> Group = None,
Optional<llvm::sys::fs::file_type> Type =
None,
Optional<llvm::sys::fs::perms> Perms = None)
Description
Add a file containing a buffer or a directory to the VFS with a path. The VFS owns the buffer. If present, User, Group, Type and Perms apply to the newly-created file or directory.
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:535
Parameters
- const llvm::Twine& Path
- time_t ModificationTime
- std::unique_ptr<llvm::MemoryBuffer> Buffer
- Optional<uint32_t> User = None
- Optional<uint32_t> Group = None
- Optional<llvm::sys::fs::file_type> Type = None
- Optional<llvm::sys::fs::perms> Perms = None
Returns
true if the file or directory was successfully added, false if the file or directory already exists in the file system with different contents.
¶bool addFileNoOwn(
const llvm::Twine& Path,
time_t ModificationTime,
const llvm::MemoryBufferRef& Buffer,
Optional<uint32_t> User = None,
Optional<uint32_t> Group = None,
Optional<llvm::sys::fs::file_type> Type =
None,
Optional<llvm::sys::fs::perms> Perms = None)
bool addFileNoOwn(
const llvm::Twine& Path,
time_t ModificationTime,
const llvm::MemoryBufferRef& Buffer,
Optional<uint32_t> User = None,
Optional<uint32_t> Group = None,
Optional<llvm::sys::fs::file_type> Type =
None,
Optional<llvm::sys::fs::perms> Perms = None)
Description
Add a buffer to the VFS with a path. The VFS does not own the buffer. If present, User, Group, Type and Perms apply to the newly-created file or directory.
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:575
Parameters
- const llvm::Twine& Path
- time_t ModificationTime
- const llvm::MemoryBufferRef& Buffer
- Optional<uint32_t> User = None
- Optional<uint32_t> Group = None
- Optional<llvm::sys::fs::file_type> Type = None
- Optional<llvm::sys::fs::perms> Perms = None
Returns
true if the file or directory was successfully added, false if the file or directory already exists in the file system with different contents.
¶bool addHardLink(const llvm::Twine& NewLink,
const llvm::Twine& Target)
bool addHardLink(const llvm::Twine& NewLink,
const llvm::Twine& Target)
Description
Add a hard link to a file. Here hard links are not intended to be fully equivalent to the classical filesystem. Both the hard link and the file share the same buffer and status (and thus have the same UniqueID). Because of this there is no way to distinguish between the link and the file after the link has been added. The
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:555
Parameters
- const llvm::Twine& NewLink
- node is added as a hard link which points to the resolved file of
- const llvm::Twine& Target
- node.
Returns
true if the above condition is satisfied and hardlink was successfully created, false otherwise.
¶bool addSymbolicLink(
const llvm::Twine& NewLink,
const llvm::Twine& Target,
time_t ModificationTime,
Optional<uint32_t> User = None,
Optional<uint32_t> Group = None,
Optional<llvm::sys::fs::perms> Perms = None)
bool addSymbolicLink(
const llvm::Twine& NewLink,
const llvm::Twine& Target,
time_t ModificationTime,
Optional<uint32_t> User = None,
Optional<uint32_t> Group = None,
Optional<llvm::sys::fs::perms> Perms = None)
Description
Add a symbolic link. Unlike a HardLink, because
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:564
Parameters
- const llvm::Twine& NewLink
- const llvm::Twine& Target
- isn't automatically created.
- time_t ModificationTime
- Optional<uint32_t> User = None
- Optional<uint32_t> Group = None
- Optional<llvm::sys::fs::perms> Perms = None
¶llvm::vfs::directory_iterator dir_begin(
const llvm::Twine& Dir,
std::error_code& EC)
llvm::vfs::directory_iterator dir_begin(
const llvm::Twine& Dir,
std::error_code& EC)
Description
Get a directory_iterator for \p Dir.
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:590
Parameters
- const llvm::Twine& Dir
- std::error_code& EC
¶llvm::ErrorOr<std::string>
getCurrentWorkingDirectory() const
llvm::ErrorOr<std::string>
getCurrentWorkingDirectory() const
Description
Get the working directory of this file system.
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:592
¶std::error_code getRealPath(
const llvm::Twine& Path,
SmallVectorImpl<char>& Output) const
std::error_code getRealPath(
const llvm::Twine& Path,
SmallVectorImpl<char>& Output) const
Description
Canonicalizes \p Path by combining with the current working directory and normalizing the path (e.g. remove dots). If the current working directory is not set, this returns errc::operation_not_permitted. This doesn't resolve symlinks as they are not supported in in-memory file system.
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:601
Parameters
- const llvm::Twine& Path
- SmallVectorImpl<char>& Output
¶std::error_code isLocal(const llvm::Twine& Path,
bool& Result)
std::error_code isLocal(const llvm::Twine& Path,
bool& Result)
Description
Is the file mounted on a local filesystem?
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:603
Parameters
- const llvm::Twine& Path
- bool& Result
¶detail::NamedNodeOrError lookupNode(
const llvm::Twine& P,
bool FollowFinalSymlink,
size_t SymlinkDepth = 0) const
detail::NamedNodeOrError lookupNode(
const llvm::Twine& P,
bool FollowFinalSymlink,
size_t SymlinkDepth = 0) const
Description
Looks up the in-memory node for the path
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:520
Parameters
- const llvm::Twine& P
- bool FollowFinalSymlink
- is true, the returned node is guaranteed to not be a symlink and its path may differ from
- size_t SymlinkDepth = 0
¶llvm::ErrorOr<std::unique_ptr<File>>
openFileForRead(const llvm::Twine& Path)
llvm::ErrorOr<std::unique_ptr<File>>
openFileForRead(const llvm::Twine& Path)
Description
Get a \p File object for the file at \p Path, if one exists.
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:589
Parameters
- const llvm::Twine& Path
¶void printImpl(
llvm::raw_ostream& OS,
llvm::vfs::FileSystem::PrintType Type,
unsigned int IndentLevel) const
void printImpl(
llvm::raw_ostream& OS,
llvm::vfs::FileSystem::PrintType Type,
unsigned int IndentLevel) const
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:607
Parameters
- llvm::raw_ostream& OS
- llvm::vfs::FileSystem::PrintType Type
- unsigned int IndentLevel
¶std::error_code setCurrentWorkingDirectory(
const llvm::Twine& Path)
std::error_code setCurrentWorkingDirectory(
const llvm::Twine& Path)
Description
Set the working directory. This will affect all following operations on this file system and may propagate down for nested file systems.
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:604
Parameters
- const llvm::Twine& Path
¶llvm::ErrorOr<Status> status(
const llvm::Twine& Path)
llvm::ErrorOr<Status> status(
const llvm::Twine& Path)
Description
Get the status of the entry at \p Path, if one exists.
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:587
Parameters
- const llvm::Twine& Path
¶std::string toString() const
std::string toString() const
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:582
¶bool useNormalizedPaths() const
bool useNormalizedPaths() const
Description
Return true if this file system normalizes . and .. in paths.
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:585
¶~InMemoryFileSystem()
~InMemoryFileSystem()
Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:527