![]() |
eRPC Generator (erpcgen)
Rev. 1.7.2
NXP Semiconductors
|
Handles searching a list of paths for a file. More...
#include <SearchPath.h>
Public Types | |
enum | _target_type { kFindFile, kFindDirectory } |
typedef enum _target_type | target_type_t |
Public Member Functions | |
PathSearcher () | |
Constructor. | |
void | addSearchPath (const std::string &path) |
Add a new search path to the end of the list. | |
void | setTempPath (const std::string &path) |
Set temporary path. | |
bool | search (const std::string &base, target_type_t targetType, bool searchCwd, std::string &result) |
Attempts to locate a file by using the search paths. More... | |
Static Public Member Functions | |
static PathSearcher & | getGlobalSearcher () |
Access global path searching object. More... | |
Protected Types | |
typedef std::list< std::string > | string_list_t |
Linked list of strings. | |
Protected Member Functions | |
bool | isAbsolute (const std::string &path) |
Returns whether path is absolute. | |
std::string | joinPaths (const std::string &first, const std::string &second) |
Combines two paths into a single one. | |
Protected Attributes | |
string_list_t | m_paths |
Ordered list of paths to search. | |
std::string | m_tempPath |
Possibility to add temporary path. | |
Static Protected Attributes | |
static PathSearcher * | s_searcher |
Global search object singleton. | |
Handles searching a list of paths for a file.
typedef enum _target_type PathSearcher::target_type_t |
Type of searched item.
|
static |
Access global path searching object.
This function will create the global path search object if it has not already been created.
bool PathSearcher::search | ( | const std::string & | base, |
target_type_t | targetType, | ||
bool | searchCwd, | ||
std::string & | result | ||
) |
Attempts to locate a file by using the search paths.
The base path argument can be either a relative or absolute path. If the path is relative, then it is joined with search paths one after another until a matching file is located or all search paths are exhausted. If the base is absolute, only that path is tested and if invalid false is returned.
base | A path to the file that is to be found. | |
targetType | Currently ignored. In the future it will let you select whether to find a file or directory. | |
searchCwd | If set to true, the current working directory is searched before using any of the search paths. Otherwise only the search paths are considered. | |
[out] | result | When true is returned this string is set to the first path at which a valid file was found. |
true | A matching file was found among the search paths. The contents of result are a valid path. |
false | No match could be made. result has been left unmodified. |