#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 () |
bool | eof () |
bool | throw_eof () |
void | set_throw_eof (bool teof=true) |
bool | is_file () const |
bool | is_directory () const |
bool | is_other_file_type () const |
size_t | size () const |
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 (long int timeout, size_t s=0) 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 |
TODO review NSPR documentation for completeness TODO add support for PR_GetFileInfo
typedef ConexusPointer<File> Conexus::NSPR::File::pointer |
Reimplemented from Conexus::NSPR::FileDescriptor.
Conexus::NSPR::File::File | ( | const std::string & | filename, | |
long unsigned | mode | |||
) | [protected] |
References Conexus::FILE_UNCHANGED, and set_filename().
Conexus::NSPR::File::~File | ( | ) | [virtual] |
Conexus::NSPR::File::CONEXUS_ENDPOINT_GENERIC_CREATE | ( | ) |
File::pointer Conexus::NSPR::File::create | ( | const std::string & | filename = std::string() , |
|
long unsigned | mode = 0 | |||
) | [static] |
bool Conexus::NSPR::File::eof | ( | ) |
References m_eof.
std::string Conexus::NSPR::File::filename | ( | ) |
bool Conexus::NSPR::File::is_directory | ( | ) | const |
References m_filename.
bool Conexus::NSPR::File::is_file | ( | ) | const |
References m_filename.
bool Conexus::NSPR::File::is_other_file_type | ( | ) | const |
References m_filename.
long unsigned Conexus::NSPR::File::mode | ( | ) |
References m_mode.
void Conexus::NSPR::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::NSPR::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_EXCLUSIVE_CREATE, Conexus::FILE_READ, Conexus::NSPR::FILE_SYNC, Conexus::FILE_TRUNCATE, Conexus::FILE_UNCHANGED, and Conexus::FILE_WRITE.
Data Conexus::NSPR::File::read_data | ( | long int | timeout, | |
size_t | s = 0 | |||
) | 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 |
References Conexus::NSPR::FileDescriptor::read_data().
void Conexus::NSPR::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::NSPR::File::set_throw_eof | ( | bool | teof = true |
) |
References m_throw_eof.
sigc::signal< void > Conexus::NSPR::File::signal_filename_changed | ( | ) |
References m_signal_filename_changed.
size_t Conexus::NSPR::File::size | ( | ) | const |
References m_filename.
bool Conexus::NSPR::File::throw_eof | ( | ) |
References m_throw_eof.
bool Conexus::NSPR::File::m_eof [protected] |
Referenced by eof().
std::string Conexus::NSPR::File::m_filename [protected] |
Referenced by filename(), is_directory(), is_file(), is_other_file_type(), open(), and size().
long unsigned Conexus::NSPR::File::m_mode [protected] |
Referenced by mode().
sigc::signal<void> Conexus::NSPR::File::m_signal_filename_changed [protected] |
Referenced by signal_filename_changed().
bool Conexus::NSPR::File::m_throw_eof [protected] |
Referenced by set_throw_eof(), and throw_eof().