LLVM  15.0.0git
Public Types | Public Member Functions | Protected Member Functions | List of all members
llvm::vfs::FileSystem Class Referenceabstract

The virtual file system interface. More...

#include "llvm/Support/VirtualFileSystem.h"

Inheritance diagram for llvm::vfs::FileSystem:
Inheritance graph
[legend]
Collaboration diagram for llvm::vfs::FileSystem:
Collaboration graph
[legend]

Public Types

enum  PrintType { PrintType::Summary, PrintType::Contents, PrintType::RecursiveContents }
 

Public Member Functions

virtual ~FileSystem ()
 
virtual llvm::ErrorOr< Statusstatus (const Twine &Path)=0
 Get the status of the entry at Path, if one exists. More...
 
virtual llvm::ErrorOr< std::unique_ptr< File > > openFileForRead (const Twine &Path)=0
 Get a File object for the file at Path, if one exists. More...
 
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...
 
virtual directory_iterator dir_begin (const Twine &Dir, std::error_code &EC)=0
 Get a directory_iterator for Dir. More...
 
virtual std::error_code setCurrentWorkingDirectory (const Twine &Path)=0
 Set the working directory. More...
 
virtual llvm::ErrorOr< std::string > getCurrentWorkingDirectory () const =0
 Get the working directory of this file system. More...
 
virtual std::error_code getRealPath (const Twine &Path, SmallVectorImpl< char > &Output) const
 Gets real path of Path e.g. More...
 
bool exists (const Twine &Path)
 Check whether a file exists. Provided for convenience. More...
 
virtual std::error_code isLocal (const Twine &Path, bool &Result)
 Is the file mounted on a local filesystem? More...
 
virtual std::error_code makeAbsolute (SmallVectorImpl< char > &Path) const
 Make Path an absolute path. More...
 
void print (raw_ostream &OS, PrintType Type=PrintType::Contents, unsigned IndentLevel=0) const
 
LLVM_DUMP_METHOD void dump () const
 
- Public Member Functions inherited from llvm::ThreadSafeRefCountedBase< FileSystem >
void Retain () const
 
void Release () const
 

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 &)
 
ThreadSafeRefCountedBaseoperator= (const ThreadSafeRefCountedBase &)=delete
 
 ~ThreadSafeRefCountedBase ()
 

Detailed Description

The virtual file system interface.

Definition at line 267 of file VirtualFileSystem.h.

Member Enumeration Documentation

◆ PrintType

Enumerator
Summary 
Contents 
RecursiveContents 

Definition at line 321 of file VirtualFileSystem.h.

Constructor & Destructor Documentation

◆ ~FileSystem()

FileSystem::~FileSystem ( )
virtualdefault

Member Function Documentation

◆ dir_begin()

virtual directory_iterator llvm::vfs::FileSystem::dir_begin ( const Twine Dir,
std::error_code &  EC 
)
pure virtual

◆ dump()

void FileSystem::dump ( ) const

Definition at line 155 of file VirtualFileSystem.cpp.

References llvm::dbgs(), print(), and RecursiveContents.

◆ exists()

bool FileSystem::exists ( const Twine Path)

◆ getBufferForFile()

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, llvm::AMDGPU::HSAMD::Kernel::Arg::Key::IsVolatile, and openFileForRead().

Referenced by llvm::SpecialCaseList::createInternal().

◆ getCurrentWorkingDirectory()

virtual llvm::ErrorOr<std::string> llvm::vfs::FileSystem::getCurrentWorkingDirectory ( ) const
pure virtual

◆ getRealPath()

std::error_code FileSystem::getRealPath ( const Twine Path,
SmallVectorImpl< char > &  Output 
) const
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, llvm::vfs::InMemoryFileSystem, llvm::vfs::ProxyFileSystem, llvm::vfs::OverlayFileSystem, and llvm::FileCollectorFileSystem.

Definition at line 140 of file VirtualFileSystem.cpp.

References llvm::operation_not_permitted.

◆ isLocal()

std::error_code FileSystem::isLocal ( const Twine Path,
bool &  Result 
)
virtual

◆ makeAbsolute()

std::error_code FileSystem::makeAbsolute ( SmallVectorImpl< char > &  Path) const
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

Parameters
PathA path that is modified to be an absolute path.
Returns
success if path has been made absolute, otherwise a platform-specific error_code.

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::InMemoryFileSystem::getRealPath(), and llvm::vfs::InMemoryFileSystem::setCurrentWorkingDirectory().

◆ openFileForRead()

virtual llvm::ErrorOr<std::unique_ptr<File> > llvm::vfs::FileSystem::openFileForRead ( const Twine Path)
pure virtual

◆ print()

void llvm::vfs::FileSystem::print ( raw_ostream OS,
PrintType  Type = PrintType::Contents,
unsigned  IndentLevel = 0 
) const
inline

Definition at line 322 of file VirtualFileSystem.h.

References printImpl().

Referenced by dump().

◆ printImpl()

virtual void llvm::vfs::FileSystem::printImpl ( raw_ostream OS,
PrintType  Type,
unsigned  IndentLevel 
) const
inlineprotectedvirtual

◆ printIndent()

void llvm::vfs::FileSystem::printIndent ( raw_ostream OS,
unsigned  IndentLevel 
) const
inlineprotected

◆ setCurrentWorkingDirectory()

virtual std::error_code llvm::vfs::FileSystem::setCurrentWorkingDirectory ( const Twine Path)
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::vfs::RedirectingFileSystem, llvm::vfs::InMemoryFileSystem, llvm::vfs::ProxyFileSystem, llvm::vfs::OverlayFileSystem, and llvm::FileCollectorFileSystem.

◆ status()

virtual llvm::ErrorOr<Status> llvm::vfs::FileSystem::status ( const Twine Path)
pure virtual

The documentation for this class was generated from the following files: