casacore
|
#include <FileUnbufferedIO.h>
Public Member Functions | |
FileUnbufferedIO (const RegularFile &fileName, ByteIO::OpenOption option, Bool useODirect=False) | |
The constructor opens or creates a file. | |
~FileUnbufferedIO () override | |
The destructor closes the file. | |
FileUnbufferedIO (const FileUnbufferedIO &)=delete | |
Copy constructor and assignment cannot be used. | |
FileUnbufferedIO & | operator= (const FileUnbufferedIO &)=delete |
void | reopenRW () override |
Reopen the file for read/write. | |
![]() | |
FiledesIO () | |
Default constructor. | |
FiledesIO (int fd, const String &fileName=String()) | |
Construct from the given file descriptor. | |
void | attach (int fd, const String &fileName) |
Attach to the given file descriptor. | |
void | detach () |
Detach from the file descriptor. | |
virtual | ~FiledesIO () |
The destructor detaches, but does not close the file. | |
virtual void | write (Int64 size, const void *buf) |
Write the number of bytes. | |
virtual void | pwrite (Int64 size, Int64 offset, const void *buf) |
Write the number of bytes at offset from start of the file. | |
virtual Int64 | read (Int64 size, void *buf, Bool throwException=True) |
Read size bytes from the descriptor. | |
virtual Int64 | pread (Int64 size, Int64 offset, void *buf, Bool throwException=True) |
Like read except reads from offset of the start of the file. | |
virtual Int64 | length () |
Get the length of the byte stream. | |
virtual Bool | isReadable () const |
Is the IO stream readable? | |
virtual Bool | isWritable () const |
Is the IO stream writable? | |
virtual Bool | isSeekable () const |
Is the IO stream seekable? | |
void | setWritable () |
Set that the IO stream is writable. | |
virtual String | fileName () const |
Get the file name of the file attached. | |
virtual void | fsync () |
Fsync the file (i.e. | |
virtual void | truncate (Int64 size) |
Truncate the file to the given size. | |
![]() | |
ByteIO () | |
The constructor does nothing. | |
virtual | ~ByteIO () |
Int64 | seek (Int offset, ByteIO::SeekOption=ByteIO::Begin) |
This function sets the position on the given offset. | |
Int64 | seek (Int64 offset, ByteIO::SeekOption=ByteIO::Begin) |
virtual void | flush () |
Flush the data to the file. | |
virtual void | resync () |
Resync the file (i.e. | |
Private Attributes | |
Bool | itsUseODirect |
Additional Inherited Members | |
![]() | |
enum | OpenOption { Old , Update , Append , New , NewNoReplace , Scratch , Delete } |
Define the possible ByteIO open options. More... | |
enum | SeekOption { Begin , Current , End } |
Define the possible seek options. More... | |
![]() | |
static int | create (const Char *name, int mode=0666) |
Some static convenience functions for file create/open/close. | |
static int | open (const Char *name, Bool writable=False, Bool throwExcp=True) |
static void | close (int fd) |
![]() | |
int | fd () const |
Get the file descriptor. | |
void | fillRWFlags (int fd) |
Determine if the file descriptor is readable and/or writable. | |
void | fillSeekable () |
Determine if the file is seekable. | |
virtual Int64 | doSeek (Int64 offset, ByteIO::SeekOption) |
Reset the position pointer to the given value. | |
![]() | |
ByteIO (const ByteIO &byteIO) | |
Make copy constructor and assignment protected, so a user cannot use them (but a derived class can). | |
ByteIO & | operator= (const ByteIO &byteIO) |
Class for unbuffered IO on a file.
Public interface
This class is a specialization of class FiledesIO to make it easier to open a file. It reads/writes the data directly instead of using a buffer to reduce the number of IO-operations. It is meant for file access using large reads and writes as done by MultiFile.
Optionally the file can be used with O_DIRECT to bypass the system's file cache for more predictable IO behaviour which can be of importance in real-time applications.
Make it possible to use the Casacore IO functionality on any file. In this way any device can be hooked to the IO framework.
Definition at line 68 of file FileUnbufferedIO.h.
|
explicit |
The constructor opens or creates a file.
For option NewNoReplace it is checked if the file does not exist yet. If useODirect=True and if supported by the OS, the file will be opened with O_DIRECT which bypasses the kernel's file cache for more predictable I/O behaviour. It requires the size and the alignment of the data read or written to be a multiple of the the disk's logical block size.
|
override |
The destructor closes the file.
|
delete |
Copy constructor and assignment cannot be used.
|
delete |
|
overridevirtual |
Reopen the file for read/write.
Nothing is done if already opened for read/write. An exception is thrown if the file is readonly.
Reimplemented from casacore::ByteIO.
|
private |
Definition at line 94 of file FileUnbufferedIO.h.