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)
std::string resolveCreate(std::string_view filename) const
std::span< const std::string > getPaths() const
bool isUserContext() const
std::string resolve(std::string_view filename) const
This file implemented 3 utility functions:
Definition Autofire.cc:11
const FileContext & systemFileContext()
FileContext configFileContext(string_view path, string_view hwDescr, string_view userName)
const FileContext & currentDirFileContext()
const FileContext & userFileContext()
FileContext userDataFileContext(string_view subDir)
const FileContext & preferSystemFileContext()