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

Synopsis

Declared in <bdls_filedescriptorguard.h>

struct FileDescriptorGuard;

Member Functions

Name

Description

FileDescriptorGuard [constructor]

Create a guard that manages the specified descriptor.

~FileDescriptorGuard [destructor]

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

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.

descriptor

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

release

Release the managed file descriptor without closing it.

Data Members

Name

Description

d_descriptor

File descriptor managed by this guard.

Created with MrDocs