cppfs  1.2.0.5b71c2c98fb9
Cross-platform C++ file system library supporting multiple backends (Local-FS, SSH)
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
cppfs::Tree Class Reference

Representation of a directory tree. More...

#include <cppfs/include/cppfs/Tree.h>

Public Member Functions

 Tree ()
 Constructor. More...
 
 ~Tree ()
 Destructor. More...
 
void clear ()
 Clear data. More...
 
const std::string & path () const
 Get path. More...
 
void setPath (const std::string &path)
 Set path. More...
 
void setPath (std::string &&path)
 Set path. More...
 
const std::string & fileName () const
 Get filename. More...
 
void setFileName (const std::string &filename)
 Set filename. More...
 
void setFileName (std::string &&filename)
 Set filename. More...
 
bool isFile () const
 Check if item is a file. More...
 
bool isDirectory () const
 Check if item is a directory. More...
 
void setDirectory (bool isDir)
 Set directory. More...
 
unsigned int size () const
 Get file size. More...
 
void setSize (unsigned int size)
 Set file size. More...
 
unsigned int accessTime () const
 Get time of last access. More...
 
void setAccessTime (unsigned int time)
 Set time of last access. More...
 
unsigned int modificationTime () const
 Get time of last modification. More...
 
void setModificationTime (unsigned int time)
 Set time of last modification. More...
 
unsigned int userId () const
 Get ID of owning user. More...
 
void setUserId (unsigned int id)
 Set ID of owning user. More...
 
unsigned int groupId () const
 Get ID of owning group. More...
 
void setGroupId (unsigned int id)
 Set ID of owning group. More...
 
unsigned long permissions () const
 Get file permissions. More...
 
void setPermissions (unsigned int permissions)
 Set file permissions. More...
 
const std::string & sha1 () const
 Get sha1 hash. More...
 
void setSha1 (const std::string &hash)
 Set sha1 hash. More...
 
void setSha1 (std::string &&hash)
 Set sha1 hash. More...
 
std::vector< std::string > listFiles () const
 List files in directory. More...
 
const std::vector< std::unique_ptr< Tree > > & children () const
 Get children list. More...
 
std::vector< std::unique_ptr< Tree > > & children ()
 Get children list. More...
 
void add (std::unique_ptr< Tree > &&tree)
 Add child. More...
 
void print (const std::string &indent="") const
 Print tree to stdout. More...
 
std::unique_ptr< DiffcreateDiff (const Tree &target) const
 Create diff from this state to target state. More...
 

Protected Member Functions

 Tree (const Tree &)
 
const Treeoperator= (const Tree &)
 

Static Protected Member Functions

static void createDiff (const Tree *currentState, const Tree *targetState, Diff &diff)
 

Protected Attributes

std::string m_path
 Path. More...
 
std::string m_filename
 Filename. More...
 
bool m_directory
 'true' if directory, 'false' if file More...
 
unsigned int m_size
 File size. More...
 
unsigned int m_accessTime
 Time of last access. More...
 
unsigned int m_modificationTime
 Time of last modification. More...
 
unsigned int m_userId
 User ID. More...
 
unsigned int m_groupId
 Group ID. More...
 
unsigned long m_permissions
 File permissions. More...
 
std::string m_sha1
 SHA1 hash. More...
 
std::vector< std::unique_ptr< Tree > > m_children
 List of children. More...
 

Detailed Description

Representation of a directory tree.

Constructor & Destructor Documentation

cppfs::Tree::Tree ( )

Constructor.

cppfs::Tree::~Tree ( )

Destructor.

cppfs::Tree::Tree ( const Tree )
protected

Member Function Documentation

void cppfs::Tree::clear ( )

Clear data.

const std::string& cppfs::Tree::path ( ) const

Get path.

Returns
Path to file or directory
Remarks
The path is constructed relative to the root element of the tree. So the path of the root element will be empty (""), the path of the first-order child elements will equal their filenames, etc.
void cppfs::Tree::setPath ( const std::string &  path)

Set path.

Parameters
[in]pathPath to file or directory
void cppfs::Tree::setPath ( std::string &&  path)

Set path.

Parameters
[in]pathPath to file or directory
const std::string& cppfs::Tree::fileName ( ) const

Get filename.

Returns
Filename
void cppfs::Tree::setFileName ( const std::string &  filename)

Set filename.

