LLVM
8.0.1
|
An in-memory file system. More...
#include "llvm/Support/VirtualFileSystem.h"
Public Member Functions | |
InMemoryFileSystem (bool UseNormalizedPaths=true) | |
~InMemoryFileSystem () override | |
bool | addFile (const 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) |
Add a file containing a buffer or a directory to the VFS with a path. More... | |
bool | addHardLink (const Twine &From, const Twine &To) |
Add a hard link to a file. More... | |
bool | addFileNoOwn (const Twine &Path, time_t ModificationTime, 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) |
Add a buffer to the VFS with a path. More... | |
std::string | toString () const |
bool | useNormalizedPaths () const |
Return true if this file system normalizes . and .. in paths. More... | |
llvm::ErrorOr< Status > | status (const Twine &Path) override |
Get the status of the entry at Path , if one exists. More... | |
llvm::ErrorOr< std::unique_ptr< File > > | openFileForRead (const Twine &Path) override |
Get a File object for the file at Path , if one exists. More... | |
directory_iterator | dir_begin (const Twine &Dir, std::error_code &EC) override |
Get a directory_iterator for Dir . More... | |
llvm::ErrorOr< std::string > | getCurrentWorkingDirectory () const override |
Get the working directory of this file system. More... | |
std::error_code | getRealPath (const Twine &Path, SmallVectorImpl< char > &Output) const override |
Canonicalizes Path by combining with the current working directory and normalizing the path (e.g. More... | |
std::error_code | isLocal (const Twine &Path, bool &Result) override |
Is the file mounted on a local filesystem? More... | |
std::error_code | setCurrentWorkingDirectory (const Twine &Path) override |
Set the working directory. More... | |
Public Member Functions inherited from llvm::vfs::FileSystem | |
virtual | ~FileSystem () |
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > | getBufferForFile (const Twine &Name, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false) |
This is a convenience method that opens a file, gets its content and then closes the file. More... | |
bool | exists (const Twine &Path) |
Check whether a file exists. Provided for convenience. More... | |
std::error_code | makeAbsolute (SmallVectorImpl< char > &Path) const |
Make Path an absolute path. More... | |
Public Member Functions inherited from llvm::ThreadSafeRefCountedBase< FileSystem > | |
void | Retain () const |
void | Release () const |
Additional Inherited Members | |
Protected Member Functions inherited from llvm::ThreadSafeRefCountedBase< FileSystem > | |
ThreadSafeRefCountedBase () | |
An in-memory file system.
Definition at line 399 of file VirtualFileSystem.h.
Definition at line 634 of file VirtualFileSystem.cpp.
References ~InMemoryFileSystem().
|
overridedefault |
Referenced by InMemoryFileSystem().
bool llvm::vfs::InMemoryFileSystem::addFile | ( | const 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 |
||
) |
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.
Definition at line 738 of file VirtualFileSystem.cpp.
bool llvm::vfs::InMemoryFileSystem::addFileNoOwn | ( | const Twine & | Path, |
time_t | ModificationTime, | ||
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 |
||
) |
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.
Definition at line 748 of file VirtualFileSystem.cpp.
References llvm::MemoryBuffer::getBuffer(), llvm::MemoryBuffer::getBufferIdentifier(), and llvm::MemoryBuffer::getMemBuffer().
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 To path must be an existing file or a hardlink. The From file must not have been added before. The To Path must not be a directory. The From Node is added as a hard link which points to the resolved file of To Node.
Definition at line 805 of file VirtualFileSystem.cpp.
References llvm::vfs::lookupInMemoryNode(), and llvm::None.
|
overridevirtual |
Get a directory_iterator for Dir
.
Implements llvm::vfs::FileSystem.
Definition at line 889 of file VirtualFileSystem.cpp.
|
inlineoverridevirtual |
Get the working directory of this file system.
Implements llvm::vfs::FileSystem.
Definition at line 465 of file VirtualFileSystem.h.
References llvm::vfs::getNextVirtualUniqueID(), llvm::vfs::getRealFileSystem(), and llvm::vfs::getVFSFromYAML().
Referenced by getRealPath().
|
overridevirtual |
Canonicalizes 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.
Reimplemented from llvm::vfs::FileSystem.
Definition at line 923 of file VirtualFileSystem.cpp.
References getCurrentWorkingDirectory(), llvm::vfs::FileSystem::makeAbsolute(), llvm::operation_not_permitted, llvm::sys::path::remove_dots(), and llvm::Twine::toVector().
|
overridevirtual |
Is the file mounted on a local filesystem?
Reimplemented from llvm::vfs::FileSystem.
Definition at line 935 of file VirtualFileSystem.cpp.
|
overridevirtual |
Get a File
object for the file at Path
, if one exists.
Implements llvm::vfs::FileSystem.
Definition at line 825 of file VirtualFileSystem.cpp.
|
overridevirtual |
Set the working directory.
This will affect all following operations on this file system and may propagate down for nested file systems.
Implements llvm::vfs::FileSystem.
Definition at line 905 of file VirtualFileSystem.cpp.
References assert(), llvm::SmallVectorBase::empty(), llvm::vfs::FileSystem::makeAbsolute(), llvm::sys::path::remove_dots(), llvm::SmallString< InternalLen >::str(), llvm::Twine::toVector(), and useNormalizedPaths().
|
overridevirtual |
Get the status of the entry at Path
, if one exists.
Implements llvm::vfs::FileSystem.
Definition at line 817 of file VirtualFileSystem.cpp.
Referenced by llvm::vfs::RedirectingFileSystem::dir_begin(), and llvm::vfs::RedirectingFileSystem::status().
std::string llvm::vfs::InMemoryFileSystem::toString | ( | ) | const |
Definition at line 643 of file VirtualFileSystem.cpp.
References llvm::sys::fs::all_all, assert(), llvm::sys::path::begin(), E, llvm::SmallVectorBase::empty(), llvm::sys::path::end(), llvm::Optional< T >::getValueOr(), I, llvm::vfs::FileSystem::makeAbsolute(), llvm::sys::fs::owner_all, P, llvm::sys::fs::regular_file, llvm::sys::path::remove_dots(), llvm::Twine::toVector(), and useNormalizedPaths().
|
inline |
Return true if this file system normalizes . and .. in paths.
Definition at line 458 of file VirtualFileSystem.h.
References llvm::sys::fs::openFileForRead(), and llvm::sys::fs::status().
Referenced by llvm::vfs::lookupInMemoryNode(), setCurrentWorkingDirectory(), and toString().