[#BloombergLP-bdls-FileDescriptorGuard]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdls.adoc[bdls]::FileDescriptorGuard
:relfileprefix: ../../
:mrdocs:

This class implements a guard that conditionally closes an open file descriptor upon its destruction&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
struct FileDescriptorGuard;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdls/FileDescriptorGuard/2constructor.adoc[`FileDescriptorGuard`]         [.small]#[constructor]#
| Create a guard that manages the specified `descriptor`&period;
| xref:BloombergLP/bdls/FileDescriptorGuard/2destructor.adoc[`&#126;FileDescriptorGuard`] [.small]#[destructor]#
| If this guard object manages a file, close that file&period;
| xref:BloombergLP/bdls/FileDescriptorGuard/closeAndRelease.adoc[`closeAndRelease`] 
| Close the file managed by this guard and release that file from management by this object&period; The behavior is undefined unless this object is managing a file&period;
| xref:BloombergLP/bdls/FileDescriptorGuard/descriptor.adoc[`descriptor`] 
| If this guard is managing a file, return the file descriptor referring to that file, and return `FilesystemUtil&colon;&colon;k&lowbar;INVALID&lowbar;FD` otherwise&period;
| xref:BloombergLP/bdls/FileDescriptorGuard/release.adoc[`release`] 
| Release the managed file descriptor without closing it&period;
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdls/FileDescriptorGuard/d_descriptor.adoc[`d&lowbar;descriptor`] 
| File descriptor managed by this guard&period;
|===



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