LLVM 20.0.0git
|
The virtual file system interface. More...
#include "llvm/Support/VirtualFileSystem.h"
Public Types | |
enum class | PrintType { Summary , Contents , RecursiveContents } |
using | VisitCallbackTy = llvm::function_ref< void(FileSystem &)> |
Public Member Functions | |
virtual | ~FileSystem () |
virtual llvm::ErrorOr< Status > | status (const Twine &Path)=0 |
Get the status of the entry at Path , if one exists. | |
virtual llvm::ErrorOr< std::unique_ptr< File > > | openFileForRead (const Twine &Path)=0 |
Get a File object for the file at Path , if one exists. | |
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. | |
virtual directory_iterator | dir_begin (const Twine &Dir, std::error_code &EC)=0 |
Get a directory_iterator for Dir . | |
virtual std::error_code | setCurrentWorkingDirectory (const Twine &Path)=0 |
Set the working directory. | |
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) |
Gets real path of Path e.g. | |
virtual bool | exists (const Twine &Path) |
Check whether Path exists. | |
virtual std::error_code | isLocal (const Twine &Path, bool &Result) |
Is the file mounted on a local filesystem? | |
virtual std::error_code | makeAbsolute (SmallVectorImpl< char > &Path) const |
Make Path an absolute path. | |
llvm::ErrorOr< bool > | equivalent (const Twine &A, const Twine &B) |
void | print (raw_ostream &OS, PrintType Type=PrintType::Contents, unsigned IndentLevel=0) const |
virtual void | visitChildFileSystems (VisitCallbackTy Callback) |
void | visit (VisitCallbackTy Callback) |
LLVM_DUMP_METHOD void | dump () const |
Public Member Functions inherited from llvm::ThreadSafeRefCountedBase< FileSystem > | |
unsigned | UseCount () const |
void | Retain () const |
void | Release () const |
Public Member Functions inherited from llvm::RTTIExtends< FileSystem, RTTIRoot > | |
const void * | dynamicClassID () const override |
bool | isA (const void *const ClassID) const override |
Public Member Functions inherited from llvm::RTTIRoot | |
virtual | ~RTTIRoot ()=default |
virtual const void * | dynamicClassID () const =0 |
Returns the class ID for the dynamic type of this RTTIRoot instance. | |
virtual bool | isA (const void *const ClassID) const |
Returns true if this class's ID matches the given class ID. | |
template<typename QueryT > | |
bool | isA () const |
Check whether this instance is a subclass of QueryT. | |
Static Public Attributes | |
static const char | ID = 0 |
Protected Member Functions | |
virtual void | printImpl (raw_ostream &OS, PrintType Type, unsigned IndentLevel) const |
void | printIndent (raw_ostream &OS, unsigned IndentLevel) const |
Protected Member Functions inherited from llvm::ThreadSafeRefCountedBase< FileSystem > | |
ThreadSafeRefCountedBase ()=default | |
ThreadSafeRefCountedBase (const ThreadSafeRefCountedBase &) | |
ThreadSafeRefCountedBase & | operator= (const ThreadSafeRefCountedBase &)=delete |
~ThreadSafeRefCountedBase () | |
Additional Inherited Members | |
Static Public Member Functions inherited from llvm::RTTIExtends< FileSystem, RTTIRoot > | |
static const void * | classID () |
static bool | classof (const RTTIRoot *R) |
Static Public Member Functions inherited from llvm::RTTIRoot | |
static const void * | classID () |
Returns the class ID for this type. | |
The virtual file system interface.
Definition at line 265 of file VirtualFileSystem.h.
using llvm::vfs::FileSystem::VisitCallbackTy = llvm::function_ref<void(FileSystem &)> |
Definition at line 332 of file VirtualFileSystem.h.
|
strong |
Enumerator | |
---|---|
Summary | |
Contents | |
RecursiveContents |
Definition at line 326 of file VirtualFileSystem.h.
|
virtualdefault |
|
pure virtual |
Get a directory_iterator for Dir
.
Implemented in llvm::FileCollectorFileSystem, and llvm::vfs::RedirectingFileSystem.
Referenced by getHighestNumericTupleInDirectory().
void FileSystem::dump | ( | ) | const |
Definition at line 165 of file VirtualFileSystem.cpp.
References llvm::dbgs(), print(), and RecursiveContents.
A
and B
represent the same file, or an error or false if they do not. Definition at line 154 of file VirtualFileSystem.cpp.
Check whether Path
exists.
By default this uses status()
, but filesystems may provide a more efficient implementation if available.
Reimplemented in llvm::vfs::RedirectingFileSystem.
Definition at line 149 of file VirtualFileSystem.cpp.
References llvm::vfs::Status::exists(), and status().
Referenced by llvm::findVCToolChainViaEnvironment(), llvm::getWindowsSDKDir(), and llvm::useUniversalCRT().
ErrorOr< std::unique_ptr< MemoryBuffer > > FileSystem::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.
Definition at line 119 of file VirtualFileSystem.cpp.
References F, Name, and openFileForRead().
Referenced by llvm::SpecialCaseList::createInternal().
|
pure virtual |
Get the working directory of this file system.
Implemented in llvm::vfs::RedirectingFileSystem, and llvm::FileCollectorFileSystem.
Referenced by llvm::cl::ExpansionContext::expandResponseFiles(), and makeAbsolute().
|
virtual |
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 in llvm::vfs::RedirectingFileSystem, and llvm::FileCollectorFileSystem.
Definition at line 140 of file VirtualFileSystem.cpp.
References llvm::operation_not_permitted.
Is the file mounted on a local filesystem?
Reimplemented in llvm::vfs::RedirectingFileSystem, and llvm::FileCollectorFileSystem.
Definition at line 145 of file VirtualFileSystem.cpp.
References llvm::operation_not_permitted.
|
virtual |
Make Path an absolute path.
Makes Path absolute using the current directory if it is not already. An empty Path will result in the current directory.
/absolute/path => /absolute/path relative/../path => <current-directory>/relative/../path
Path | A path that is modified to be an absolute path. |
Reimplemented in llvm::vfs::RedirectingFileSystem.
Definition at line 128 of file VirtualFileSystem.cpp.
References getCurrentWorkingDirectory(), llvm::sys::path::is_absolute(), and llvm::sys::fs::make_absolute().
Referenced by llvm::vfs::RedirectingFileSystem::create(), llvm::cl::ExpansionContext::findConfigFile(), and llvm::cl::ExpansionContext::readConfigFile().
|
pure virtual |
Get a File
object for the file at Path
, if one exists.
Implemented in llvm::vfs::RedirectingFileSystem, and llvm::FileCollectorFileSystem.
Referenced by getBufferForFile().
|
inline |
Definition at line 327 of file VirtualFileSystem.h.
References OS, and printImpl().
Referenced by dump().
|
inlineprotectedvirtual |
Reimplemented in llvm::vfs::RedirectingFileSystem.
Definition at line 344 of file VirtualFileSystem.h.
References OS, and printIndent().
Referenced by print().
|
inlineprotected |
Definition at line 350 of file VirtualFileSystem.h.
References OS.
Referenced by llvm::vfs::RedirectingFileSystem::printEntry(), printImpl(), and llvm::vfs::RedirectingFileSystem::printImpl().
|
pure virtual |
Set the working directory.
This will affect all following operations on this file system and may propagate down for nested file systems.
Implemented in llvm::FileCollectorFileSystem, and llvm::vfs::RedirectingFileSystem.
|
pure virtual |
Get the status of the entry at Path
, if one exists.
Implemented in llvm::vfs::RedirectingFileSystem, and llvm::FileCollectorFileSystem.
Referenced by equivalent(), exists(), llvm::cl::ExpansionContext::expandResponseFiles(), llvm::cl::ExpansionContext::findConfigFile(), llvm::findVCToolChainViaSetupConfig(), and getHighestNumericTupleInDirectory().
|
inline |
Definition at line 334 of file VirtualFileSystem.h.
References visitChildFileSystems().
|
inlinevirtual |
Reimplemented in llvm::vfs::RedirectingFileSystem.
Definition at line 333 of file VirtualFileSystem.h.
Referenced by visit().
Definition at line 268 of file VirtualFileSystem.h.