| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <string> | ||
| 4 | #include <vector> | ||
| 5 | #include <sstream> | ||
| 6 | |||
| 7 | namespace na64dp { | ||
| 8 | namespace util { | ||
| 9 | |||
| 10 | /**\brief Class represents a cached state for accessible directories. | ||
| 11 | * | ||
| 12 | * Helper class keeping a set of directories to perform file lookup. Designed | ||
| 13 | * for reentrant usage to speedup momentary usage (does not update itself | ||
| 14 | * automatically). | ||
| 15 | * | ||
| 16 | * Internally a POSIX `glob()` is used to locate file(s). | ||
| 17 | * | ||
| 18 | * \note thread-unsafe due to `glob()` | ||
| 19 | * */ | ||
| 20 | class RuntimeDirs : public std::vector<std::string> { | ||
| 21 | private: | ||
| 22 | std::stringstream _mlLog; | ||
| 23 | public: | ||
| 24 | /**\brief Accepts colon-separated list of directories | ||
| 25 | * | ||
| 26 | * During instantiation, filters existing, accessible directories and puts | ||
| 27 | * them into parental class (vector) for subsequent usage. | ||
| 28 | * */ | ||
| 29 | RuntimeDirs( const char * locations="." ); | ||
| 30 | |||
| 31 | /// Find file(s) by given pattern | ||
| 32 | std::vector<std::string> locate_files( const std::string & ) const; | ||
| 33 | |||
| 34 | /// Returns internal log reference for | ||
| 35 | ✗ | std::string dir_lookup_log() const { return _mlLog.str(); } | |
| 36 | |||
| 37 | #if 0 | ||
| 38 | /**\brief Locates file(s) in directory(-ies) | ||
| 39 | * | ||
| 40 | * For given path (or columns-separated list of directories) and given file(s) | ||
| 41 | * (or wildcard) performs search for files. Both, paths and name patterns may | ||
| 42 | * be a column-separated lists. | ||
| 43 | * | ||
| 44 | * Upon successful lookup a string is returned containing the path to a file | ||
| 45 | * found first in the paths list. If `multiple` is `true`, returned string may | ||
| 46 | * contain multiple file paths delimited with column. | ||
| 47 | * */ | ||
| 48 | static std::string find_files_by_name_in( const std::string & path | ||
| 49 | , const std::string & namePattern | ||
| 50 | , bool multiple=false | ||
| 51 | ); | ||
| 52 | #endif | ||
| 53 | }; | ||
| 54 | |||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 |