LargeFiledesIO.h
Classes
- LargeFiledesIO -- Class for IO on a large file descriptor. (full description)
Interface
- Public Members
- LargeFiledesIO()
- explicit LargeFiledesIO (int fd)
- void attach (int fd)
- ~LargeFiledesIO()
- virtual void write (uInt size, const void* buf)
- virtual Int read (uInt size, void* buf, Bool throwException=True)
- virtual Int64 length()
- virtual Bool isReadable() const
- virtual Bool isWritable() const
- virtual Bool isSeekable() const
- virtual String fileName() const
- static int create (const Char* name, int mode = 0644)
- static int open (const Char* name, Bool writable = False, Bool throwExcp = True)
- static void close (int fd)
- Protected Members
- void detach()
- void fillRWFlags (int fd)
- void fillSeekable()
- virtual Int64 doSeek (Int64 offset, ByteIO::ByteIO)
- Private Members
- LargeFiledesIO (const LargeFiledesIO& that)
- LargeFiledesIO& operator= (const LargeFiledesIO& that)
Review Status
- Reviewed By:
- Friso Olnon
- Date Reviewed:
- 1996/11/06
- Programs:
- Tests:
Prerequisite
Synopsis
This class is a specialization of class
ByteIO. It uses a file descriptor
to read/write data.
The file associated with the file descriptor has to be opened
before hand.
The constructor will determine automatically if the file is
readable, writable and seekable.
Note that on destruction the file descriptor is NOT closed.
Example
This example shows how FiledesIO can be used with an fd.
It uses the fd for a regular file, which could be done in an easier
way using class RegularFileIO.
However, when using pipes or sockets, this would be the only way.
// Get a file descriptor for the file.
int fd = open ("file.name");
// Use that as the source of AipsIO (which will also use CanonicalIO).
FiledesIO fio (fd);
AipsIO stream (&fio);
// Read the data.
Int vali;
Bool valb;
stream >> vali >> valb;
Motivation
Make it possible to use the AIPS++ IO functionality on any file.
In this way any device can be hooked to the IO framework.
Member Description
Default constructor.
A stream can be attached using the attach function.
Construct from the given file descriptor.
void attach (int fd)
Attach to the given file descriptor.
The destructor does not close the file.
virtual void write (uInt size, const void* buf)
Write the number of bytes.
virtual Int read (uInt size, void* buf, Bool throwException=True)
Read size bytes from the descriptor. Returns the number of
bytes actually read or a negative number if an error occured. Will throw
an Exception (AipsError) if the requested number of bytes could not be
read, or an error occured, unless throwException is set to False. Will
always throw an exception if the descriptor is not readable or the
system call returned an undocumented value.
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?
Get the file name of the file attached.
static int create (const Char* name, int mode = 0644)
static int open (const Char* name, Bool writable = False, Bool throwExcp = True)
static void close (int fd)
Some static convenience functions for file create/open/close.
Detach the FILE. Close it when it is owned.
Determine if the file descriptor is readable and/or writable.
Determine if the file is seekable.
virtual Int64 doSeek (Int64 offset, ByteIO::ByteIO)
Reset the position pointer to the given value. It returns the
new position.
LargeFiledesIO (const LargeFiledesIO& that)
Copy constructor, should not be used.
LargeFiledesIO& operator= (const LargeFiledesIO& that)
Assignment, should not be used.