#include <BALL/SYSTEM/directory.h>
Directory class.
Definition at line 50 of file directory.h.
◆ Directory() [1/3]
BALL::Directory::Directory |
( |
| ) |
|
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
◆ Directory() [2/3]
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_path | the name of the directory to be opend |
set_current | true, to set the directory as the current, default = false |
- Returns
- Directory - new constructed Directory object
◆ Directory() [3/3]
BALL::Directory::Directory |
( |
const Directory & | directory | ) |
|
Copy constructor. Construct new Directory object by copying directory .
- Parameters
-
directory | the Directory object to be copied (cloned) |
- Returns
- Directory - new constructed Directory cloned from directory
◆ ~Directory()
BALL::Directory::~Directory |
( |
| ) |
|
◆ changeToUserHomeDir()
static bool BALL::Directory::changeToUserHomeDir |
( |
| ) |
|
|
static |
Goto the home directory of the current user.
◆ clear()
void BALL::Directory::clear |
( |
| ) |
|
Explicit default initialization. Set the state to the default values. The path is set to an empty string.
◆ countDirectories()
Size BALL::Directory::countDirectories |
( |
| ) |
|
Count the subdirectories in the directory.
- Returns
- Size the number of subdirectories
◆ countFiles()
Size BALL::Directory::countFiles |
( |
| ) |
|
Count the files in the directory.
- Returns
- Size the number of files
◆ countItems()
Size BALL::Directory::countItems |
( |
| ) |
|
Count all items in the directory.
- Returns
- Size the number of items (files, links, directories)
◆ create()
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
-
path | the path of the new directory |
mode | the access mode of the directory |
- Returns
- bool true if the directory could be created
◆ destroy()
void BALL::Directory::destroy |
( |
| ) |
|
◆ find()
Find a file in the directory. The search is recursive.
- Parameters
-
filename | the name of the file to be searched |
filepath | the path of the file, if it was found |
- Returns
- bool true if the file was found
◆ get()
void BALL::Directory::get |
( |
Directory & | directory | ) |
const |
Copying with cloning facility. Copy this instance to directory .
- Parameters
-
directory | the directory to be assigned to |
◆ getFirstEntry()
bool BALL::Directory::getFirstEntry |
( |
String & | entry | ) |
|
Get the name of the first entry in the directory.
- Parameters
-
entry | reference to the name of the first entry |
- Returns
- bool true if an entry was found
◆ getNextEntry()
bool BALL::Directory::getNextEntry |
( |
String & | entry | ) |
|
Get the name of the next entry in the directory.
- Parameters
-
entry | reference to the name of the next entry |
- Returns
- bool true if an entry was found
◆ getPath()
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
◆ getUserHomeDir()
static String BALL::Directory::getUserHomeDir |
( |
| ) |
|
|
static |
Get the home directory of the current user.
◆ has()
Test if the directory has an item.
- Parameters
-
item | the name of the item to look for |
- Returns
- bool true if the directory has the item
◆ isCurrent()
bool BALL::Directory::isCurrent |
( |
| ) |
const |
Test if the directory is the current working directory.
- Returns
- bool
◆ isEmpty()
bool BALL::Directory::isEmpty |
( |
| ) |
|
Test if the directory is empty.
- Returns
- bool
◆ isValid()
bool BALL::Directory::isValid |
( |
| ) |
const |
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
◆ operator!=()
bool BALL::Directory::operator!= |
( |
const Directory & | directory | ) |
const |
Inequality operator.
- Returns
- bool, true if the name of both directories are inequal
◆ operator=()
Assignment operator. Assign directory to this instance.
◆ operator==()
bool BALL::Directory::operator== |
( |
const Directory & | directory | ) |
const |
Equality operator.
- Returns
- bool, true if the name of both directories are equal
◆ remove() [1/2]
bool BALL::Directory::remove |
( |
| ) |
|
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
◆ remove() [2/2]
Remove a directory. With this method the directory associated with this object can not be removed. Use remove() instead to do so.
- Parameters
-
old_path | the path of the directory |
- Returns
- bool true if the directory could be removed
◆ rename()
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_path | the old path |
new_path | the new path |
- Returns
- bool true if the directory could be renamed
◆ renameTo()
Rename the directory associated with this object.
- Parameters
-
- Returns
- bool true if the directory could be renamed
◆ set() [1/2]
void BALL::Directory::set |
( |
const Directory & | directory | ) |
|
Assignment with cloning facility. Assign the Directory directory
to *this
.
- Parameters
-
directory | the directory to be cloned |
◆ set() [2/2]
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_path | the name of the directory to be cloned |
set_current | true to set the directory as the current, default = false |
- Returns
- bool true if the path could be set and is valid
◆ setCurrent() [1/2]
bool BALL::Directory::setCurrent |
( |
| ) |
|
Set this directory as the current working directory.
- Returns
- bool true if the directory could be set as the current
◆ setCurrent() [2/2]
bool BALL::Directory::setCurrent |
( |
String | directory_path | ) |
|
Set a directory as the current.
- Parameters
-
directory_path | the name of the directory |
- Returns
- bool true if the directory could be set as the current
◆ MAX_PATH_LENGTH
const Size BALL::Directory::MAX_PATH_LENGTH |
|
static |
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.