LLVM 20.0.0git
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
llvm::vfs::File Class Referenceabstract

Represents an open file. More...

#include "llvm/Support/VirtualFileSystem.h"

Public Member Functions

virtual ~File ()
 Destroy the file after closing it (if open).
 
virtual llvm::ErrorOr< Statusstatus ()=0
 Get the status of the file.
 
virtual llvm::ErrorOr< std::string > getName ()
 Get the name of the file.
 
virtual llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBuffer (const Twine &Name, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false)=0
 Get the contents of the file as a MemoryBuffer.
 
virtual std::error_code close ()=0
 Closes the file.
 

Static Public Member Functions

static ErrorOr< std::unique_ptr< File > > getWithPath (ErrorOr< std::unique_ptr< File > > Result, const Twine &P)
 

Protected Member Functions

virtual void setPath (const Twine &Path)
 

Detailed Description

Represents an open file.

Definition at line 111 of file VirtualFileSystem.h.

Constructor & Destructor Documentation

◆ ~File()

File::~File ( )
virtualdefault

Destroy the file after closing it (if open).

Sub-classes should generally call close() inside their destructors. We cannot do that from the base class, since close is virtual.

Member Function Documentation

◆ close()

virtual std::error_code llvm::vfs::File::close ( )
pure virtual

Closes the file.

◆ getBuffer()

virtual llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > llvm::vfs::File::getBuffer ( const Twine Name,
int64_t  FileSize = -1,
bool  RequiresNullTerminator = true,
bool  IsVolatile = false 
)
pure virtual

Get the contents of the file as a MemoryBuffer.

◆ getName()

virtual llvm::ErrorOr< std::string > llvm::vfs::File::getName ( )
inlinevirtual

Get the name of the file.

Definition at line 122 of file VirtualFileSystem.h.

References llvm::vfs::Status::getName(), status(), and llvm::StringRef::str().

◆ getWithPath()

ErrorOr< std::unique_ptr< File > > File::getWithPath ( ErrorOr< std::unique_ptr< File > >  Result,
const Twine P 
)
static

Definition at line 2526 of file VirtualFileSystem.cpp.

References F, Name, and P.

Referenced by llvm::vfs::RedirectingFileSystem::openFileForRead().

◆ setPath()

virtual void llvm::vfs::File::setPath ( const Twine Path)
inlineprotectedvirtual

Definition at line 143 of file VirtualFileSystem.h.

◆ status()

virtual llvm::ErrorOr< Status > llvm::vfs::File::status ( )
pure virtual

Get the status of the file.

Referenced by getName().


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