ScummVM API documentation
vfs.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 MTROPOLIS_VFS_H
23#define MTROPOLIS_VFS_H
24
25#include "common/archive.h"
26#include "common/hash-str.h"
27
28namespace MTropolis {
29
32
33 struct PathJunction {
34 Common::String _srcPath;
35 Common::String _destPath;
36 };
37
39 Common::String _archiveName;
40 Common::Archive *_archive;
41 };
42
43 char _pathSeparator;
44 Common::Path _workspaceRoot;
45
46 Common::Array<PathJunction> _pathJunctions;
47 Common::Array<ArchiveJunction> _archiveJunctions;
49};
50
52public:
53 explicit VirtualFileSystem(const VirtualFileSystemLayout &layout);
54
55 bool hasFile(const Common::Path &path) const override;
56 bool isPathDirectory(const Common::Path &path) const override;
57 int listMembers(Common::ArchiveMemberList &list) const override;
58 const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
60
61 Common::SeekableReadStream *createReadStreamForMemberAltStream(const Common::Path &path, Common::AltStreamType altStreamType) const override;
62
63 int listMatchingMembers(Common::ArchiveMemberList &list, const Common::Path &pattern, bool matchPathComponents = false) const override;
64
65 char getPathSeparator() const override;
66
67private:
68 struct VirtualFile {
69 Common::Path _virtualPath;
70 Common::ArchiveMemberPtr _archiveMember;
71
72 Common::ArchiveMemberPtr _vfsArchiveMember;
73 };
74
75 struct TempLayoutFile {
76 Common::String _expandedPath;
77 Common::String _expandedPathCanonical;
78 Common::ArchiveMemberPtr _archiveMember;
79 };
80
81 class VFSArchiveMember : public Common::ArchiveMember {
82 public:
83 VFSArchiveMember(const VirtualFile *virtualFile, char pathSeparator);
84
85 Common::SeekableReadStream *createReadStream() const override;
86 Common::SeekableReadStream *createReadStreamForAltStream(Common::AltStreamType altStreamType) const override;
87
88 Common::String getName() const override;
89
90 Common::Path getPathInArchive() const override;
91 Common::String getFileName() const override;
92 bool isDirectory() const override;
93 void listChildren(Common::ArchiveMemberList &childList, const char *pattern) const override;
94 Common::U32String getDisplayName() const override;
95 bool isInMacArchive() const override;
96
97 private:
98 const VirtualFile *_virtualFile;
99 char _pathSeparator;
100 };
101
102 const VirtualFile *getVirtualFile(const Common::Path &path) const;
103 static bool sortVirtualFiles(const VirtualFile &a, const VirtualFile &b);
104
105 Common::String canonicalizePath(const Common::Path &path) const;
106
107 char _pathSeparator;
108 Common::Path _workspaceRoot;
109
110 Common::Array<VirtualFile> _virtualFiles;
111 Common::HashMap<Common::String, uint> _pathToVirtualFileIndex;
112};
113
114} // End of namespace MTropolis
115
116#endif
Definition: archive.h:141
Definition: archive.h:68
Definition: array.h:52
Definition: list.h:44
Definition: path.h:52
Definition: stream.h:745
Definition: str.h:59
Definition: ustr.h:57
Definition: vfs.h:51
int listMatchingMembers(Common::ArchiveMemberList &list, const Common::Path &pattern, bool matchPathComponents=false) const override
int listMembers(Common::ArchiveMemberList &list) const override
const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override
Common::SeekableReadStream * createReadStreamForMemberAltStream(const Common::Path &path, Common::AltStreamType altStreamType) const override
char getPathSeparator() const override
Common::SeekableReadStream * createReadStreamForMember(const Common::Path &path) const override
bool isPathDirectory(const Common::Path &path) const override
bool hasFile(const Common::Path &path) const override
Definition: actions.h:25