gramods
FileResolver.hh
1 
2 #ifndef GRAMODS_CORE_FILERESOLVER
3 #define GRAMODS_CORE_FILERESOLVER
4 
5 #include <gmCore/config.hh>
6 
7 #include <filesystem>
8 
9 BEGIN_NAMESPACE_GMCORE;
10 
27 class FileResolver {
28 
29 private:
30  FileResolver();
31  virtual ~FileResolver();
32 
33 public:
37  enum struct Check {
38  None, //< Perform no check
39  ReadableFile, //< Check if file and readable
40  WritableFile //< Check if file and writable
41  };
42 
46  bool readUrnFile(std::filesystem::path urn_file);
47 
52  std::filesystem::path resolve(std::string, Check check = Check::None);
53 
57  std::filesystem::path resolve(std::filesystem::path path,
58  Check check = Check::None) {
59  return resolve(path.u8string(), check);
60  }
61 
65  static std::filesystem::path getPathToExecutable();
66 
70  static FileResolver * getDefault() {
71  static FileResolver default_resolver;
72  return &default_resolver;
73  }
74 
75 private:
76  struct Impl;
77  std::unique_ptr<Impl> _impl;
78 };
79 
80 END_NAMESPACE_GMCORE;
81 
82 #endif
The FileResolver provides a means to locate resources in a portable manner.
Definition: FileResolver.hh:27
std::filesystem::path resolve(std::filesystem::path path, Check check=Check::None)
Resolves the specified path using the currently loaded rules.
Definition: FileResolver.hh:57
Check
Flag for checking path after resolving pattern.
Definition: FileResolver.hh:37
static FileResolver * getDefault()
Returns the default resolver.
Definition: FileResolver.hh:70