Quick Links:

bal | bbl | bdl | bsl

Public Member Functions | Public Attributes

bdls::FileDescriptorGuard Struct Reference

#include <bdls_filedescriptorguard.h>

List of all members.

Public Member Functions

 FileDescriptorGuard (FilesystemUtil::FileDescriptor descriptor)
 ~FileDescriptorGuard ()
void closeAndRelease ()
FilesystemUtil::FileDescriptor release ()
FilesystemUtil::FileDescriptor descriptor () const

Public Attributes

FilesystemUtil::FileDescriptor d_descriptor

Detailed Description

This class implements a guard that conditionally closes an open file descriptor upon its destruction.

See Component bdls_filedescriptorguard


Constructor & Destructor Documentation

bdls::FileDescriptorGuard::FileDescriptorGuard ( FilesystemUtil::FileDescriptor  descriptor  )  [explicit]

Create a guard object that will manage the specified descriptor, closing it upon destruction (unless either realease or closeAndRelease has been called). It is permissible for descriptor to be FilesystemUtil::k_INVALID_FD, in which case the guard created will not manage anything.

bdls::FileDescriptorGuard::~FileDescriptorGuard (  ) 

If this guard object manages a file, close that file.


Member Function Documentation

void bdls::FileDescriptorGuard::closeAndRelease (  ) 

Close the file managed by this guard and release that file from management by this object. The behavior is undefined unless this object is managing a file.

FilesystemUtil::FileDescriptor bdls::FileDescriptorGuard::release (  ) 

Release the file from management by this object (without closing it) and return the formerly managed descriptor. The behavior is undefined unless this object is managing a file.

FilesystemUtil::FileDescriptor bdls::FileDescriptorGuard::descriptor (  )  const

If this guard is managing a file, return the file descriptor referring to that file, and return FilesystemUtil::k_INVALID_FD otherwise.


Member Data Documentation

FilesystemUtil::FileDescriptor bdls::FileDescriptorGuard::d_descriptor

handle for the


The documentation for this struct was generated from the following file: