openMSX
Filename.hh
Go to the documentation of this file.
1 #ifndef FILENAME_HH
2 #define FILENAME_HH
3 
4 #include <string>
5 
6 namespace openmsx {
7 
8 class FileContext;
9 
17 class Filename
18 {
19 public:
20  Filename();
21  explicit Filename(std::string filename);
22  Filename(std::string filename, const FileContext& context);
23 
24  const std::string& getOriginal() const { return originalFilename; }
25  const std::string& getResolved() const { return resolvedFilename; }
26 
32  void updateAfterLoadState();
33 
38  bool empty() const;
39 
44  void setResolved(const std::string& resolved) {
45  resolvedFilename = resolved;
46  }
47 
48  // Do both Filename objects point to the same file?
49  bool operator==(const Filename& other) const {
50  return resolvedFilename == other.resolvedFilename;
51  }
52  bool operator!=(const Filename& other) const {
53  return !(*this == other);
54  }
55 
56  template<typename Archive>
57  void serialize(Archive& ar, unsigned version);
58 
59 private:
60  // non-const because we want this class to be assignable
61  // (to be able to store them in std::vector)
62  std::string originalFilename;
63  std::string resolvedFilename;
64 };
65 
66 } // namespace openmsx
67 
68 #endif
bool operator==(const Filename &other) const
Definition: Filename.hh:49
void serialize(Archive &ar, unsigned version)
Definition: Filename.cc:50
const std::string & getOriginal() const
Definition: Filename.hh:24
std::unique_ptr< Context > context
Definition: GLContext.cc:9
void updateAfterLoadState()
After a loadstate we prefer to use the exact same file as before savestate.
Definition: Filename.cc:30
bool operator!=(const Filename &other) const
Definition: Filename.hh:52
This class represents a filename.
Definition: Filename.hh:17
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void setResolved(const std::string &resolved)
Change the resolved part of this filename E.g.
Definition: Filename.hh:44
const std::string & getResolved() const
Definition: Filename.hh:25
bool empty() const
Convenience method to test for empty filename.
Definition: Filename.cc:43