LLVM
8.0.1
|
A virtual file system parsed from a YAML file. More...
#include "llvm/Support/VirtualFileSystem.h"
Classes | |
class | Entry |
A single file or directory in the VFS. More... | |
class | RedirectingDirectoryEntry |
class | RedirectingFileEntry |
Public Types | |
enum | EntryKind { EK_Directory, EK_File } |
Public Member Functions | |
ErrorOr< Entry * > | lookupPath (const Twine &Path) const |
Looks up Path in Roots . More... | |
ErrorOr< Status > | status (const Twine &Path) override |
Get the status of the entry at Path , if one exists. More... | |
ErrorOr< std::unique_ptr< File > > | openFileForRead (const Twine &Path) override |
Get a File object for the file at Path , if one exists. More... | |
std::error_code | getRealPath (const Twine &Path, SmallVectorImpl< char > &Output) const override |
Gets real path of Path e.g. More... | |
llvm::ErrorOr< std::string > | getCurrentWorkingDirectory () const override |
Get the working directory of this file system. More... | |
std::error_code | setCurrentWorkingDirectory (const Twine &Path) override |
Set the working directory. More... | |
std::error_code | isLocal (const Twine &Path, bool &Result) override |
Is the file mounted on a local filesystem? More... | |
directory_iterator | dir_begin (const Twine &Dir, std::error_code &EC) override |
Get a directory_iterator for Dir . More... | |
void | setExternalContentsPrefixDir (StringRef PrefixDir) |
StringRef | getExternalContentsPrefixDir () const |
LLVM_DUMP_METHOD void | dump () const |
LLVM_DUMP_METHOD void | dumpEntry (Entry *E, int NumSpaces=0) const |
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 |
Static Public Member Functions | |
static RedirectingFileSystem * | create (std::unique_ptr< MemoryBuffer > Buffer, SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath, void *DiagContext, IntrusiveRefCntPtr< FileSystem > ExternalFS) |
Parses Buffer , which is expected to be in YAML format and returns a virtual file system representing its contents. More... | |
Friends | |
class | VFSFromYamlDirIterImpl |
class | RedirectingFileSystemParser |
Additional Inherited Members | |
Protected Member Functions inherited from llvm::ThreadSafeRefCountedBase< FileSystem > | |
ThreadSafeRefCountedBase () | |
A virtual file system parsed from a YAML file.
Currently, this class allows creating virtual directories and mapping virtual file paths to existing external files, available in ExternalFS
.
The basic structure of the parsed file is:
/// { /// 'version': <version number>, /// <optional configuration> /// 'roots': [ /// <directory entries> /// ] /// } ///
All configuration options are optional. 'case-sensitive': <boolean, default=true> 'use-external-names': <boolean, default=true> 'overlay-relative': <boolean, default=false> 'fallthrough': <boolean, default=true> Virtual directories are represented as
/// { /// 'type': 'directory', /// 'name': <string>, /// 'contents': [ <file or directory entries> ] /// } ///
The default attributes for virtual directories are:
/// MTime = now() when created /// Perms = 0777 /// User = Group = 0 /// Size = 0 /// UniqueID = unspecified unique value ///
Re-mapped files are represented as
/// { /// 'type': 'file', /// 'name': <string>, /// 'use-external-name': <boolean> # Optional /// 'external-contents': <path to external file> /// } ///
and inherit their attributes from the external contents. In both cases, the 'name' field may contain multiple path components (e.g. /path/to/file). However, any directory that contains more than one child must be uniquely represented by a directory entry.
Definition at line 557 of file VirtualFileSystem.h.
Enumerator | |
---|---|
EK_Directory | |
EK_File |
Definition at line 559 of file VirtualFileSystem.h.
|
static |
Parses Buffer
, which is expected to be in YAML format and returns a virtual file system representing its contents.
Definition at line 1513 of file VirtualFileSystem.cpp.
References assert(), llvm::SourceMgr::DK_Error, llvm::StringRef::empty(), llvm::sys::fs::make_absolute(), P, llvm::sys::path::parent_path(), llvm::vfs::RedirectingFileSystemParser::parse(), llvm::SourceMgr::PrintMessage(), and llvm::SourceMgr::setDiagHandler().
Referenced by getRealPath(), and getVFSEntries().
|
overridevirtual |
Get a directory_iterator for Dir
.
Implements llvm::vfs::FileSystem.
Definition at line 1006 of file VirtualFileSystem.cpp.
References D, E, llvm::ErrorOr< T >::getError(), llvm::no_such_file_or_directory, llvm::not_a_directory, and llvm::vfs::InMemoryFileSystem::status().
LLVM_DUMP_METHOD void RedirectingFileSystem::dump | ( | ) | const |
Definition at line 1041 of file VirtualFileSystem.cpp.
References LLVM_DUMP_METHOD.
LLVM_DUMP_METHOD void RedirectingFileSystem::dumpEntry | ( | RedirectingFileSystem::Entry * | E, |
int | NumSpaces = 0 |
||
) | const |
Definition at line 1047 of file VirtualFileSystem.cpp.
References assert(), llvm::dbgs(), llvm::dyn_cast(), E, EK_Directory, llvm::vfs::RedirectingFileSystem::Entry::getKind(), llvm::vfs::RedirectingFileSystem::Entry::getName(), llvm::make_range(), and llvm::StringRef::str().
|
overridevirtual |
Get the working directory of this file system.
Implements llvm::vfs::FileSystem.
Definition at line 992 of file VirtualFileSystem.cpp.
StringRef RedirectingFileSystem::getExternalContentsPrefixDir | ( | ) | const |
Definition at line 1036 of file VirtualFileSystem.cpp.
|
overridevirtual |
Gets real path of Path
e.g.
collapse all . and .. patterns, resolve symlinks. For real file system, this uses llvm::sys::fs::real_path
. This returns errc::operation_not_permitted if not implemented by subclass.
Reimplemented from llvm::vfs::FileSystem.
Definition at line 1725 of file VirtualFileSystem.cpp.
References create(), F(), llvm::ErrorOr< T >::getError(), llvm::vfs::getVFSFromYAML(), llvm::invalid_argument, and llvm::no_such_file_or_directory.
|
overridevirtual |
Is the file mounted on a local filesystem?
Reimplemented from llvm::vfs::FileSystem.
Definition at line 1001 of file VirtualFileSystem.cpp.
ErrorOr< RedirectingFileSystem::Entry * > RedirectingFileSystem::lookupPath | ( | const Twine & | Path | ) | const |
Looks up Path
in Roots
.
Definition at line 1556 of file VirtualFileSystem.cpp.
References llvm::SmallVectorBase::empty(), llvm::invalid_argument, llvm::make_error_code(), llvm::vfs::FileSystem::makeAbsolute(), llvm::sys::path::remove_dots(), llvm::sys::path::remove_leading_dotslash(), and llvm::Twine::toVector().
|
overridevirtual |
Get a File
object for the file at Path
, if one exists.
Implements llvm::vfs::FileSystem.
Definition at line 1695 of file VirtualFileSystem.cpp.
References llvm::dyn_cast(), F(), llvm::ErrorOr< T >::getError(), getRedirectedFileStatus(), llvm::invalid_argument, llvm::make_error_code(), and llvm::no_such_file_or_directory.
|
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 997 of file VirtualFileSystem.cpp.
void RedirectingFileSystem::setExternalContentsPrefixDir | ( | StringRef | PrefixDir | ) |
Definition at line 1032 of file VirtualFileSystem.cpp.
References llvm::StringRef::str().
Get the status of the entry at Path
, if one exists.
Implements llvm::vfs::FileSystem.
Definition at line 1657 of file VirtualFileSystem.cpp.
References llvm::ErrorOr< T >::getError(), llvm::no_such_file_or_directory, and llvm::vfs::InMemoryFileSystem::status().
|
friend |
Definition at line 632 of file VirtualFileSystem.h.
|
friend |
Definition at line 631 of file VirtualFileSystem.h.