[#BloombergLP-bdls-FdStreamBuf_FileHandler]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdls.adoc[bdls]::FdStreamBuf&lowbar;FileHandler
:relfileprefix: ../../
:mrdocs:

Private helper that isolates file operations from `FdStreamBuf`&period;

== Synopsis

Declared in `&lt;bdls&lowbar;fdstreambuf&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class FdStreamBuf&lowbar;FileHandler;
----

== Description

This private helper class isolates direct operations on files from the `FdStreamBuf` class&semi; it is a thin wrapper around `FilesystemUtil`&period; One service this class provides is converting between an in&hyphen;process &grave; &grave; and its corresponding on&hyphen;file &grave;&bsol;r &grave; when writing to or reading from a Windows text file&period; 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`&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/2constructor.adoc[`FdStreamBuf&lowbar;FileHandler`]         [.small]#[constructor]#
| Create a file handler that is not associated with any file descriptor&period; Note that `isOpened` will be `false` on the newly created object&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/2destructor.adoc[`&#126;FdStreamBuf&lowbar;FileHandler`] [.small]#[destructor]#
| Destroy this file handler&period; If `willCloseOnReset` is `true`, close any file descriptor associated with this object&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/clear.adoc[`clear`] 
| Release any file descriptor associated with this file handler&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/fileDescriptor.adoc[`fileDescriptor`] 
| Return the file descriptor associated with this object, if `isOpened` is `true`, and &hyphen;1 otherwise&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/fileSize.adoc[`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&period;g&period;, a device or directory)&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/getOffset.adoc[`getOffset`] 
| Return the on&hyphen;disk size of the byte range `&lsqb;first, last)&rsqb;`&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/isInBinaryMode.adoc[`isInBinaryMode`] 
| Return `false` if on Windows and the file is opened in text mode, and `true` otherwise&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/isOpened.adoc[`isOpened`] 
| Return `true` if this file handler is currently associated with a file descriptor, and `false` otherwise&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/isRegularFile.adoc[`isRegularFile`] 
| Return whether this handler&apos;s file descriptor refers to a regular file&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/mmap.adoc[`mmap`] 
| Map a file section into read&hyphen;only memory&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/openMode.adoc[`openMode`] 
| Return the `ios&lowbar;base` mode bits for this file handler&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/read.adoc[`read`] 
| Read `numBytes` from the file descriptor into `buffer`&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/release.adoc[`release`] 
| Disassociate this file handler from its file descriptor without closing it&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/reset.adoc[`reset`] 
| Associate this object with the specified file descriptor&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/seek.adoc[`seek`] 
| Set the file position associated with this object according to the specified `offset` and `dir` behavior&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/setWillCloseOnReset.adoc[`setWillCloseOnReset`] 
| Set whether this handler closes its file descriptor on reset&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/unmap.adoc[`unmap`] 
| Unmap the memory range starting at `mappedMemory`&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/willCloseOnReset.adoc[`willCloseOnReset`] 
| Return whether the associated file descriptor will be closed on reset&period;
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/write.adoc[`write`] 
| Write `numBytes` from `buffer` to the file descriptor&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdls/FdStreamBuf_FileHandler/pageSize.adoc[`pageSize`] 
| Return the operating system&apos;s page size&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
