Provides information about a node in the file-system. More...

#include <cxxtools/fileinfo.h>

Public Types

enum  Type {
  Invalid = 0, Directory = 1, File = 2, Chardev = 3,
  Blockdev = 4, Fifo = 5, Symlink = 6, Socket = 7
}
 File-node type. More...

Public Member Functions

 FileInfo ()
 Default constructor.
 FileInfo (const std::string &path)
 Constructs a FileInfo object from the path path.
 FileInfo (const DirectoryIterator &it)
 FileInfo (const FileInfo &fi)
 Copy constructor.
 ~FileInfo ()
 Destructor.
FileInfooperator= (const FileInfo &fi)
 Assignment operator.
Type type () const
 Returns the type of the file node.
const std::string & path () const
std::string name () const
 Returns the full path of node in the file-system.
std::string dirName () const
 Returns the parent directory path.
std::size_t size () const
 Returns the size of the file in bytes.
bool isDirectory () const
 Returns true if the node is a directory.
bool isFile () const
 Returns true if the node is a file.
void remove ()
 Removes the file node.
void move (const std::string &to)
 Moves the file node to the location given by to.

Static Public Member Functions

static bool exists (const std::string &path)
 Returns true if a file or directory exists at path.
static Type getType (const std::string &path)
 Returns the type of file at path.

Detailed Description

Provides information about a node in the file-system.

Member Enumeration Documentation

File-node type.

Enumerator:
Invalid 
Directory 
File 
Chardev 
Blockdev 
Fifo 
Symlink 
Socket 

Constructor & Destructor Documentation

cxxtools::FileInfo::FileInfo ( )

Default constructor.

cxxtools::FileInfo::FileInfo ( const std::string &  path)
explicit

Constructs a FileInfo object from the path path.

cxxtools::FileInfo::FileInfo ( const DirectoryIterator it)
explicit
cxxtools::FileInfo::FileInfo ( const FileInfo fi)

Copy constructor.

cxxtools::FileInfo::~FileInfo ( )

Destructor.

Member Function Documentation

std::string cxxtools::FileInfo::dirName ( ) const

Returns the parent directory path.

This method might return an empty string if the node was created without a complete path. If the directory is located in the root directory of a unix file system, a slash ("/") is returned. A returned directory path always ends with a trailing path separator character. (A backslash in Windows and a slash in Unix, for example.)

static bool cxxtools::FileInfo::exists ( const std::string &  path)
static

Returns true if a file or directory exists at path.

static Type cxxtools::FileInfo::getType ( const std::string &  path)
static

Returns the type of file at path.

bool cxxtools::FileInfo::isDirectory ( ) const
inline

Returns true if the node is a directory.

bool cxxtools::FileInfo::isFile ( ) const
inline

Returns true if the node is a file.

void cxxtools::FileInfo::move ( const std::string &  to)

Moves the file node to the location given by to.

The object will stay valid after this method was called and point to the moved file node.

std::string cxxtools::FileInfo::name ( ) const

Returns the full path of node in the file-system.

This method may return a relative path, or a fully qualified one depending on how this object was constructed.

FileInfo& cxxtools::FileInfo::operator= ( const FileInfo fi)

Assignment operator.

const std::string& cxxtools::FileInfo::path ( ) const
void cxxtools::FileInfo::remove ( )

Removes the file node.

This object will be invalid after calling this method.

std::size_t cxxtools::FileInfo::size ( ) const

Returns the size of the file in bytes.

Type cxxtools::FileInfo::type ( ) const

Returns the type of the file node.


The documentation for this class was generated from the following file: