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  [[nodiscard]] std::string resolve (std::string_view filename) const;
17  [[nodiscard]] std::string resolveCreate(std::string_view filename) const;
18 
19  [[nodiscard]] std::vector<std::string> getPaths() const;
20  [[nodiscard]] 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 [[nodiscard]] FileContext configFileContext(std::string_view path, std::string_view hwDescr, std::string_view userName);
31 [[nodiscard]] FileContext systemFileContext();
32 [[nodiscard]] FileContext preferSystemFileContext();
33 [[nodiscard]] FileContext userFileContext(std::string_view savePath = {});
34 [[nodiscard]] FileContext userDataFileContext(std::string_view subdir);
35 [[nodiscard]] FileContext currentDirFileContext();
36 
37 } // namespace openmsx
38 
39 #endif
openmsx::userDataFileContext
FileContext userDataFileContext(string_view subDir)
Definition: FileContext.cc:174
openmsx::FileContext::getPaths
std::vector< std::string > getPaths() const
Definition: FileContext.cc:107
openmsx::FileContext::resolve
std::string resolve(std::string_view filename) const
Definition: FileContext.cc:80
openmsx::FileContext::resolveCreate
std::string resolveCreate(std::string_view filename) const
Definition: FileContext.cc:88
openmsx::userFileContext
FileContext userFileContext(string_view savePath)
Definition: FileContext.cc:164
openmsx::FileContext
Definition: FileContext.hh:10
openmsx::currentDirFileContext
FileContext currentDirFileContext()
Definition: FileContext.cc:180
openmsx::filename
constexpr const char *const filename
Definition: FirmwareSwitch.cc:10
openmsx::FileContext
FileContext
Definition: FileContext.cc:123
openmsx::FileContext::isUserContext
bool isUserContext() const
Definition: FileContext.cc:112
openmsx::FileContext::FileContext
FileContext()=default
openmsx::FileContext::serialize
void serialize(Archive &ar, unsigned version)
Definition: FileContext.cc:118
openmsx::configFileContext
FileContext configFileContext(string_view path, string_view hwDescr, string_view userName)
Definition: FileContext.cc:145
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::preferSystemFileContext
FileContext preferSystemFileContext()
Definition: FileContext.cc:158
openmsx::systemFileContext
FileContext systemFileContext()
Definition: FileContext.cc:152