ScummVM API documentation
data_archive.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ULTIMA_SHARED_ENGINE_DATA_ARCHIVE_H
23 #define ULTIMA_SHARED_ENGINE_DATA_ARCHIVE_H
24 
25 #include "common/archive.h"
26 #include "common/fs.h"
27 #include "common/path.h"
28 
29 namespace Ultima {
30 namespace Shared {
31 
39 private:
40  Common::Archive *_zip;
41  Common::Path _publicFolder;
42  Common::Path _innerfolder;
43 
44 
45  UltimaDataArchive(Common::Archive *zip, const Common::Path &subfolder) :
46  _zip(zip), _publicFolder("data/"), _innerfolder(subfolder) {}
47 
48  Common::Path innerToPublic(const Common::Path &filename) const {
49  assert(filename.isRelativeTo(_publicFolder));
50  return _innerfolder.join(filename.relativeTo(_publicFolder));
51  }
52 public:
62  static bool load(const Common::Path &subfolder,
63  int reqMajorVersion, int reqMinorVersion, Common::U32String &errorMsg);
64 public:
65  ~UltimaDataArchive() override {
66  delete _zip;
67  }
68 
74  bool hasFile(const Common::Path &path) const override;
75 
83  const Common::Path &pattern, bool matchPathComponents = false) const override;
84 
91  int listMembers(Common::ArchiveMemberList &list) const override;
92 
97  const override;
98 
105  const Common::Path &path) const override;
106 
107  bool isPathDirectory(const Common::Path &path) const override;
108 };
109 
110 #ifndef RELEASE_BUILD
111 
120  friend class UltimaDataArchive;
121 private:
122  Common::FSNode _folder;
123  const Common::Path _publicFolder;
124 
125  UltimaDataArchiveProxy(const Common::FSNode &folder) : _folder(folder), _publicFolder("data/") {}
126 
130  Common::FSNode getNode(const Common::Path &name) const;
131 public:
132  ~UltimaDataArchiveProxy() override {
133  }
134 
140  bool hasFile(const Common::Path &path) const override {
141  return path.isRelativeTo(_publicFolder) && getNode(path).exists();
142  }
143 
151  const Common::Path &pattern, bool matchPathComponents = false) const override;
152 
159  int listMembers(Common::ArchiveMemberList &list) const override;
160 
165  const override;
166 
173  const Common::Path &path) const override;
174 
175  bool isPathDirectory(const Common::Path &path) const override;
176 };
177 
178 #endif
179 
180 } // End of namespace Shared
181 } // End of namespace Ultima
182 
183 #endif
Common::SeekableReadStream * createReadStreamForMember(const Common::Path &path) const override
int listMatchingMembers(Common::ArchiveMemberList &list, const Common::Path &pattern, bool matchPathComponents=false) const override
Definition: data_archive.h:119
Definition: list.h:44
Definition: path.h:52
static bool load(const Common::Path &subfolder, int reqMajorVersion, int reqMinorVersion, Common::U32String &errorMsg)
Definition: stream.h:745
bool isRelativeTo(const Common::Path &other) const
Definition: path.h:478
bool hasFile(const Common::Path &path) const override
Definition: data_archive.h:140
Definition: archive.h:141
Definition: detection.h:27
Definition: ustr.h:57
bool hasFile(const Common::Path &path) const override
Definition: fs.h:69
const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override
Path relativeTo(const Common::Path &other) const
Definition: data_archive.h:38
bool exists() const
int listMembers(Common::ArchiveMemberList &list) const override
bool isPathDirectory(const Common::Path &path) const override
WARN_UNUSED_RESULT Path join(const Path &x) const
Definition: path.h:447