ot::io
class FileDescriptor
#include "ot/io/FileDescriptor.h"
An abstract base class representing open file handles.
It derives from ManagedObject and uses the standard OpenTop reference-counting scheme. By using ResourceDescriptors, OpenTop is able to share file handles between multiple objects, preventing the file from being closed until all references to the FileDescriptor have been removed.
A FileDescriptor is associated with a FileSystem object when it is created. When the file needs to be closed, the FileSystem associated with the file performs the action.
Method Summary
|
virtual void |
close()
Closes the file. |
static RefPtr< FileDescriptor > |
Err()
Returns a FileDescriptor for the standard Console stream 'stderr'. |
RefPtr< FileSystem > |
getFileSystem() const
Returns the FileSystem associated with this FileDescriptor. |
static RefPtr< FileDescriptor > |
In()
Returns a FileDescriptor for the standard Console stream 'stdin'. |
static RefPtr< FileDescriptor > |
Out()
Returns a FileDescriptor for the standard Console stream 'stdout'. |
Constructor/Destructor Detail |
FileDescriptor
FileDescriptor(const FileSystem* pFS,
bool bAutoClose)
-
Constructs a FileDescriptor.
- Parameters:
pFS
-
the FileSystem associated with the open file designated by this FileDescriptor.
bAutoClose
-
true if the file should be closed when this FileDescriptor is destroyed
- Exceptions:
NullPointerException
-
if pFS is null
~FileDescriptor
virtual ~FileDescriptor()
-
Destructor.
This method does nothing, but derived classes are expected to call getAutoClose() and close the related resource if it returns true.
To indicate that they have performed the required task, all derived class destructors should call setAutoClose(false) before exiting.
close
virtual void close()
-
Closes the file.
Err
static RefPtr< FileDescriptor > Err()
-
Returns a FileDescriptor for the standard Console stream 'stderr'.
FileDescriptors for standard Console streams are not auto-close descriptors which means that the stream is (correctly) left open when then the returned FileDescriptor is destroyed.
getFileSystem
RefPtr< FileSystem > getFileSystem() const
-
Returns the FileSystem associated with this FileDescriptor.
In
static RefPtr< FileDescriptor > In()
-
Returns a FileDescriptor for the standard Console stream 'stdin'.
FileDescriptors for standard Console streams are not auto-close descriptors which means that the stream is (correctly) left open when then the returned FileDescriptor is destroyed.
Out
static RefPtr< FileDescriptor > Out()
-
Returns a FileDescriptor for the standard Console stream 'stdout'.
FileDescriptors for standard Console streams are not auto-close descriptors which means that the stream is (correctly) left open when then the returned FileDescriptor is destroyed.
Found a bug or missing feature? Please email us at support@elcel.com