openMSX
FileContext.hh
Go to the documentation of this file.
1 #ifndef FILECONTEXT_HH
2 #define FILECONTEXT_HH
3 
4 #include <string_view>
5 #include <vector>
6 
7 namespace openmsx {
8 
9 class FileContext final
10 {
11 public:
12  FileContext() = default;
13  FileContext(std::vector<std::string>&& paths,
14  std::vector<std::string>&& savePaths);
15 
16  std::string resolve (std::string_view filename) const;
17  std::string resolveCreate(std::string_view filename) const;
18 
19  std::vector<std::string> getPaths() const;
20  bool isUserContext() const;
21 
22  template<typename Archive>
23  void serialize(Archive& ar, unsigned version);
24 
25 private:
26  std::vector<std::string> paths;
27  std::vector<std::string> savePaths;
28 };
29 
30 FileContext configFileContext(std::string_view path, std::string_view hwDescr, std::string_view userName);
33 FileContext userFileContext(std::string_view savePath = {});
34 FileContext userDataFileContext(std::string_view subdir);
36 
37 } // namespace openmsx
38 
39 #endif
std::string resolveCreate(std::string_view filename) const
Definition: FileContext.cc:85
FileContext userDataFileContext(string_view subDir)
Definition: FileContext.cc:171
FileContext configFileContext(string_view path, string_view hwDescr, string_view userName)
Definition: FileContext.cc:142
FileContext preferSystemFileContext()
Definition: FileContext.cc:155
FileContext systemFileContext()
Definition: FileContext.cc:149
bool isUserContext() const
Definition: FileContext.cc:109
std::string resolve(std::string_view filename) const
Definition: FileContext.cc:77
FileContext userFileContext(string_view savePath)
Definition: FileContext.cc:161
constexpr const char *const filename
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
FileContext currentDirFileContext()
Definition: FileContext.cc:177
std::vector< std::string > getPaths() const
Definition: FileContext.cc:104
void serialize(Archive &ar, unsigned version)
Definition: FileContext.cc:115