class FileOutputBuffer

Declaration

class FileOutputBuffer { /* full declaration omitted */ };

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.

Declared at: llvm/include/llvm/Support/FileOutputBuffer.h:30

Member Variables

protected std::string FinalPath

Method Overview

Methods

FileOutputBuffer(llvm::StringRef Path)

Declared at: llvm/include/llvm/Support/FileOutputBuffer.h:82

Parameters

llvm::StringRef Path

virtual llvm::Error commit()

Description

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.

Declared at: llvm/include/llvm/Support/FileOutputBuffer.h:70

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

Description

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. When F_modify is specified and \p FilePath refers to an existing on-disk file \p Size may be set to -1, in which case the entire file is used. Otherwise, the file shrinks or grows as necessary based on the value of\p Size. It is an error to specify F_modify and Size=-1 if \p FilePath does not exist.

Declared at: llvm/include/llvm/Support/FileOutputBuffer.h:51

Parameters

llvm::StringRef FilePath
size_t Size
unsigned int Flags = 0

virtual void discard()

Description

This removes the temporary file (unless it already was committed) but keeps the memory mapping alive.

Declared at: llvm/include/llvm/Support/FileOutputBuffer.h:79

virtual uint8_t* getBufferEnd() const

Description

Returns a pointer to the end of the buffer.

Declared at: llvm/include/llvm/Support/FileOutputBuffer.h:57

virtual size_t getBufferSize() const

Description

Returns size of the buffer.

Declared at: llvm/include/llvm/Support/FileOutputBuffer.h:60

virtual uint8_t* getBufferStart() const

Description

Returns a pointer to the start of the buffer.

Declared at: llvm/include/llvm/Support/FileOutputBuffer.h:54

llvm::StringRef getPath() const

Description

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

Declared at: llvm/include/llvm/Support/FileOutputBuffer.h:63

virtual ~FileOutputBuffer()

Description

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.

Declared at: llvm/include/llvm/Support/FileOutputBuffer.h:75