ibrcommon::File Class Reference

#include <File.h>

Inheritance diagram for ibrcommon::File:
ibrcommon::TemporaryFile

List of all members.

Public Member Functions

 File ()
 File (const string path)
virtual ~File ()
unsigned char getType () const
int getFiles (list< File > &files)
bool isSystem () const
bool isDirectory () const
std::string getPath () const
int remove (bool recursive=false)
File get (string filename) const
File getParent () const
bool exists () const
void update ()
size_t size () const

Static Public Member Functions

static void createDirectory (File &path)

Detailed Description

A File object can hold a reference to any existing or non-existing files/directories. It provides a common set of file operations.

Definition at line 29 of file File.h.


Constructor & Destructor Documentation

ibrcommon::File::File (  ) 

Instantiate a File object without a reference to a file.

Definition at line 19 of file File.cpp.

Referenced by getParent().

ibrcommon::File::File ( const string  path  ) 

Instantiate a File object with a reference to a existing and non-existing file.

Parameters:
path Filename or path to reference to.

Definition at line 30 of file File.cpp.

References update().

ibrcommon::File::~File (  )  [virtual]

Destructor of the file.

Definition at line 86 of file File.cpp.


Member Function Documentation

void ibrcommon::File::createDirectory ( File path  )  [static]

This method creates a directory. This is done recursively.

Parameters:
path The path to create.

Definition at line 185 of file File.cpp.

References exists(), getParent(), getPath(), and update().

Referenced by createBundleStorage().

bool ibrcommon::File::exists (  )  const

Checks whether this file exists or not.

Returns:
True, if the file exists.

Definition at line 47 of file File.cpp.

Referenced by dtn::daemon::StatisticLogger::componentUp(), createBundleStorage(), and createDirectory().

File ibrcommon::File::get ( string  filename  )  const

Get a specific file in this directory.

Parameters:
filename The name of the file (not the full path).
Returns:
A file object of the contained file.

Definition at line 133 of file File.cpp.

References getPath().

Referenced by dtn::core::SQLiteBundleStorage::componentUp().

int ibrcommon::File::getFiles ( list< File > &  files  ) 

Get all files in the directory. The given path in the constructor has to be a directory in this case.

Parameters:
files A (empty) list to put the new file objects in.
Returns:
Returns zero on success and an error number on failure.

Definition at line 94 of file File.cpp.

References getPath(), and isDirectory().

Referenced by main(), and remove().

File ibrcommon::File::getParent (  )  const

Get the parent of this file. This is always the containing directory.

Returns:
The parent directory of this file.

Definition at line 179 of file File.cpp.

References File().

Referenced by createDirectory().

string ibrcommon::File::getPath (  )  const
unsigned char ibrcommon::File::getType (  )  const

Returns the type of the file. The type is only updated when calling update().

See also:
update()
Returns:
The filetype of the file (e.g. DT_REG, DT_LNK, DT_DIR, DT_UNKNOWN)

Definition at line 89 of file File.cpp.

bool ibrcommon::File::isDirectory (  )  const

Checks if a file is a directory.

Returns:
True, if the file is a directory.

Definition at line 122 of file File.cpp.

Referenced by getFiles(), and remove().

bool ibrcommon::File::isSystem (  )  const

Checks if a file is a system file like ".." and ".".

Returns:
True, if the file is a system file.

Definition at line 116 of file File.cpp.

Referenced by main(), and remove().

int ibrcommon::File::remove ( bool  recursive = false  ) 

Remove a file.

Parameters:
recursive If set to true, the deletion works recursive and deletes directories with files too.
Returns:
Returns zero on success and an error number on failure.

Definition at line 141 of file File.cpp.

References getFiles(), getPath(), isDirectory(), and isSystem().

Referenced by ibrcommon::TmpFileBLOB::clear(), main(), dtn::core::SimpleBundleStorage::BundleContainer::Holder::~Holder(), and ibrcommon::TmpFileBLOB::~TmpFileBLOB().

size_t ibrcommon::File::size (  )  const

Get the size of the file.

Returns:
The size in bytes.

Definition at line 200 of file File.cpp.

References getPath().

Referenced by dtn::core::SimpleBundleStorage::BundleContainer::Holder::Holder(), and dtn::core::SimpleBundleStorage::BundleContainer::Holder::invokeStore().

void ibrcommon::File::update (  ) 

Updates file information like file type

See also:
getType()

Definition at line 56 of file File.cpp.

Referenced by createDirectory(), and File().


The documentation for this class was generated from the following files:
Generated on Mon Aug 23 08:13:01 2010 for IBR-DTNSuite by  doxygen 1.6.3