Private helper that isolates file operations from FdStreamBuf.

Synopsis

Declared in <bdls_fdstreambuf.h>

class FdStreamBuf_FileHandler;

Description

This private helper class isolates direct operations on files from the FdStreamBuf class; it is a thin wrapper around FilesystemUtil. One service this class provides is converting between an in‐process ` ` and its corresponding on‐file `\r ` when writing to or reading from a Windows text file. On reset an object of this type is associated with a supplied file descriptor, after which it can do simple operations on that file descriptor in the service of a FdStreamBuf.

Member Functions

Name

Description

FdStreamBuf_FileHandler [constructor]

Create a file handler that is not associated with any file descriptor. Note that isOpened will be false on the newly created object.

~FdStreamBuf_FileHandler [destructor]

Destroy this file handler. If willCloseOnReset is true, close any file descriptor associated with this object.

clear

Release any file descriptor associated with this file handler.

fileDescriptor

Return the file descriptor associated with this object, if isOpened is true, and ‐1 otherwise.

fileSize

Return the size of the file associated with this file handler, or 0 if it is associated with a device other than a regular file (e.g., a device or directory).

getOffset

Return the on‐disk size of the byte range [first, last)].

isInBinaryMode

Return false if on Windows and the file is opened in text mode, and true otherwise.

isOpened

Return true if this file handler is currently associated with a file descriptor, and false otherwise.

isRegularFile

Return whether this handler's file descriptor refers to a regular file.

mmap

Map a file section into read‐only memory.

openMode

Return the ios_base mode bits for this file handler.

read

Read numBytes from the file descriptor into buffer.

release

Disassociate this file handler from its file descriptor without closing it.

reset

Associate this object with the specified file descriptor.

seek

Set the file position associated with this object according to the specified offset and dir behavior.

setWillCloseOnReset

Set whether this handler closes its file descriptor on reset.

unmap

Unmap the memory range starting at mappedMemory.

willCloseOnReset

Return whether the associated file descriptor will be closed on reset.

write

Write numBytes from buffer to the file descriptor.

Static Member Functions

Name

Description

pageSize

Return the operating system's page size.

Created with MrDocs