BALL  1.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Private Member Functions | Private Attributes
BALL::Directory Class Reference

#include <BALL/SYSTEM/directory.h>

List of all members.

Public Member Functions

Constructors and Destructors
 Directory ()
 Directory (const String &directory_path, bool set_current=false)
 Directory (const Directory &directory)
 ~Directory ()
void clear ()
void destroy ()
Assignment
bool set (const String &directory_path, bool set_current=false)
void set (const Directory &directory)
Directoryoperator= (const Directory &directory)
void get (Directory &directory) const
Accessors
const StringgetPath () const
bool rename (String old_path, String new_path)
bool renameTo (String new_path)
bool setCurrent (String directory_path)
bool setCurrent ()
bool create (String path, const mode_t &mode=0777)
bool remove (String old_path)
bool remove ()
bool getFirstEntry (String &entry)
bool getNextEntry (String &entry)
Size countItems ()
Size countFiles ()
Size countDirectories ()
bool find (const String &filename, String &filepath)

Static Public Attributes

Constants
static const Size MAX_PATH_LENGTH

Private Member Functions

String getcwd_ ()
int chdir_ (const String &new_dir)
void synchronize_ ()
bool desynchronize_ (bool result=true)

Private Attributes

DIR * dir_
dirent * dirent_
String directory_path_
String backup_path_

Predicates

bool has (const String &item)
bool isValid () const
bool isCurrent () const
bool isEmpty ()
bool operator== (const Directory &directory) const
bool operator!= (const Directory &directory) const
static String getUserHomeDir ()
 Get the home directory of the current user.
static bool changeToUserHomeDir ()
 Goto the home directory of the current user.

Detailed Description

Directory class.

Definition at line 50 of file directory.h.


Constructor & Destructor Documentation

Default constructor. Constructs new Directory object. The directory path is set to the current working directory. The directory path does not have a path seperator {"/"} at its end.

Returns:
Directory - new constructed Directory object
BALL::Directory::Directory ( const String directory_path,
bool  set_current = false 
)

Detailed constructor. Construct new Directory object from {directory_path}. The directory path does not have a path seperator {"/"} at its end. If the given directory does not exists, the directory path is set to an empty string.

Parameters:
directory_paththe name of the directory to be opend
set_currenttrue, to set the directory as the current, default = false
Returns:
Directory - new constructed Directory object
BALL::Directory::Directory ( const Directory directory)

Copy constructor. Construct new Directory object by copying directory .

Parameters:
directorythe Directory object to be copied (cloned)
Returns:
Directory - new constructed Directory cloned from directory

Destructor.


Member Function Documentation

Goto the home directory of the current user.

int BALL::Directory::chdir_ ( const String new_dir) [private]

Explicit default initialization. Set the state to the default values. The path is set to an empty string.

Count the subdirectories in the directory.

Returns:
Size the number of subdirectories

Count the files in the directory.

Returns:
Size the number of files

Count all items in the directory.

Returns:
Size the number of items (files, links, directories)
bool BALL::Directory::create ( String  path,
const mode_t &  mode = 0777 
)

Create a new directory. The directory is created using an absolute path, if it starts with a path seperator, else it is created in this directory.

Parameters:
paththe path of the new directory
modethe access mode of the directory
Returns:
bool true if the directory could be created

Explicit destructor.

bool BALL::Directory::desynchronize_ ( bool  result = true) [private]
bool BALL::Directory::find ( const String filename,
String filepath 
)

Find a file in the directory. The search is recursive.

Parameters:
filenamethe name of the file to be searched
filepaththe path of the file, if it was found
Returns:
bool true if the file was found
void BALL::Directory::get ( Directory directory) const

Copying with cloning facility. Copy this instance to directory .

Parameters:
directorythe directory to be assigned to

Get the name of the first entry in the directory.

Parameters:
entryreference to the name of the first entry
Returns:
bool true if an entry was found

Get the name of the next entry in the directory.

Parameters:
entryreference to the name of the next entry
Returns:
bool true if an entry was found
const String& BALL::Directory::getPath ( ) const

Get the path of this instance. The directory path does not have a path seperator {"/"} at its end and is absolute. If a unvalid path was set the path is an empty string.

Returns:
String the name of the directory

Get the home directory of the current user.

bool BALL::Directory::has ( const String item)

Test if the directory has an item.

Parameters:
itemthe name of the item to look for
Returns:
bool true if the directory has the item

Test if the directory is the current working directory.

Returns:
bool

Test if the directory is empty.

Returns:
bool

Test if the directory is valid. The directory is valid if it exists. This function uses ::opendir(const char *dirname).

Returns:
bool true if the directory is valid
bool BALL::Directory::operator!= ( const Directory directory) const

Inequality operator.

Returns:
bool, true if the name of both directories are inequal
Directory& BALL::Directory::operator= ( const Directory directory)

Assignment operator. Assign directory to this instance.

bool BALL::Directory::operator== ( const Directory directory) const

Equality operator.

Returns:
bool, true if the name of both directories are equal

Remove a directory. With this method the directory associated with this object can not be removed. Use remove() instead to do so.

Parameters:
old_paththe path of the directory
Returns:
bool true if the directory could be removed

Remove this directory. The directory this object points to is deleted and the object is cleared.

Returns:
bool true if the directory could be removed
bool BALL::Directory::rename ( String  old_path,
String  new_path 
)

Rename a given directory. With this method the directory associated with this object can not be renamed. Use renameTo instead to do so.

Parameters:
old_paththe old path
new_paththe new path
Returns:
bool true if the directory could be renamed

Rename the directory associated with this object.

Parameters:
new_paththe new path
Returns:
bool true if the directory could be renamed
bool BALL::Directory::set ( const String directory_path,
bool  set_current = false 
)

Assign the Directory with the path directory_path. The given directory path can be either absolute or relative. If the path starts with a path seperator it is set as a absolute path.

Parameters:
directory_paththe name of the directory to be cloned
set_currenttrue to set the directory as the current, default = false
Returns:
bool true if the path could be set and is valid
void BALL::Directory::set ( const Directory directory)

Assignment with cloning facility. Assign the Directory directory to *this.

Parameters:
directorythe directory to be cloned

Set a directory as the current.

Parameters:
directory_paththe name of the directory
Returns:
bool true if the directory could be set as the current

Set this directory as the current working directory.

Returns:
bool true if the directory could be set as the current
void BALL::Directory::synchronize_ ( ) [private]

Member Data Documentation

Definition at line 306 of file directory.h.

DIR* BALL::Directory::dir_ [private]

Definition at line 302 of file directory.h.

Definition at line 305 of file directory.h.

dirent* BALL::Directory::dirent_ [private]

Definition at line 303 of file directory.h.

The maximum length of a path. This constant is used for system calls that require a maximum length (e.g., getcwd()). Default is 8192.

Definition at line 66 of file directory.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines