Loading...
Searching...
No Matches
casacore::FileUnbufferedIO Class Reference
casa package (libcasa_casa) » IO_module

More...

`#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.
Public Member Functions inherited from casacore::FiledesIO
| 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.
Public Member Functions inherited from casacore::ByteIO
| 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

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...
Static Public Member Functions inherited from casacore::FiledesIO
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)
Protected Member Functions inherited from casacore::FiledesIO
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.
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).
ByteIO & | operator= (const ByteIO &byteIO)

## Detailed Description

Class for unbuffered IO on a file.

### Intended use:

Public interface

### Review Status

Reviewed By:
  Friso Olnon
Date Reviewed:
  1996/11/06
Test programs:
  tByteIO

### Prerequisite

- ByteIO class
- file descriptors

### Synopsis

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.

### Motivation

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.

## Constructor & Destructor Documentation

## FileUnbufferedIO() [1/2]

casacore::FileUnbufferedIO::FileUnbufferedIO | ( | const RegularFile & | fileName,
|  | ByteIO::OpenOption | option,
|  | Bool | useODirect = False )

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.

References casacore::False, and casacore::FiledesIO::fileName().

Referenced by FileUnbufferedIO(), and operator=().

## ~FileUnbufferedIO()

casacore::FileUnbufferedIO::~FileUnbufferedIO | ( |  | ) |

override

The destructor closes the file.

## FileUnbufferedIO() [2/2]

casacore::FileUnbufferedIO::FileUnbufferedIO | ( | const FileUnbufferedIO & |  | ) |

delete

Copy constructor and assignment cannot be used.

References FileUnbufferedIO().

## Member Function Documentation

## operator=()

FileUnbufferedIO & casacore::FileUnbufferedIO::operator= | ( | const FileUnbufferedIO & |  | ) |

delete

References FileUnbufferedIO().

## reopenRW()

void casacore::FileUnbufferedIO::reopenRW | ( |  | ) |

override virtual

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.

## Member Data Documentation

## itsUseODirect

Bool casacore::FileUnbufferedIO::itsUseODirect

private

Definition at line 94 of file FileUnbufferedIO.h.

The documentation for this class was generated from the following file:

- casa/IO/FileUnbufferedIO.h