Fennel: RandomAccessFileDevice Class Reference (original) (raw)
RandomAccessFileDevice is an implementation of RandomAccessDevice in terms of a FileDevice. More...
#include <[RandomAccessFileDevice.h](RandomAccessFileDevice%5F8h-source.html)>
Inheritance diagram for RandomAccessFileDevice:

| Public Member Functions | |
|---|---|
| RandomAccessFileDevice (std::string filename, DeviceMode mode, FileSize initialSize) | |
| Opens a file device for random access, specifying an initial size on creation. | |
| RandomAccessFileDevice (std::string filename, DeviceMode mode) | |
| Opens a file device for random access. | |
| virtual FileSize | getSizeInBytes () |
| virtual void | setSizeInBytes (FileSize cbNew) |
| virtual void | transfer (RandomAccessRequest const &request) |
| Executes a synchronous transfer request for a single random access binding. | |
| virtual void | prepareTransfer (RandomAccessRequest &request) |
| Prepares for an asynchronous transfer by associating required information about this device (e.g. | |
| virtual void | flush () |
| virtual int | getHandle () |
| **Returns:**OS-defined handle representing this device, or -1 for none | |
| void | close () |
| bool | isOpen () const |
| **Returns:**whether the device file is currently open | |
| Protected Attributes | |
| FileSize | cbFile |
| current file size in bytes | |
| int | handle |
| the opened OS file | |
| DeviceMode | mode |
| mode in which file was opened | |
| std::string | filename |
| path to file in file system | |
| StrictMutex | mutex |
| On Cygwin, there's no pread/pwrite, so all I/O has to be synchronized per device. |
Detailed Description
RandomAccessFileDevice is an implementation of RandomAccessDevice in terms of a FileDevice.
Definition at line 38 of file RandomAccessFileDevice.h.
Constructor & Destructor Documentation
| RandomAccessFileDevice::RandomAccessFileDevice | ( | std::string | filename, |
|---|---|---|---|
| DeviceMode | mode, | ||
| FileSize | initialSize | ||
| ) | [explicit] |
Opens a file device for random access, specifying an initial size on creation.
Parameters:
| filename | path to file |
|---|---|
| mode | modifiers for how to open file |
| initialSize | the initial size (in bytes) of the device, if creating a new file |
Definition at line 30 of file RandomAccessFileDevice.cpp.
| RandomAccessFileDevice::RandomAccessFileDevice | ( | std::string | filename, |
|---|---|---|---|
| DeviceMode | mode | ||
| ) | [explicit] |
Opens a file device for random access.
Parameters:
| filename | path to file |
|---|---|
| mode | modifiers for how to open file |
Definition at line 36 of file RandomAccessFileDevice.cpp.
Member Function Documentation
| FileSize RandomAccessFileDevice::getSizeInBytes | ( | | ) | [virtual] | | --------------------------------------------------------------------------------------------------- | - | | - | ----------- |
| void RandomAccessFileDevice::setSizeInBytes | ( | FileSize | cbNew | ) | [virtual] |
|---|
Executes a synchronous transfer request for a single random access binding.
This is an all-or-nothing request, so unless the result size is equal to the requested transfer size, the request is considered a failure. However, no exception is thrown when failure occurs; instead, the binding notification method is called.
Parameters:
| request | transfer specification; must have exactly one binding |
|---|
Reimplemented from FileDevice.
Definition at line 56 of file RandomAccessFileDevice.cpp.
References RandomAccessRequest::pDevice, and FileDevice::transfer().
| void RandomAccessFileDevice::flush | ( | | ) | [virtual] | | ---------------------------------- | - | | - | ----------- |
| int RandomAccessFileDevice::getHandle | ( | | ) | [virtual] | | ------------------------------------- | - | | - | ----------- |
| void FileDevice::close | ( | | ) | [inherited] | | ---------------------- | - | | - | ------------- |
| bool FileDevice::isOpen | ( | | ) | const [inline, inherited] | | ----------------------- | - | | - | --------------------------- |
Member Data Documentation
On Cygwin, there's no pread/pwrite, so all I/O has to be synchronized per device.
Definition at line 66 of file FileDevice.h.
The documentation for this class was generated from the following files:
- /home/pub/open/dev/fennel/device/RandomAccessFileDevice.h
- /home/pub/open/dev/fennel/device/RandomAccessFileDevice.cpp
