casacore
|
#include <MFFileIO.h>
Public Member Functions | |
MFFileIO (const std::shared_ptr< MultiFileBase > &, const String &name, ByteIO::OpenOption=ByteIO::Old) | |
Open or create a virtual file with the given name. | |
~MFFileIO () override | |
The destructor flushes and closes the file. | |
Int64 | read (Int64 size, void *buf, Bool throwException=True) override |
Read size bytes from the byte stream. | |
void | write (Int64 size, const void *buffer) override |
Write a block at the current offset. | |
void | reopenRW () override |
Reopen the file (and possibly underlying MultiFileBase) for read/write access. | |
void | remove () |
Remove the file from the MultiFileBase object. | |
void | flush () override |
Flush the file by writing all dirty data and all header info. | |
Int64 | length () override |
Get the length of the file. | |
Bool | isReadable () const override |
The file is always readable. | |
Bool | isWritable () const override |
Is the file writable? | |
Bool | isSeekable () const override |
The file is always seekable. | |
String | fileName () const override |
Get the file name of the file attached. | |
void | fsync () override |
Fsync the file (i.e. | |
void | truncate (Int64 size) override |
Truncate the file to the given size. | |
Int64 | doSeek (Int64 offset, ByteIO::SeekOption) override |
Reset the position pointer to the given value. | |
const MultiFileInfo & | getInfo () const |
Get the MultiFileInfo object for this file. | |
![]() | |
ByteIO () | |
The constructor does nothing. | |
virtual | ~ByteIO () |
virtual void | pwrite (Int64 size, Int64 offset, const void *buf) |
Write size bytes to the byte stream at offset . | |
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. | |
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 | resync () |
Resync the file (i.e. | |
Private Attributes | |
std::shared_ptr< MultiFileBase > | itsFile |
Int64 | itsPosition |
String | itsName |
Int | itsId |
Bool | itsIsWritable |
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... | |
![]() | |
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 IO on a virtual file in a MultiFileBase
Public interface
This class is a specialization of class ByteIO. It uses a MultiFileBase as the data store.
Similar to a regular file it is possible to read and write data and to seek in the file. The object keeps track of the current file offset.
Definition at line 76 of file MFFileIO.h.
casacore::MFFileIO::MFFileIO | ( | const std::shared_ptr< MultiFileBase > & | , |
const String & | name, | ||
ByteIO::OpenOption | = ByteIO::Old |
||
) |
Open or create a virtual file with the given name.
Note that only the basename of the file name is actually used. It is created in the given MultiFileBase.
|
override |
The destructor flushes and closes the file.
|
overridevirtual |
Reset the position pointer to the given value.
It returns the new position.
Implements casacore::ByteIO.
|
overridevirtual |
Get the file name of the file attached.
Reimplemented from casacore::ByteIO.
|
overridevirtual |
Flush the file by writing all dirty data and all header info.
Reimplemented from casacore::ByteIO.
|
overridevirtual |
const MultiFileInfo & casacore::MFFileIO::getInfo | ( | ) | const |
Get the MultiFileInfo object for this file.
|
overridevirtual |
The file is always readable.
Implements casacore::ByteIO.
|
overridevirtual |
The file is always seekable.
Implements casacore::ByteIO.
|
overridevirtual |
Is the file writable?
Implements casacore::ByteIO.
|
overridevirtual |
Get the length of the file.
Implements casacore::ByteIO.
|
overridevirtual |
Read size
bytes from the byte stream.
Returns the number of bytes actually read, or a negative number if an error occurred. Will also throw an Exception (AipsError) if the requested number of bytes could not be read unless throwException is set to False.
Implements casacore::ByteIO.
void casacore::MFFileIO::remove | ( | ) |
Remove the file from the MultiFileBase object.
It makes the object invalid by setting the fileId to -1.
|
overridevirtual |
Reopen the file (and possibly underlying MultiFileBase) for read/write access.
Nothing will be done if the stream is writable already. An exception will be thrown if it is not possible to reopen it for read/write access.
Reimplemented from casacore::ByteIO.
|
overridevirtual |
Truncate the file to the given size.
Reimplemented from casacore::ByteIO.
|
overridevirtual |
Write a block at the current offset.
Implements casacore::ByteIO.
|
private |
Definition at line 140 of file MFFileIO.h.
|
private |
Definition at line 143 of file MFFileIO.h.
|
private |
Definition at line 144 of file MFFileIO.h.
|
private |
Definition at line 142 of file MFFileIO.h.
|
private |
Definition at line 141 of file MFFileIO.h.