LLVM  6.0.0svn
Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::FileOutputBuffer Class Reference

FileOutputBuffer - This interface provides simple way to create an in-memory buffer which will be written to a file. More...

#include "llvm/Support/FileOutputBuffer.h"

Public Types

enum  { F_executable = 1 }
 

Public Member Functions

uint8_t * getBufferStart ()
 Returns a pointer to the start of the buffer. More...
 
uint8_t * getBufferEnd ()
 Returns a pointer to the end of the buffer. More...
 
size_t getBufferSize () const
 Returns size of the buffer. More...
 
StringRef getPath () const
 Returns path where file will show up if buffer is committed. More...
 
std::error_code commit ()
 Flushes the content of the buffer to its file and deallocates the buffer. More...
 
 ~FileOutputBuffer ()
 If this object was previously committed, the destructor just deletes this object. More...
 

Static Public Member Functions

static ErrorOr< std::unique_ptr< FileOutputBuffer > > create (StringRef FilePath, size_t Size, unsigned Flags=0)
 Factory method to create an OutputBuffer object which manages a read/write buffer of the specified size. More...
 

Detailed Description

FileOutputBuffer - This interface provides simple way to create an in-memory buffer which will be written to a file.

During the lifetime of these objects, the content or existence of the specified file is undefined. That is, creating an OutputBuffer for a file may immediately remove the file. If the FileOutputBuffer is committed, the target file's content will become the buffer content at the time of the commit. If the FileOutputBuffer is not committed, the file will be deleted in the FileOutputBuffer destructor.

Definition at line 31 of file FileOutputBuffer.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
F_executable 

Definition at line 34 of file FileOutputBuffer.h.

Constructor & Destructor Documentation

◆ ~FileOutputBuffer()

llvm::FileOutputBuffer::~FileOutputBuffer ( )

If this object was previously committed, the destructor just deletes this object.

If this object was not committed, the destructor deallocates the buffer and the target file is never written.

Definition at line 37 of file FileOutputBuffer.cpp.

References llvm::sys::fs::remove().

Referenced by getPath().

Member Function Documentation

◆ commit()

std::error_code llvm::FileOutputBuffer::commit ( )

Flushes the content of the buffer to its file and deallocates the buffer.

If commit() is not called before this object's destructor is called, the file is deleted in the destructor. The optional parameter is used if it turns out you want the file size to be smaller than initially requested.

Definition at line 115 of file FileOutputBuffer.cpp.

References llvm::sys::fs::copy_file(), llvm::sys::DontRemoveFileOnSignal(), llvm::sys::fs::remove(), and rename().

Referenced by getPath().

◆ create()

ErrorOr< std::unique_ptr< FileOutputBuffer > > llvm::FileOutputBuffer::create ( StringRef  FilePath,
size_t  Size,
unsigned  Flags = 0 
)
static

◆ getBufferEnd()

uint8_t* llvm::FileOutputBuffer::getBufferEnd ( )
inline

Returns a pointer to the end of the buffer.

Definition at line 50 of file FileOutputBuffer.h.

◆ getBufferSize()

size_t llvm::FileOutputBuffer::getBufferSize ( ) const
inline

Returns size of the buffer.

Definition at line 55 of file FileOutputBuffer.h.

◆ getBufferStart()

uint8_t* llvm::FileOutputBuffer::getBufferStart ( )
inline

Returns a pointer to the start of the buffer.

Definition at line 45 of file FileOutputBuffer.h.

◆ getPath()

StringRef llvm::FileOutputBuffer::getPath ( ) const
inline

Returns path where file will show up if buffer is committed.

Definition at line 60 of file FileOutputBuffer.h.

References commit(), and ~FileOutputBuffer().


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