openMSX
Filename.cc
Go to the documentation of this file.
1#include "Filename.hh"
2#include "MSXException.hh"
3#include "serialize.hh"
4#include <cassert>
5
6namespace openmsx {
7
9{
10 if (empty()) return;
11 if (FileOperations::exists(resolvedFilename)) return;
12
13 try {
14 resolvedFilename = FileOperations::getAbsolutePath(
15 userFileContext().resolve(originalFilename));
16 } catch (MSXException&) {
17 // nothing
18 }
19}
20
21bool Filename::empty() const
22{
23 assert(getOriginal().empty() == getResolved().empty());
24 return getOriginal().empty();
25}
26
27template<typename Archive>
28void Filename::serialize(Archive& ar, unsigned /*version*/)
29{
30 ar.serialize("original", originalFilename,
31 "resolved", resolvedFilename);
32}
34
35} // namespace openmsx
This class represents a filename.
Definition Filename.hh:20
const std::string & getOriginal() const
Definition Filename.hh:37
bool empty() const
Convenience method to test for empty filename.
Definition Filename.cc:21
void serialize(Archive &ar, unsigned version)
Definition Filename.cc:28
const std::string & getResolved() const &
Definition Filename.hh:38
void updateAfterLoadState()
After a loadstate we prefer to use the exact same file as before savestate.
Definition Filename.cc:8
bool exists(zstring_view filename)
Does this file (directory) exists?
string getAbsolutePath(string_view path)
Transform given path into an absolute path.
This file implemented 3 utility functions:
Definition Autofire.cc:11
const FileContext & userFileContext()
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)