IndexFilesystemBLFile

BLFile Class Referencefinal [¶]

A thin abstraction over a native OS file IO [C++ API].

A thin wrapper around a native OS file support. The file handle is always intptr_t and it refers to either a file descriptor on POSIX targets and file handle on Windows targets.

Member Functions

Construction & Destruction
Common Functionality
Interface

Additional Inherited Members

Public Attributes inherited from BLFileCore

BLFile::BLFile()noexcept[1/3][¶]

Creates an empty file instance, which doesn't represent any open file.

Note

The internal file handle of non-opened files is set to -1.

BLFile::BLFile(
BLFile&& other
)noexcept[2/3][¶]

Move constructor - copies file descriptor from other to this instance and resets other to a default constructed state.

BLFile::BLFile(
intptr_t handle
)explicitnoexcept[3/3][¶]

Creates a file instance from an existing file handle, which either represents a file descriptor or Windows HANDLE (if compiled for Windows platform).

BLFile::~BLFile()noexcept[¶]

Destroys this file instance - closes the file descriptor or handle when it's referencing an open file.

bool BLFile::is_open() constnoexcept[¶]

Tests whether the file is open.

BLResult BLFile::open(
const char* file_name,
)noexcept[¶]

Attempts to open a file specified by file_name with the given open_flags.

BLResult BLFile::close()noexcept[¶]

Closes the file (if open) and sets the file handle to -1.

BLResult BLFile::seek(
int64_t offset,
)noexcept[1/2][¶]

Sets the file position of the file to the given offset by using the specified seek_type.

BLResult BLFile::seek(
int64_t offset,
BLFileSeekType seek_type,
int64_t* position_out
)noexcept[2/2][¶]

Sets the file position of the file to the given offset by using the specified seek_type and writes the new position into position_out output parameter.

BLResult BLFile::read(
void* buffer,
size_t n,
size_t* bytes_read_out
)noexcept[¶]

Reads n bytes from the file into the given buffer and stores the number of bytes actually read into the bytes_read_out output parameter.

BLResult BLFile::write(
const void* buffer,
size_t n,
size_t* bytes_written_out
)noexcept[¶]

Writes n bytes to the file from the given buffer and stores the number of bytes actually written into the bytes_read_out output parameter.

BLResult BLFile::truncate(
int64_t max_size
)noexcept[¶]

Truncates the file to the given maximum size max_size.

BLResult BLFile::get_info(
BLFileInfo* info_out
)noexcept[¶]

Queries an information of the file and stores it to info_out.

BLResult BLFile::get_size(
uint64_t* size_out
)noexcept[¶]

Queries a size of the file and stores it to size_out.