Filesystem utilities.
More...
|
auto | base_name (const std::string &path) -> std::string |
|
auto | dir_name (const std::string &path) -> std::string |
|
template<typename Predicate > |
auto | find_if (const std::string &base, bool recursive, Predicate &&predicate) -> std::string |
|
auto | find (const std::string &base, const std::string &name, bool recursive=false) -> std::string |
|
auto | find (const std::string &base, const std::regex ®ex, bool recursive=false) -> std::string |
|
◆ base_name()
auto irccd::fs_util::base_name |
( |
const std::string & |
path | ) |
-> std::string |
Get the base name from a path.
Example, base_name("/etc/foo.conf") returns foo.conf
- Parameters
-
- Returns
- the base name
◆ dir_name()
auto irccd::fs_util::dir_name |
( |
const std::string & |
path | ) |
-> std::string |
Get the parent directory from a path.
Example, dir_name("/etc/foo.conf") returns /etc
- Parameters
-
- Returns
- the parent directory
◆ find() [1/2]
auto irccd::fs_util::find |
( |
const std::string & |
base, |
|
|
const std::regex & |
regex, |
|
|
bool |
recursive = false |
|
) |
| -> std::string |
Overload by regular expression.
- Parameters
-
base | the base directory |
regex | the regular expression |
recursive | true to do recursive search |
- Returns
- the full path name to the file or empty string if never found
- Exceptions
-
boost::system::system_error | on errors |
◆ find() [2/2]
auto irccd::fs_util::find |
( |
const std::string & |
base, |
|
|
const std::string & |
name, |
|
|
bool |
recursive = false |
|
) |
| -> std::string |
Find a file by name recursively.
- Parameters
-
base | the base directory |
name | the file name |
recursive | true to do recursive search |
- Returns
- the full path name to the file or empty string if never found
- Exceptions
-
boost::system::system_error | on errors |
◆ find_if()
template<typename Predicate >
auto irccd::fs_util::find_if |
( |
const std::string & |
base, |
|
|
bool |
recursive, |
|
|
Predicate && |
predicate |
|
) |
| -> std::string
|
Search an item recursively.
The predicate must have the following signature: void f(const boost::filesystem::directory_entry& entry)
Where:
- base is the current parent directory in the tree
- entry is the current entry
- Parameters
-
base | the base directory |
predicate | the predicate |
recursive | true to do recursive search |
- Returns
- the full path name to the file or empty string if never found
- Exceptions
-
boost::system::system_error | on errors |