llvm::MemoryBuffer::getFileSlice

Map a subrange of the specified file as a MemoryBuffer.

Synopsis

Declared in <llvm/Support/MemoryBuffer.h>

static
ErrorOr<std::unique_ptr<MemoryBuffer>>
getFileSlice(
    Twine const& Filename,
    uint64_t MapSize,
    uint64_t Offset,
    bool IsVolatile = false,
    std::optional<Align> Alignment = std::nullopt);

Return Value

The mapped buffer on success, or an error on failure.

Parameters

NameDescription
FilenamePath of the file to map.
MapSizeNumber of bytes to map from the file.
OffsetByte offset into the file at which to begin the mapping.
IsVolatileSet to true to indicate that the contents of the file can change outside the user's control.
AlignmentSet to indicate that the buffer should be aligned to at least the specified alignment.