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::isOpen() constnoexcept[¶]

Tests whether the file is open.

BLResult BLFile::open(
const char* fileName,
BLFileOpenFlags openFlags
)noexcept[¶]

Attempts to open a file specified by fileName with the given openFlags.

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 seekType.

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

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

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

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

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

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

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

Truncates the file to the given maximum size maxSize.

BLResult BLFile::getInfo(
BLFileInfo* infoOut
)noexcept[¶]

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

BLResult BLFile::getSize(
uint64_t* sizeOut
)noexcept[¶]

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