#include <file.h>
Public Types | |
typedef ConexusPointer< File > | pointer |
Public Member Functions | |
CONEXUS_ENDPOINT_GENERIC_CREATE () | |
virtual | ~File () |
virtual void | open (const std::string name, long unsigned mode=FILE_UNCHANGED) throw ( open_exception) |
Opens the named file in the specified mode. | |
virtual void | open () throw ( open_exception ) |
Will attempt to open the file if a filename has been specified. | |
std::string | filename () |
Will return the filename. | |
long unsigned | mode () |
Returns the POSIX file mode of the endpoint. | |
bool | eof () |
True if file has encountered an EOF condition, false otherwise. | |
void | set_eof (bool state=true) |
Forces the eof state to a specific value. | |
bool | is_throw_eof_set () |
If true, file endpoint will throw an eof exception when an EOF condition is encountered. | |
void | set_throw_eof (bool teof=true) |
Sets the endpoint behavior when an EOF condition is encountered. | |
void | set_filename (std::string d, long unsigned mode=FILE_UNCHANGED) throw ( open_exception ) |
Sets the filename. | |
sigc::signal< void > | signal_filename_changed () |
Static Public Member Functions | |
static File::pointer | create (const std::string &filename=std::string(), long unsigned mode=0) |
Protected Member Functions | |
File (const std::string &filename, long unsigned mode) | |
virtual Data | read_data (size_t size, Timeout timeout) throw ( read_exception ) |
Reimplements Endpoint::read_data() using FileDescriptor::read_data() to catch the exception where data read size is zero indicating EOF. | |
Protected Attributes | |
std::string | m_filename |
long unsigned | m_mode |
bool | m_eof |
bool | m_throw_eof |
sigc::signal< void > | m_signal_filename_changed |
Related Functions | |
(Note that these are not member functions.) | |
enum | FileMode { FILE_READ = 1<<0, FILE_WRITE = 1<<1, FILE_APPEND = 1<<2, FILE_CREATE = 1<<3, FILE_DIRECT = 1<<4, FILE_LARGE_FILE = 1<<5, FILE_NO_ACCESS_TIME = 1<<6, FILE_NO_FOLLOW = 1<<7, FILE_TRUNCATE = 1<<8, FILE_EXCLUSIVE_CREATE = 1<<9, FILE_UNCHANGED = 1<<10, FILE_LAST_STATE = FILE_UNCHANGED } |
TODO add support for stat(2)
typedef ConexusPointer<File> Conexus::File::pointer |
Reimplemented from Conexus::FileDescriptor.
Conexus::File::File | ( | const std::string & | filename, | |
long unsigned | mode | |||
) | [protected] |
References Conexus::FILE_UNCHANGED, and set_filename().
Conexus::File::~File | ( | ) | [virtual] |
Conexus::File::CONEXUS_ENDPOINT_GENERIC_CREATE | ( | ) |
File::pointer Conexus::File::create | ( | const std::string & | filename = std::string() , |
|
long unsigned | mode = 0 | |||
) | [static] |
bool Conexus::File::eof | ( | ) |
std::string Conexus::File::filename | ( | ) |
bool Conexus::File::is_throw_eof_set | ( | ) |
If true, file endpoint will throw an eof exception when an EOF condition is encountered.
The default setting for any endpoint is to not throw an EOF exception
References m_throw_eof.
long unsigned Conexus::File::mode | ( | ) |
void Conexus::File::open | ( | ) | throw ( open_exception ) [virtual] |
Will attempt to open the file if a filename has been specified.
Otherwise an exception will be thrown.
Implements Conexus::Endpoint.
References m_filename.
void Conexus::File::open | ( | const std::string | name, | |
long unsigned | mode = FILE_UNCHANGED | |||
) | throw ( open_exception) [virtual] |
Opens the named file in the specified mode.
References Conexus::ENDPOINT_CLOSED, Conexus::FILE_APPEND, Conexus::FILE_CREATE, Conexus::FILE_DIRECT, Conexus::FILE_EXCLUSIVE_CREATE, Conexus::FILE_LARGE_FILE, Conexus::FILE_NO_ACCESS_TIME, Conexus::FILE_NO_FOLLOW, Conexus::FILE_READ, Conexus::FILE_TRUNCATE, Conexus::FILE_UNCHANGED, and Conexus::FILE_WRITE.
Data Conexus::File::read_data | ( | size_t | size, | |
Timeout | timeout | |||
) | throw ( read_exception ) [protected, virtual] |
Reimplements Endpoint::read_data() using FileDescriptor::read_data() to catch the exception where data read size is zero indicating EOF.
When encountered throws eof exception.
Conexus::exception::read::eof | When file EOF is encounter on a zero length read |
Reimplemented from Conexus::FileDescriptor.
References Conexus::FileDescriptor::read_data().
void Conexus::File::set_eof | ( | bool | state = true |
) |
Forces the eof state to a specific value.
Setting this to false sets the internal eof state to false, even if an EOF condition has been encountered. This effectively resets the internal state of the endpoint but has no actual effect on the file. If the file is truly EOF it will remain EOF.
References m_eof.
void Conexus::File::set_filename | ( | std::string | d, | |
long unsigned | mode = FILE_UNCHANGED | |||
) | throw ( open_exception ) |
Sets the filename.
If the file is currently open and d is not equal to the current filename, the current file will be closed.
Also, if auto_open is set, the new file will be immediately opened.
Additionally, this method checks whether the parameter d is the same as the current filename, and parameter mode is the same as the current mode. If both are equal, the file will not be closed and reopened unless force=true.
References Conexus::FILE_UNCHANGED.
Referenced by File().
void Conexus::File::set_throw_eof | ( | bool | teof = true |
) |
Sets the endpoint behavior when an EOF condition is encountered.
teof | If set to true, endpoint will throw an exception when an EOF is encountered |
References m_throw_eof.
sigc::signal< void > Conexus::File::signal_filename_changed | ( | ) |
References m_signal_filename_changed.
enum FileMode [related] |
bool Conexus::File::m_eof [protected] |
std::string Conexus::File::m_filename [protected] |
Referenced by filename(), and open().
long unsigned Conexus::File::m_mode [protected] |
Referenced by mode().
sigc::signal<void> Conexus::File::m_signal_filename_changed [protected] |
Referenced by signal_filename_changed().
bool Conexus::File::m_throw_eof [protected] |
Referenced by is_throw_eof_set(), and set_throw_eof().