LLVM  14.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). More...
 
virtual llvm::ErrorOr< Statusstatus ()=0
 Get the status of the file. More...
 
virtual llvm::ErrorOr< std::string > getName ()
 Get the name of the file. More...
 
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. More...
 
virtual std::error_code close ()=0
 Closes the file. More...
 

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 99 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 110 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 2076 of file VirtualFileSystem.cpp.

References F, move, and P.

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

◆ setPath()

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

Definition at line 131 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: