Enable searching for files in a given list of paths, give access to the current directory and wrap boost::filesystem functionality.
More...
#include <ApplicationData.h>
|
| ApplicationData (const std::vector< std::string > &paths) |
| Constructor, class is immutable, pass a list of paths to be used for searching duplicate paths will be eliminated, invalid paths will be eliminated, the order of the paths given here is the order that will be used in searching, the first occurrance of a file within a given path will be used. More...
|
|
| ApplicationData (const std::string &configFile) |
| Reads the search paths from a given configuration file. More...
|
|
std::vector< std::string > | getPaths () const |
| Gets the search paths. More...
|
|
std::string | findFile (const std::string &fileName) const |
| Searches for the first occurrence of fileName amongst the given paths, the search is shallow, only direct content of the directories in the path list will be used as search candidates. More...
|
|
bool | tryFindFile (const std::string &fileName, std::string *target) const |
| Searches for the first occurrence of fileName amongst the given paths, see findFile() for details. More...
|
|
bool | isValidFilename (const std::string &fileName) const |
| Checks if the filename is acceptable. More...
|
|
Enable searching for files in a given list of paths, give access to the current directory and wrap boost::filesystem functionality.
§ ApplicationData() [1/2]
SurgSim::Framework::ApplicationData::ApplicationData |
( |
const std::vector< std::string > & |
paths | ) |
|
|
explicit |
Constructor, class is immutable, pass a list of paths to be used for searching duplicate paths will be eliminated, invalid paths will be eliminated, the order of the paths given here is the order that will be used in searching, the first occurrance of a file within a given path will be used.
- Parameters
-
paths | The list of search paths. |
§ ApplicationData() [2/2]
SurgSim::Framework::ApplicationData::ApplicationData |
( |
const std::string & |
configFile | ) |
|
|
explicit |
Reads the search paths from a given configuration file.
- Parameters
-
configFile | The configuration file for reading the search paths. |
§ findFile()
std::string SurgSim::Framework::ApplicationData::findFile |
( |
const std::string & |
fileName | ) |
const |
Searches for the first occurrence of fileName amongst the given paths, the search is shallow, only direct content of the directories in the path list will be used as search candidates.
- Parameters
-
fileName | Filename of the file. |
- Returns
- The absolute path to the file in system format i.e c:\xxx\yyy\file.txt for windows and /xxx/yyy/file.txt for all other systems. An empty string will be returned if the file cannot be found.
§ getPaths()
std::vector< std::string > SurgSim::Framework::ApplicationData::getPaths |
( |
| ) |
const |
Gets the search paths.
- Returns
- The paths, passed in the constructor with duplicates and invalid paths removed. All paths returned will be absolute and in system format.
§ isValidFilename()
bool SurgSim::Framework::ApplicationData::isValidFilename |
( |
const std::string & |
fileName | ) |
const |
Checks if the filename is acceptable.
- Parameters
-
fileName | Filename to be checked. |
- Returns
- true if the name is valid, false otherwise.
§ tryFindFile()
bool SurgSim::Framework::ApplicationData::tryFindFile |
( |
const std::string & |
fileName, |
|
|
std::string * |
target |
|
) |
| const |
Searches for the first occurrence of fileName amongst the given paths, see findFile() for details.
If the file is found the full pathName will be sent in target and true returned. If the file is not found the result will be false and the content of target will not change.
- Parameters
-
fileName | Filename of the file. |
target | The location for the converted filename if it was found. |
- Returns
- true if the file is found, false otherwise.
The documentation for this class was generated from the following files: