LLVM API Documentation
#include <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... | |
error_code | commit (int64_t NewSmallerSize=-1) |
~FileOutputBuffer () | |
Static Public Member Functions | |
static error_code | create (StringRef FilePath, size_t Size, OwningPtr< FileOutputBuffer > &Result, unsigned Flags=0) |
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 33 of file FileOutputBuffer.h.
anonymous enum |
Enumerator | |
---|---|
F_executable |
Definition at line 36 of file FileOutputBuffer.h.
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 30 of file FileOutputBuffer.cpp.
References llvm::sys::fs::remove().
error_code llvm::FileOutputBuffer::commit | ( | int64_t | NewSmallerSize = -1 | ) |
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 90 of file FileOutputBuffer.cpp.
References llvm::sys::fs::rename(), and llvm::sys::fs::resize_file().
|
static |
Factory method to create an OutputBuffer object which manages a read/write buffer of the specified size. When committed, the buffer will be written to the file at the specified path.
Definition at line 35 of file FileOutputBuffer.cpp.
References llvm::sys::fs::all_exe, llvm::sys::fs::all_read, llvm::sys::fs::all_write, llvm::sys::fs::createUniqueFile(), F_executable, llvm::sys::fs::file_type::file_not_found, llvm::OwningPtr< T >::get(), llvm::make_error_code(), llvm::errc::operation_not_permitted, llvm::sys::fs::file_type::regular_file, llvm::sys::fs::remove(), llvm::OwningPtr< T >::reset(), llvm::sys::fs::status(), llvm::error_code::success(), llvm::OwningPtr< T >::take(), and llvm::sys::fs::file_status::type().
|
inline |
Returns a pointer to the end of the buffer.
Definition at line 53 of file FileOutputBuffer.h.
|
inline |
Returns size of the buffer.
Definition at line 58 of file FileOutputBuffer.h.
|
inline |
Returns a pointer to the start of the buffer.
Definition at line 48 of file FileOutputBuffer.h.
|
inline |
Returns path where file will show up if buffer is committed.
Definition at line 63 of file FileOutputBuffer.h.