This class provides a low‐level file utility functions for Resolver<Elf>. This class contains the file descriptor of current object file. Note that the file is opened readonly, and all reads specify the offset, so the offset of the file descriptor is not considered part of the state of this object.

Synopsis

Declared in <balst_resolver_filehelper.h>

class Resolver_FileHelper;

Type Aliases

Name

Offset

Enums

Name

Description

Unnamed enum

length in bytes of d_buffer_p; 32K minus a little so we don't waste a page

Member Functions

Name

Description

Resolver_FileHelper [constructor]

Create a file helper object in an invalid state.

fileSize

The size of the open file or mapped segment.

loadString

Read a null‐terminated string from offset in the file or mapped file into writeSpan and return a string_view to the string. If we run out of room in writeSpan, reach end of file, or reach end of mapped area, return a non‐null‐terminated string_view. The behavior is undefined unless !outSpan.empty() and offset >= 0. Note that the returned string_view never contains the terminating 0.

openFile

Open the file referred to by the specified fileName for read‐only access, and if it opens successfully, set d_reader to a FileReader type and bind it to the opened file. Return 0 on success and a non‐zero value otherwise.

openMappedFile

Open this object to access the memory referred to by the specified mappedFile as if it were a disk file. Return 0 on success and a non‐zero value otherwise.

readBytes

Read into the specified outSpan up to the specified outSpan.size() of data starting at the specified offset in the current ELF file. Return a span referring to the section of outSpan containing, which can be empty. The behavior is undefined unless !outSpan.empty() and offset >= 0.

readExact

Read into the specified outSpan exactly the specified outSpan.size() bytes of data starting at the specified offset in the current ELF file. Return 0 on success, or a negative value otherwise. The behavior is undefined unless !outSpan.empty() and offset >= 0.

Created with MrDocs