![]() |
Exiv2
|
Provides binary file IO by implementing the BasicIo interface. More...
#include <basicio.hpp>
Classes | |
class | Impl |
Internal Pimpl structure of class FileIo. More... | |
Public Member Functions | |
Creators | |
FileIo (const std::string &path) | |
Constructor that accepts the file path on which IO will be performed. The constructor does not open the file, and therefore never failes. More... | |
virtual | ~FileIo () |
Destructor. Flushes and closes an open file. | |
Manipulators | |
int | open (const std::string &mode) |
Open the file using using the specified mode. More... | |
virtual int | open () |
Open the file using using the default access mode of "rb". This method can also be used to "reopen" a file which will flush any unwritten data and reset the IO position to the start. More... | |
virtual int | close () |
Flush and unwritten data and close the file . It is safe to call close on an already closed instance. More... | |
virtual long | write (const byte *data, long wcount) |
Write data to the file. The file position is advanced by the number of bytes written. More... | |
virtual long | write (BasicIo &src) |
Write data that is read from another BasicIo instance to the file. The file position is advanced by the number of bytes written. More... | |
virtual int | putb (byte data) |
Write one byte to the file. The file position is advanced by one byte. More... | |
virtual DataBuf | read (long rcount) |
Read data from the file. Reading starts at the current file position and the position is advanced by the number of bytes read. More... | |
virtual long | read (byte *buf, long rcount) |
Read data from the file. Reading starts at the current file position and the position is advanced by the number of bytes read. More... | |
virtual int | getb () |
Read one byte from the file. The file position is advanced by one byte. More... | |
virtual void | transfer (BasicIo &src) |
Remove the contents of the file and then transfer data from the src BasicIo object into the empty file. More... | |
virtual int | seek (long offset, Position pos) |
Move the current file position. More... | |
virtual byte * | mmap (bool isWriteable=false) |
Map the file into the process's address space. The file must be open before mmap() is called. If the mapped area is writeable, changes may not be written back to the underlying file until munmap() is called. The pointer is valid only as long as the FileIo object exists. More... | |
virtual int | munmap () |
Remove a mapping established with mmap(). If the mapped area is writeable, this ensures that changes are written back to the underlying file. More... | |
virtual void | setPath (const std::string &path) |
close the file source and set a new path. | |
Accessors | |
virtual long | tell () const |
Get the current file position. More... | |
virtual size_t | size () const |
Flush any buffered writes and get the current file size in bytes. More... | |
virtual bool | isopen () const |
Returns true if the file is open, otherwise false. | |
virtual int | error () const |
Returns 0 if the file is in a valid state, otherwise nonzero. | |
virtual bool | eof () const |
Returns true if the file position has reached the end, otherwise false. | |
virtual std::string | path () const |
Returns the path of the file. | |
virtual void | populateFakeData () |
Mark all the bNone blocks to bKnow. This avoids allocating memory for parts of the file that contain image-date (non-metadata/pixel data) More... | |
![]() | |
virtual | ~BasicIo () |
Destructor. | |
Additional Inherited Members | |
![]() | |
enum | Position { beg, cur, end } |
Seek starting positions. | |
typedef std::auto_ptr< BasicIo > | AutoPtr |
BasicIo auto_ptr type. | |
![]() | |
byte * | bigBlock_ |
this is allocated and populated by mmap() | |
![]() | |
BasicIo () | |
Default Constructor. | |
Provides binary file IO by implementing the BasicIo interface.
|
explicit |
Constructor that accepts the file path on which IO will be performed. The constructor does not open the file, and therefore never failes.
path | The full path of a file |
|
virtual |
Flush and unwritten data and close the file . It is safe to call close on an already closed instance.
Implements Exiv2::BasicIo.
References munmap().
Referenced by Exiv2::ImageFactory::create(), open(), setPath(), transfer(), and ~FileIo().
|
virtual |
Read one byte from the file. The file position is advanced by one byte.
Implements Exiv2::BasicIo.
|
virtual |
Map the file into the process's address space. The file must be open before mmap() is called. If the mapped area is writeable, changes may not be written back to the underlying file until munmap() is called. The pointer is valid only as long as the FileIo object exists.
isWriteable | Set to true if the mapped area should be writeable (default is false). |
Error | In case of failure. |
Implements Exiv2::BasicIo.
References munmap().
|
virtual |
int Exiv2::FileIo::open | ( | const std::string & | mode | ) |
Open the file using using the specified mode.
This method can also be used to "reopen" a file which will flush any unwritten data and reset the IO position to the start. Although files can be opened in binary or text mode, this class has only been tested carefully in binary mode.
mode | Specified that type of access allowed on the file. Valid values match those of the C fopen command exactly. |
References close(), and path().
Referenced by Exiv2::ImageFactory::create(), Exiv2::readFile(), and Exiv2::writeFile().
|
virtual |
Open the file using using the default access mode of "rb". This method can also be used to "reopen" a file which will flush any unwritten data and reset the IO position to the start.
Implements Exiv2::BasicIo.
Referenced by transfer().
|
virtual |
Mark all the bNone blocks to bKnow. This avoids allocating memory for parts of the file that contain image-date (non-metadata/pixel data)
Reimplemented from Exiv2::BasicIo.
|
virtual |
Write one byte to the file. The file position is advanced by one byte.
data | The single byte to be written. |
Implements Exiv2::BasicIo.
|
virtual |
Read data from the file. Reading starts at the current file position and the position is advanced by the number of bytes read.
rcount | Maximum number of bytes to read. Fewer bytes may be read if rcount bytes are not available. |
Implements Exiv2::BasicIo.
References size().
|
virtual |
Read data from the file. Reading starts at the current file position and the position is advanced by the number of bytes read.
buf | Pointer to a block of memory into which the read data is stored. The memory block must be at least rcount bytes long. |
rcount | Maximum number of bytes to read. Fewer bytes may be read if rcount bytes are not available. |
Implements Exiv2::BasicIo.
|
virtual |
Move the current file position.
offset | Number of bytes to move the file position relative to the starting position specified by pos |
pos | Position from which the seek should start |
Implements Exiv2::BasicIo.
Referenced by munmap().
|
virtual |
Flush any buffered writes and get the current file size in bytes.
Implements Exiv2::BasicIo.
References Exiv2::FileIo::Impl::StructStat::st_size.
Referenced by eof(), read(), and Exiv2::XPathIo::writeDataToFile().
|
virtual |
Get the current file position.
Implements Exiv2::BasicIo.
Referenced by eof().
|
virtual |
Remove the contents of the file and then transfer data from the src BasicIo object into the empty file.
This method is optimized to simply rename the source file if the source object is another FileIo instance. The source BasicIo object is invalidated by this operation and should not be used after this method returns. This method exists primarily to be used with the BasicIo::temporary() method.
src | Reference to another BasicIo instance. The entire contents of src are transferred to this object. The src object is invalidated by the method. |
Error | In case of failure |
Implements Exiv2::BasicIo.
Reimplemented in Exiv2::XPathIo.
References close(), open(), path(), and Exiv2::string.
Referenced by Exiv2::XPathIo::transfer().
|
virtual |
Write data to the file. The file position is advanced by the number of bytes written.
data | Pointer to data. Data must be at least wcount bytes long |
wcount | Number of bytes to be written. |
Implements Exiv2::BasicIo.
Referenced by munmap().
|
virtual |
Write data that is read from another BasicIo instance to the file. The file position is advanced by the number of bytes written.
src | Reference to another BasicIo instance. Reading start at the source's current IO position |
Implements Exiv2::BasicIo.
References Exiv2::BasicIo::isopen(), Exiv2::BasicIo::read(), and Exiv2::BasicIo::seek().