eRPC Generator (erpcgen)  Rev. 1.12.0
NXP Semiconductors
PathSearcher Class Reference

Handles searching a list of paths for a file. More...

#include <SearchPath.hpp>

Public Types

enum  target_type_t {
  kFindFile,
  kFindDirectory
}
 

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 PathSearchergetGlobalSearcher ()
 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 PathSearchers_searcher
 Global search object singleton.
 

Detailed Description

Handles searching a list of paths for a file.

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
baseA path to the file that is to be found.
targetTypeCurrently ignored. In the future it will let you select whether to find a file or directory.
searchCwdIf set to true, the current working directory is searched before using any of the search paths. Otherwise only the search paths are considered.
[out]resultWhen true is returned this string is set to the first path at which a valid file was found.
Return values
trueA matching file was found among the search paths. The contents of result are a valid path.
falseNo match could be made. result has been left unmodified.

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