Singleton class that handles file searches.
More...
#include <FileManager.hh>
|
static bool | dir_iterate (const std::string &dir_name, const std::function< bool(const std::string &, const std::string &)> &func) |
| Helper function that executes a std::function on the name of each regular file found while scanning through a single directory (non-recursively) More...
|
|
|
std::string | marley_dir_ |
| Stores the value of the MARLEY environment variable (which points to the root folder of the source code distribution)
|
|
Singleton class that handles file searches.
◆ dir_iterate()
bool marley::FileManager::dir_iterate |
( |
const std::string & |
dir_name, |
|
|
const std::function< bool(const std::string &, const std::string &)> & |
func |
|
) |
| |
|
staticprotected |
Helper function that executes a std::function on the name of each regular file found while scanning through a single directory (non-recursively)
- Parameters
-
dir_name | The name of the directory to be scanned |
func | The function to execute. The first argument is the full file name (including the path). The second is the base name of the file (no path). The return value should be true if no further iterations are needed (e.g., because a file matching a desired name was found) and false otherwise. |
- Returns
- True if the iterations were stopped early (due to function returning true) or false if they were completed
◆ find_file() [1/2]
Searches for a file in the given search path.
The search is non-recursive, i.e., no subdirectories are included in the search
- Parameters
-
base_name | The base name (file name without any path) of the desired file |
search_path | A string containing a ':'-delimited list of directories that should be searched for the file |
- Returns
- The full path to the file, or an empty string if no match could be found
◆ find_file() [2/2]
std::string marley::FileManager::find_file |
( |
const std::string & |
base_name, |
|
|
const std::vector< std::string > & |
search_dirs |
|
) |
| const |
Searches for a file in the given directories.
The search is non-recursive, i.e., no subdirectories are included in the search
- Parameters
-
base_name | The base name (file name without any path) of the desired file |
search_dirs | A vector of strings specifying the directories that should be searched for the file |
- Returns
- The full path to the file, or an empty string if no match could be found
◆ list_all_files() [1/2]
Get a vector of full paths for all regular files in the requested search path.
Files in subdirectories are not included (the search is non-recursive)
- Parameters
-
search_path | A string containing a ':'-delimited list of directories that should be scanned for files |
- Returns
- A vector of strings giving the full path to each regular file that was found
◆ list_all_files() [2/2]
std::vector< std::string > marley::FileManager::list_all_files |
( |
const std::vector< std::string > & |
search_dirs | ) |
const |
Get a vector of full paths for all regular files in the requested directories.
Files in subdirectories are not included (the search is non-recursive)
- Parameters
-
search_dirs | A vector of strings specifying the directories that should be scanned |
- Returns
- A vector of strings giving the full path to each regular file that was found
◆ search_path_to_dir_vector()
Converts a ':'-delimited search path (given as a single string) into a vector of directory names.
- Parameters
-
search_path | The search path to convert that should be searched for the file |
- Returns
- A vector of directory names corresponding to those given in the search path
The documentation for this class was generated from the following files:
- /Users/gardiner/marley/include/marley/FileManager.hh
- /Users/gardiner/marley/src/FileManager.cc