| eRPC Generator (erpcgen) Rev. 1.8.1 NXP Semiconductors

- Main Page
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
PathSearcher Class Reference

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.

## Detailed Description

Handles searching a list of paths for a file.

## Member Typedef Documentation

typedef enum _target_type PathSearcher::target_type_t

Type of searched item.

## Member Function Documentation

PathSearcher & PathSearcher::getGlobalSearcher | ( |  | ) |
| 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.

Parameters

  | 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.

Return values

  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.

The documentation for this class was generated from the following files:

- SearchPath.h
- SearchPath.cpp