openMSX
FileContext.hh
Go to the documentation of this file.
1#ifndef FILECONTEXT_HH
2#define FILECONTEXT_HH
3
4#include <span>
5#include <string>
6#include <string_view>
7#include <vector>
8
9namespace openmsx {
10
11class FileContext final
12{
13public:
14 FileContext() = default;
15 FileContext(std::vector<std::string>&& paths,
16 std::vector<std::string>&& savePaths);
17
18 [[nodiscard]] std::string resolve (std::string_view filename) const;
19 [[nodiscard]] std::string resolveCreate(std::string_view filename) const;
20
21 [[nodiscard]] std::span<const std::string> getPaths() const;
22 [[nodiscard]] bool isUserContext() const;
23
24 template<typename Archive>
25 void serialize(Archive& ar, unsigned version);
26
27private:
28 std::vector<std::string> paths;
29 mutable std::vector<std::string> paths2; // calculated from paths
30 std::vector<std::string> savePaths;
31 mutable std::vector<std::string> savePaths2; // calc from savePaths
32};
33
34[[nodiscard]] FileContext configFileContext(std::string_view path, std::string_view hwDescr, std::string_view userName);
35[[nodiscard]] FileContext userDataFileContext(std::string_view subdir);
36[[nodiscard]] FileContext userFileContext(std::string_view savePath);
37[[nodiscard]] const FileContext& userFileContext();
38[[nodiscard]] const FileContext& systemFileContext();
39[[nodiscard]] const FileContext& preferSystemFileContext();
40[[nodiscard]] const FileContext& currentDirFileContext();
41
42} // namespace openmsx
43
44#endif
void serialize(Archive &ar, unsigned version)
Definition: FileContext.cc:122
std::string resolveCreate(std::string_view filename) const
Definition: FileContext.cc:86
std::span< const std::string > getPaths() const
Definition: FileContext.cc:108
bool isUserContext() const
Definition: FileContext.cc:116
std::string resolve(std::string_view filename) const
Definition: FileContext.cc:79
This file implemented 3 utility functions:
Definition: Autofire.cc:9
const FileContext & systemFileContext()
Definition: FileContext.cc:155
FileContext configFileContext(string_view path, string_view hwDescr, string_view userName)
Definition: FileContext.cc:149
const FileContext & currentDirFileContext()
Definition: FileContext.cc:189
FileContext userFileContext(string_view savePath)
Definition: FileContext.cc:171
FileContext userDataFileContext(string_view subDir)
Definition: FileContext.cc:183
const FileContext & preferSystemFileContext()
Definition: FileContext.cc:163