IBR-DTNSuite
0.12
|
#include <File.h>
Public Member Functions | |
File () | |
File (const std::string &path) | |
virtual | ~File () |
unsigned char | getType () const |
int | getFiles (std::list< File > &files) const |
bool | isRoot () const |
bool | isSystem () const |
bool | isDirectory () const |
std::string | getPath () const |
std::string | getBasename () const |
virtual int | remove (bool recursive=false) |
File | get (const std::string &filename) const |
File | getParent () const |
virtual bool | exists () const |
virtual void | update () |
virtual size_t | size () const |
virtual time_t | lastaccess () const |
virtual time_t | lastmodify () const |
virtual time_t | laststatchange () const |
bool | operator== (const ibrcommon::File &other) const |
bool | operator< (const ibrcommon::File &other) const |
Static Public Member Functions | |
static void | createDirectory (File &path) |
Protected Member Functions | |
File (const std::string &path, const unsigned char t) | |
Protected Attributes | |
unsigned char | _type |
A File object can hold a reference to any existing or non-existing files/directories. It provides a common set of file operations.
ibrcommon::File::File | ( | ) |
Instantiate a File object without a reference to a file.
Definition at line 53 of file File.cpp.
Referenced by getParent().
ibrcommon::File::File | ( | const std::string & | path) |
|
protected |
|
static |
This method creates a directory. This is done recursively.
path | The path to create. |
Definition at line 293 of file File.cpp.
References exists(), getParent(), getPath(), and update().
Referenced by dtn::storage::SQLiteBundleStorage::clear(), dtn::storage::DataStorage::DataStorage(), dtn::daemon::Configuration::Security::load(), main(), io::TarUtils::read(), dtn::data::MemoryBundleSet::setPath(), and dtn::storage::SQLiteBundleStorage::SQLiteBundleStorage().
|
virtual |
Checks whether this file exists or not.
Reimplemented in io::FATFile.
Definition at line 97 of file File.cpp.
Referenced by createDirectory(), dtn::storage::DataStorage::DataStorage(), ibrcommon::FileBLOB::FileBLOB(), dtn::security::SecurityKeyManager::get(), dtn::security::SecurityKeyManager::hasKey(), init(), main(), dtn::storage::DataStorage::retrieve(), dtn::storage::DataStorage::run(), dtn::data::MemoryBundleSet::setPath(), and dtn::security::SecurityKeyManager::store().
File ibrcommon::File::get | ( | const std::string & | filename) | const |
Get a specific file in this directory.
filename | The name of the file (not the full path). |
Definition at line 233 of file File.cpp.
References FILE_DELIMITER_CHAR, getPath(), and isRoot().
Referenced by io::FATFile::get(), dtn::security::SecurityKeyManager::get(), dtn::security::SecurityKeyManager::hasKey(), io::TarUtils::read(), dtn::storage::DataStorage::retrieve(), dtn::storage::DataStorage::run(), dtn::storage::SQLiteBundleStorage::SQLiteBundleStorage(), and dtn::security::SecurityKeyManager::store().
std::string ibrcommon::File::getBasename | ( | ) | const |
Returns the basename of the file.
Definition at line 221 of file File.cpp.
Referenced by isSystem(), and main().
int ibrcommon::File::getFiles | ( | std::list< File > & | files) | const |
Get all files in the directory. The given path in the constructor has to be a directory in this case.
files | A (empty) list to put the new file objects in. |
Definition at line 164 of file File.cpp.
References FILE_DELIMITER_CHAR, getPath(), and isDirectory().
Referenced by dtn::storage::DataStorage::DataStorage(), io::ObservedFile::findFiles(), ibrcommon::TLSStream::init(), dtn::storage::DataStorage::iterateAll(), and remove().
File ibrcommon::File::getParent | ( | ) | const |
Get the parent of this file. This is always the containing directory.
Definition at line 283 of file File.cpp.
References File(), FILE_DELIMITER, FILE_DELIMITER_CHAR, and isRoot().
Referenced by createDirectory(), io::FATFile::getParent(), and io::TarUtils::read().
string ibrcommon::File::getPath | ( | ) | const |
Returns the full path of the file (as given in the constructor).
Definition at line 216 of file File.cpp.
Referenced by dtn::net::FileConvergenceLayer::componentRun(), createDirectory(), io::FatImageReader::FileHandle::FileHandle(), io::FATFile::get(), dtn::security::SecurityKeyManager::get(), dtn::storage::SQLiteBundleStorage::get(), get(), dtn::security::SecurityKey::getData(), dtn::security::SecurityKey::getEVP(), getFiles(), io::FATFile::getParent(), ibrcommon::TLSStream::init(), dtn::storage::DataStorage::istream::istream(), lastaccess(), lastmodify(), laststatchange(), main(), dtn::security::SecurityKeyManager::onConfigurationChanged(), dtn::security::SecurityCertificateManager::onConfigurationChanged(), io::FatImageReader::open(), dtn::storage::SQLiteDatabase::open(), ibrcommon::FileBLOB::open(), io::TarUtils::read(), ibrcommon::LogWriter::reload(), remove(), dtn::storage::DataStorage::retrieve(), dtn::storage::DataStorage::run(), dtn::daemon::NativeDaemon::setConfigFile(), ibrcommon::LogWriter::setLogfile(), size(), dtn::security::SecurityKeyManager::store(), dtn::storage::SQLiteBundleStorage::store(), ibrcommon::filesocket::up(), dtn::net::FileMonitor::watch(), and io::TarUtils::write().
unsigned char ibrcommon::File::getType | ( | ) | const |
bool ibrcommon::File::isDirectory | ( | ) | const |
Checks if a file is a directory.
Definition at line 210 of file File.cpp.
References _type.
Referenced by io::ObservedFile::findFiles(), getFiles(), ibrcommon::TLSStream::init(), main(), dtn::security::SecurityCertificateManager::onConfigurationChanged(), remove(), dtn::data::MemoryBundleSet::setPath(), dtn::net::FileMonitor::watch(), and io::TarUtils::write().
bool ibrcommon::File::isRoot | ( | ) | const |
Checks if a file is the root of the file-system
Definition at line 200 of file File.cpp.
References FILE_DELIMITER.
Referenced by get(), getParent(), io::FatImageReader::isDirectory(), io::FatImageReader::lastaccess(), and io::FatImageReader::size().
bool ibrcommon::File::isSystem | ( | ) | const |
Checks if a file is a system file like ".." and ".".
Definition at line 205 of file File.cpp.
References getBasename().
Referenced by io::ObservedFile::findFiles(), and remove().
|
virtual |
Get the timestamp of the last access
Reimplemented in io::FATFile.
Definition at line 319 of file File.cpp.
References getPath().
Referenced by dtn::storage::SimpleBundleStorage::get(), and dtn::storage::SQLiteBundleStorage::get().
|
virtual |
Get the timestamp of the last modification
Reimplemented in io::FATFile.
Definition at line 326 of file File.cpp.
References getPath().
Referenced by dtn::security::SecurityKeyManager::get(), dtn::storage::SimpleBundleStorage::get(), and dtn::storage::SQLiteBundleStorage::get().
|
virtual |
Get the timestamp of the last status change
Reimplemented in io::FATFile.
Definition at line 333 of file File.cpp.
References getPath().
bool ibrcommon::File::operator< | ( | const ibrcommon::File & | other) | const |
bool ibrcommon::File::operator== | ( | const ibrcommon::File & | other) | const |
|
virtual |
Remove a file.
recursive | If set to true, the deletion works recursive and deletes directories with files too. |
Reimplemented in io::FATFile.
Definition at line 244 of file File.cpp.
References _type, getFiles(), getPath(), isDirectory(), isSystem(), and remove().
Referenced by dtn::storage::SQLiteBundleStorage::clear(), dtn::net::FileConvergenceLayer::componentRun(), dtn::storage::SQLiteDatabase::expire(), main(), remove(), dtn::storage::SQLiteDatabase::remove(), dtn::storage::DataStorage::run(), dtn::storage::SQLiteBundleStorage::SQLiteBundleStorage(), dtn::security::SecurityKeyManager::store(), and dtn::storage::SQLiteBundleStorage::store().
|
virtual |
Get the size of the file.
Reimplemented in io::FATFile.
Definition at line 312 of file File.cpp.
References getPath().
Referenced by ibrcommon::FileBLOB::__get_size(), dtn::storage::SQLiteBundleStorage::store(), and io::TarUtils::write().
|
virtual |
Updates file information like file type
Reimplemented in io::FATFile.
Definition at line 114 of file File.cpp.
References _type.
Referenced by createDirectory(), and File().
|
protected |
Definition at line 173 of file File.h.
Referenced by getType(), isDirectory(), remove(), io::FATFile::update(), and update().