casacore
|
Class for IO on a regular file. More...
#include <RegularFileIO.h>
Public Member Functions | |
RegularFileIO (const RegularFile ®ularFile, ByteIO::OpenOption=ByteIO::Old, uInt filebufSize=0) | |
Create an IO stream object for a regular file with the given name. More... | |
~RegularFileIO () | |
virtual void | reopenRW () |
Reopen the underlying file for read/write access. More... | |
virtual String | fileName () const |
Get the file name of the file attached. More... | |
Public Member Functions inherited from casacore::FilebufIO | |
FilebufIO () | |
Default constructor. More... | |
FilebufIO (int fd, uInt bufferSize=16384) | |
Construct from the given file descriptor. More... | |
void | attach (int fd, uInt bufferSize=16384) |
Attach to the given file descriptor. More... | |
virtual | ~FilebufIO () |
The destructor closes the file when it was owned and opened and not closed yet. More... | |
virtual void | write (Int64 size, const void *buf) |
Write the number of bytes. More... | |
virtual Int64 | read (Int64 size, void *buf, Bool throwException=True) |
Read size bytes from the File. More... | |
virtual void | flush () |
Flush the current buffer. More... | |
virtual void | resync () |
Resync the file (i.e. More... | |
virtual Int64 | length () |
Get the length of the byte stream. More... | |
virtual Bool | isReadable () const |
Is the IO stream readable? More... | |
virtual Bool | isWritable () const |
Is the IO stream writable? More... | |
virtual Bool | isSeekable () const |
Is the IO stream seekable? More... | |
uInt | bufferSize () const |
Get the buffer size. More... | |
Public Member Functions inherited from casacore::ByteIO | |
ByteIO () | |
The constructor does nothing. More... | |
virtual | ~ByteIO () |
virtual void | pwrite (Int64 size, Int64 offset, const void *buf) |
Write size bytes to the byte stream at offset . More... | |
virtual Int64 | pread (Int64 size, Int64 offset, void *buf, Bool throwException=True) |
Like read but reads from offset of start of the file The file offset is not changed. More... | |
Int64 | seek (Int offset, ByteIO::SeekOption=ByteIO::Begin) |
This function sets the position on the given offset. More... | |
Int64 | seek (Int64 offset, ByteIO::SeekOption=ByteIO::Begin) |
virtual void | fsync () |
Fsync the file (i.e. More... | |
Static Public Member Functions | |
static int | openCreate (const RegularFile &file, ByteIO::OpenOption, Bool useODirect=False) |
Convenience function to open or create a file. More... | |
Private Member Functions | |
RegularFileIO (const RegularFileIO &that) | |
Copy constructor, should not be used. More... | |
RegularFileIO & | operator= (const RegularFileIO &that) |
Assignment, should not be used. More... | |
Private Attributes | |
OpenOption | itsOption |
RegularFile | itsRegularFile |
Additional Inherited Members | |
Public Types inherited from casacore::ByteIO | |
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... | |
Protected Member Functions inherited from casacore::FilebufIO | |
void | detach (Bool closeFile=False) |
Detach the FILE. More... | |
void | fillRWFlags (int fd) |
Determine if the file descriptor is readable and/or writable. More... | |
void | fillSeekable () |
Determine if the file is seekable. More... | |
virtual Int64 | doSeek (Int64 offset, ByteIO::SeekOption) |
Reset the position pointer to the given value. More... | |
void | setBuffer (Int64 bufSize) |
Set a new buffer size. More... | |
void | writeBuffer (Int64 offset, const char *buf, Int64 size) |
Write a buffer of given length into the file at given offset. More... | |
Int64 | readBuffer (Int64 offset, char *buf, Int64 size, Bool throwException) |
Read a buffer of given length from the file at given offset. More... | |
void | writeBlock (Int64 size, const char *buf) |
Write a block into the stream at the current offset. More... | |
Int64 | readBlock (Int64 size, char *buf, Bool throwException) |
Read a block from the stream at the current offset. More... | |
Protected Member Functions inherited from casacore::ByteIO | |
ByteIO (const ByteIO &byteIO) | |
Make copy constructor and assignment protected, so a user cannot use them (but a derived class can). More... | |
ByteIO & | operator= (const ByteIO &byteIO) |
Class for IO on a regular file.
Public interface
This class is a specialization of class ByteIO. It uses a regular file as the data store.
The class is derived from FilebufIO, which contains all functions to access the file. The description of this class explains the use of the filebufSize
argument in the constructor.
Definition at line 81 of file RegularFileIO.h.
|
explicit |
Create an IO stream object for a regular file with the given name.
The ByteIO option determines if the file will be created or opened for input and/or output.
The argument filebufSize
defines the length of the internal buffer in the underlying FilebufIO object. A zero length uses an appropriate default.
casacore::RegularFileIO::~RegularFileIO | ( | ) |
|
private |
Copy constructor, should not be used.
|
virtual |
Get the file name of the file attached.
Reimplemented from casacore::FilebufIO.
|
static |
Convenience function to open or create a file.
Optionally 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 to be read/written to be a multiple of the the disk's logival block size. It returns the file descriptor.
|
private |
Assignment, should not be used.
|
virtual |
Reopen the underlying file for read/write access.
Nothing will be done if the stream is writable already. Otherwise it will be reopened and an exception will be thrown if it is not possible to reopen it for read/write access.
Reimplemented from casacore::ByteIO.
|
private |
Definition at line 117 of file RegularFileIO.h.
|
private |
Definition at line 118 of file RegularFileIO.h.