Parameters
[in]filenameFilename
void cppfs::Tree::setFileName ( std::string &&  filename)

Set filename.

Parameters
[in]filenameFilename
bool cppfs::Tree::isFile ( ) const

Check if item is a file.

Returns
'true' if it is a file, else 'false'
bool cppfs::Tree::isDirectory ( ) const

Check if item is a directory.

Returns
'true' if it is a directory, else 'false'
void cppfs::Tree::setDirectory ( bool  isDir)

Set directory.

Parameters
[in]isDir'true' if it is a directory, else 'false'
unsigned int cppfs::Tree::size ( ) const

Get file size.

Returns
Size of file
void cppfs::Tree::setSize ( unsigned int  size)

Set file size.

Parameters
[in]sizeSize of file
unsigned int cppfs::Tree::accessTime ( ) const

Get time of last access.

Returns
Time stamp
void cppfs::Tree::setAccessTime ( unsigned int  time)

Set time of last access.

Parameters
[in]timeTime stamp
unsigned int cppfs::Tree::modificationTime ( ) const

Get time of last modification.

Returns
Time stamp
void cppfs::Tree::setModificationTime ( unsigned int  time)

Set time of last modification.

Parameters
[in]timeTime stamp
unsigned int cppfs::Tree::userId ( ) const

Get ID of owning user.

Returns
User ID
void cppfs::Tree::setUserId ( unsigned int  id)

Set ID of owning user.

Parameters
[in]idUser ID
unsigned int cppfs::Tree::groupId ( ) const

Get ID of owning group.

Returns
Group ID
void cppfs::Tree::setGroupId ( unsigned int  id)

Set ID of owning group.

Parameters
[in]idGroup ID
unsigned long cppfs::Tree::permissions ( ) const

Get file permissions.

Returns
File permissions
void cppfs::Tree::setPermissions ( unsigned int  permissions)

Set file permissions.

Parameters
[in]permissionsFile permissions
const std::string& cppfs::Tree::sha1 ( ) const

Get sha1 hash.

Returns
SHA1 hash
void cppfs::Tree::setSha1 ( const std::string &  hash)

Set sha1 hash.

Parameters
[in]hashSHA1 hash
void cppfs::Tree::setSha1 ( std::string &&  hash)

Set sha1 hash.

Parameters
[in]hashSHA1 hash
std::vector<std::string> cppfs::Tree::listFiles ( ) const

List files in directory.

Returns
List of files, empty list if this is not a valid directory
const std::vector< std::unique_ptr<Tree> >& cppfs::Tree::children ( ) const

Get children list.

Returns
List of children
std::vector< std::unique_ptr<Tree> >& cppfs::Tree::children ( )

Get children list.

Returns
List of children
void cppfs::Tree::add ( std::unique_ptr< Tree > &&  tree)

Add child.

Parameters
[in]treeChild tree (must NOT be null!)
Remarks
The tree takes ownership over the child tree
void cppfs::Tree::print ( const std::string &  indent = "") const

Print tree to stdout.

Parameters
[in]indentIndentation
std::unique_ptr<Diff> cppfs::Tree::createDiff ( const Tree target) const

Create diff from this state to target state.

Parameters
[in]targetTarget tree state
Returns
Diff (never null)
Remarks
This functions creates a diff which contains the operations that are needed to get from this state to the target state. The returned diff must be deleted by the caller.
const Tree& cppfs::Tree::operator= ( const Tree )
protected
static void cppfs::Tree::createDiff ( const Tree currentState,
const Tree targetState,
Diff diff 
)
staticprotected

Member Data Documentation

std::string cppfs::Tree::m_path
protected

Path.

std::string cppfs::Tree::m_filename
protected

Filename.

bool cppfs::Tree::m_directory
protected

'true' if directory, 'false' if file

unsigned int cppfs::Tree::m_size
protected

File size.

unsigned int cppfs::Tree::m_accessTime
protected

Time of last access.

unsigned int cppfs::Tree::m_modificationTime
protected

Time of last modification.

unsigned int cppfs::Tree::m_userId
protected

User ID.

unsigned int cppfs::Tree::m_groupId
protected

Group ID.

unsigned long cppfs::Tree::m_permissions
protected

File permissions.

std::string cppfs::Tree::m_sha1
protected

SHA1 hash.

std::vector< std::unique_ptr<Tree> > cppfs::Tree::m_children
protected

List of children.


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