LLVM 22.0.0git
Public Types | Public Member Functions | Static Public Attributes | 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:
[フレーム]
[legend]

Public Types

Public Member Functions

  ~FileSystem () override
virtual llvm::ErrorOr< Statusstatus (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 text file at Path, if one exists.
virtual llvm::ErrorOr< std::unique_ptr< File > >  openFileForReadBinary (const Twine &Path)
  Get a File object for the binary 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, bool IsText=true)
  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.
virtual void  visitChildFileSystems (VisitCallbackTy Callback)
void  visit (VisitCallbackTy Callback)
Public Member Functions inherited from llvm::ThreadSafeRefCountedBase< FileSystem >
void  Retain () const
void  Release () const
Public Member Functions inherited from llvm::RTTIExtends< FileSystem, RTTIRoot >
const void *  dynamicClassID () const override
bool  isA () const
  Check whether this instance is a subclass of QueryT.
Public Member Functions inherited from llvm::RTTIRoot
virtual  ~RTTIRoot ()=default
virtual bool  isA (const void *const ClassID) const
  Returns true if this class's ID matches the given class ID.

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 >

Additional Inherited Members

Static Public Member Functions inherited from llvm::RTTIExtends< FileSystem, RTTIRoot >
static const void *  classID ()
static bool  classof (const T *R)
Static Public Member Functions inherited from llvm::RTTIRoot
static const void *  classID ()
  Returns the class ID for this type.

Detailed Description

The virtual file system interface.

Definition at line 267 of file VirtualFileSystem.h.

Member Typedef Documentation

◆  VisitCallbackTy

Definition at line 347 of file VirtualFileSystem.h.

Member Enumeration Documentation

◆  PrintType

Enumerator
Summary 
Contents 
RecursiveContents 

Definition at line 341 of file VirtualFileSystem.h.

Constructor & Destructor Documentation

◆  ~FileSystem()

FileSystem::~FileSystem ( )
overridedefault

Member Function Documentation

◆  dir_begin()

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

Get a directory_iterator for Dir.

Note
The 'end' iterator is directory_iterator().

Implemented in llvm::FileCollectorFileSystem, and llvm::vfs::RedirectingFileSystem.

Referenced by getHighestNumericTupleInDirectory().

◆  dump()

void FileSystem::dump ( ) const

Definition at line 165 of file VirtualFileSystem.cpp.

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

◆  equivalent()

llvm::ErrorOr< bool > FileSystem::equivalent ( const Twine & A,
const Twine & B )
Returns
true if A and B represent the same file, or an error or false if they do not.

Definition at line 154 of file VirtualFileSystem.cpp.

References A(), B(), and status().

Referenced by getCurrentWorkingDirectory().

◆  exists()

bool FileSystem::exists ( const Twine & Path )
virtual

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(), getCurrentWorkingDirectory(), getFilename(), llvm::getWindowsSDKDir(), and llvm::useUniversalCRT().

◆  getBufferForFile()

ErrorOr< std::unique_ptr< MemoryBuffer > > FileSystem::getBufferForFile ( const Twine & Name,
int64_t FileSize = -1,
bool RequiresNullTerminator = true,
bool IsVolatile = false,
bool IsText = true )

This is a convenience method that opens a file, gets its content and then closes the file.

The IsText parameter is used to distinguish whether the file should be opened as a binary or text file.

Definition at line 118 of file VirtualFileSystem.cpp.

References F, openFileForRead(), and openFileForReadBinary().

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

◆  getCurrentWorkingDirectory()

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

Get the working directory of this file system.

Implemented in llvm::FileCollectorFileSystem, and llvm::vfs::RedirectingFileSystem.

References A(), B(), equivalent(), exists(), getRealPath(), and isLocal().

Referenced by makeAbsolute().

◆  getRealPath()

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

Definition at line 140 of file VirtualFileSystem.cpp.

References llvm::operation_not_permitted.

Referenced by getCurrentWorkingDirectory().

◆  isLocal()

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

Is the file mounted on a local filesystem?

Reimplemented in llvm::FileCollectorFileSystem, and llvm::vfs::RedirectingFileSystem.

Definition at line 145 of file VirtualFileSystem.cpp.

References llvm::operation_not_permitted.

Referenced by getCurrentWorkingDirectory().

◆  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
Path A 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::path::make_absolute().

Referenced by makeAbsolute().

◆  openFileForRead()

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

Get a File object for the text file at Path, if one exists.

Implemented in llvm::FileCollectorFileSystem, and llvm::vfs::RedirectingFileSystem.

Referenced by getBufferForFile(), and openFileForReadBinary().

◆  openFileForReadBinary()

virtual llvm::ErrorOr< std::unique_ptr< File > > llvm::vfs::FileSystem::openFileForReadBinary ( const Twine & Path )
inlinevirtual

Get a File object for the binary file at Path, if one exists.

Some non-ascii based file systems perform encoding conversions when reading as a text file, and this function should be used if a file's bytes should be read as-is. On most filesystems, this is the same behaviour as openFileForRead.

Definition at line 286 of file VirtualFileSystem.h.

References openFileForRead().

Referenced by getBufferForFile().

◆  print()

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

Definition at line 342 of file VirtualFileSystem.h.

References Contents, and printImpl().

Referenced by dump().

◆  printImpl()

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

Reimplemented in llvm::vfs::RedirectingFileSystem.

Definition at line 359 of file VirtualFileSystem.h.

References printIndent().

◆  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::FileCollectorFileSystem, and llvm::vfs::RedirectingFileSystem.

◆  status()

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

Get the status of the entry at Path, if one exists.

Implemented in llvm::FileCollectorFileSystem, and llvm::vfs::RedirectingFileSystem.

Referenced by equivalent(), exists(), llvm::findVCToolChainViaSetupConfig(), and getHighestNumericTupleInDirectory().

◆  visit()

void llvm::vfs::FileSystem::visit ( VisitCallbackTy Callback )
inline

Definition at line 349 of file VirtualFileSystem.h.

References visitChildFileSystems().

◆  visitChildFileSystems()

virtual void llvm::vfs::FileSystem::visitChildFileSystems ( VisitCallbackTy Callback )
inlinevirtual

Reimplemented in llvm::vfs::RedirectingFileSystem.

Definition at line 348 of file VirtualFileSystem.h.

Referenced by visit().

Member Data Documentation

◆  ID

const char FileSystem::ID = 0
static

Definition at line 270 of file VirtualFileSystem.h.


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

Generated on for LLVM by doxygen 1.14.0

AltStyle によって変換されたページ (->オリジナル) /