22 #ifndef COMMON_ARCHIVE_H 23 #define COMMON_ARCHIVE_H 25 #include "common/error.h" 26 #include "common/hashmap.h" 27 #include "common/hash-str.h" 28 #include "common/list.h" 29 #include "common/path.h" 30 #include "common/ptr.h" 31 #include "common/singleton.h" 32 #include "common/str.h" 48 class SeekableReadStream;
50 enum class AltStreamType {
72 virtual SeekableReadStream *createReadStreamForAltStream(AltStreamType altStreamType)
const = 0;
78 virtual String getName()
const = 0;
80 virtual Path getPathInArchive()
const = 0;
81 virtual String getFileName()
const = 0;
82 virtual bool isDirectory()
const;
83 virtual void listChildren(ArchiveMemberList &childList,
const char *pattern =
nullptr)
const;
85 virtual bool isInMacArchive()
const;
89 ArchiveMemberPtr arcMember;
101 bool operator()(
const ArchiveMemberPtr &a,
const ArchiveMemberPtr &b) {
122 String getName()
const override;
123 Path getPathInArchive()
const override;
124 String getFileName()
const override;
126 SeekableReadStream *createReadStreamForAltStream(AltStreamType altStreamType)
const override;
127 bool isDirectory()
const override;
128 void listChildren(ArchiveMemberList &childList,
const char *pattern)
const override;
150 virtual bool hasFile(
const Path &path)
const = 0;
155 virtual bool isPathDirectory(
const Path &path)
const;
166 virtual int listMatchingMembers(ArchiveMemberList &list,
const Path &pattern,
bool matchPathComponents =
false)
const;
174 virtual int listMembers(ArchiveMemberList &list)
const = 0;
179 virtual const ArchiveMemberPtr getMember(
const Path &path)
const = 0;
195 virtual SeekableReadStream *createReadStreamForMemberAltStream(
const Path &path, AltStreamType altStreamType)
const;
202 return createReadStreamForMember(path);
213 virtual char getPathSeparator()
const;
228 _contentSize(contentSize), _missingFile(
false), _bypass(
nullptr) {}
229 SharedArchiveContents() : _strongRef(
nullptr), _weakRef(
nullptr), _contentSize(0), _missingFile(
true), _bypass(
nullptr) {}
237 bool isFileMissing()
const {
return _missingFile; }
239 uint32 getSize()
const {
return _contentSize; }
242 if (_strongRef || _contentSize == 0 || _missingFile)
252 if (_contentSize == 0)
254 _strongRef =
nullptr;
273 SeekableReadStream *createReadStreamForMemberAltStream(
const Path &path, Common::AltStreamType altStreamType)
const;
275 virtual Path translatePath(
const Path &path)
const {
280 virtual SharedArchiveContents readContentsForPathAltStream(
const Path &translatedPath, AltStreamType altStreamType)
const;
287 AltStreamType altStreamType;
290 struct CacheKey_EqualTo {
291 bool operator()(
const CacheKey &x,
const CacheKey &y)
const;
294 struct CacheKey_Hash {
295 uint operator()(
const CacheKey &x)
const;
298 SeekableReadStream *createReadStreamForMemberImpl(
const Path &path,
bool isAltStream, Common::AltStreamType altStreamType)
const;
301 uint32 _maxStronglyCachedSize;
318 Node(
int priority,
const String &name,
Archive *arc,
bool autoFree)
319 : _priority(priority), _name(name), _arc(arc), _autoFree(autoFree) {
323 ArchiveNodeList _list;
328 void insert(
const Node& node);
339 void add(
const String& name,
Archive *arch,
int priority = 0,
bool autoFree =
true);
344 void addDirectory(
const String &name,
const Path &directory,
int priority = 0,
int depth = 1,
bool flat =
false);
349 void addDirectory(
const String &name,
const FSNode &directory,
int priority = 0,
int depth = 1,
bool flat =
false);
354 void addDirectory(
const Path &directory,
int priority = 0,
int depth = 1,
bool flat =
false);
355 void addDirectory(
const FSNode &directory,
int priority = 0,
int depth = 1,
bool flat =
false);
378 addSubDirectoriesMatching(directory, caselessName,
true, priority, depth, flat);
399 void addSubDirectoriesMatching(
const FSNode &directory,
String origPattern,
bool ignoreCase,
int priority = 0,
int depth = 1,
bool flat =
false);
404 void remove(
const String& name);
409 bool hasArchive(
const String &name)
const;
419 virtual void clear();
424 void setPriority(
const String& name,
int priority);
426 bool hasFile(
const Path &path)
const override;
427 bool isPathDirectory(
const Path &path)
const override;
428 int listMatchingMembers(ArchiveMemberList &list,
const Path &pattern,
bool matchPathComponents =
false)
const override;
429 int listMatchingMembers(ArchiveMemberDetailsList &list,
const Path &pattern,
bool matchPathComponents =
false)
const;
430 int listMembers(ArchiveMemberList &list)
const override;
432 const ArchiveMemberPtr getMember(
const Path &path)
const override;
434 const ArchiveMemberPtr getMember(
const Path &path,
Archive **container)
const;
446 SeekableReadStream *createReadStreamForMemberAltStream(
const Path &path, AltStreamType altStreamType)
const override;
468 virtual void clear();
471 friend class Singleton<SingletonBaseType>;
476 #define SearchMan Common::SearchManager::instance() virtual SeekableReadStream * createReadStreamForMemberNext(const Path &path, const Archive *starting) const
Definition: archive.h:201
In find(In first, In last, const T &v)
Definition: algorithm.h:225
Definition: archive.h:117
Definition: archive.h:141
Definition: archive.h:100
void setIgnoreClashes(bool ignoreClashes)
Definition: archive.h:457
List< ArchiveMemberDetails > ArchiveMemberDetailsList
Definition: archive.h:95
Definition: archive.h:312
virtual String getName() const =0
Definition: algorithm.h:29
Definition: archive.h:461
SharedPtr< ArchiveMember > ArchiveMemberPtr
Definition: archive.h:57
Definition: list_intern.h:48
Definition: list_intern.h:51
Definition: archive.h:224
Definition: archive.h:269
void addSubDirectoryMatching(const FSNode &directory, const String &caselessName, int priority=0, int depth=1, bool flat=false)
Definition: archive.h:377
Definition: singleton.h:42
List< ArchiveMemberPtr > ArchiveMemberList
Definition: archive.h:58