ALL: Change listMatchingMembers pattern to a Path
This handles any potential differences in directory separators passed to the function, as with the other Archive functions.
This commit is contained in:
parent
2aa7e3e558
commit
ba28d7fde6
9 changed files with 20 additions and 18 deletions
|
@ -40,18 +40,19 @@ SeekableReadStream *GenericArchiveMember::createReadStream() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Archive::listMatchingMembers(ArchiveMemberList &list, const String &pattern) const {
|
int Archive::listMatchingMembers(ArchiveMemberList &list, const Path &pattern) const {
|
||||||
// Get all "names" (TODO: "files" ?)
|
// Get all "names" (TODO: "files" ?)
|
||||||
ArchiveMemberList allNames;
|
ArchiveMemberList allNames;
|
||||||
listMembers(allNames);
|
listMembers(allNames);
|
||||||
|
|
||||||
|
String patternString = pattern.toString();
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
|
|
||||||
ArchiveMemberList::const_iterator it = allNames.begin();
|
ArchiveMemberList::const_iterator it = allNames.begin();
|
||||||
for (; it != allNames.end(); ++it) {
|
for (; it != allNames.end(); ++it) {
|
||||||
// TODO: We match case-insenstivie for now, our API does not define whether that's ok or not though...
|
// TODO: We match case-insenstivie for now, our API does not define whether that's ok or not though...
|
||||||
// For our use case case-insensitive is probably what we want to have though.
|
// For our use case case-insensitive is probably what we want to have though.
|
||||||
if ((*it)->getName().matchString(pattern, true, "/")) {
|
if ((*it)->getName().matchString(patternString, true, "/")) {
|
||||||
list.push_back(*it);
|
list.push_back(*it);
|
||||||
matches++;
|
matches++;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +219,7 @@ bool SearchSet::hasFile(const Path &path) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SearchSet::listMatchingMembers(ArchiveMemberList &list, const String &pattern) const {
|
int SearchSet::listMatchingMembers(ArchiveMemberList &list, const Path &pattern) const {
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
|
|
||||||
ArchiveNodeList::const_iterator it = _list.begin();
|
ArchiveNodeList::const_iterator it = _list.begin();
|
||||||
|
|
|
@ -116,7 +116,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return The number of members added to list.
|
* @return The number of members added to list.
|
||||||
*/
|
*/
|
||||||
virtual int listMatchingMembers(ArchiveMemberList &list, const String &pattern) const;
|
virtual int listMatchingMembers(ArchiveMemberList &list, const Path &pattern) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add all members of the Archive to the list.
|
* Add all members of the Archive to the list.
|
||||||
|
@ -253,7 +253,7 @@ public:
|
||||||
void setPriority(const String& name, int priority);
|
void setPriority(const String& name, int priority);
|
||||||
|
|
||||||
virtual bool hasFile(const Path &path) const;
|
virtual bool hasFile(const Path &path) const;
|
||||||
virtual int listMatchingMembers(ArchiveMemberList &list, const String &pattern) const;
|
virtual int listMatchingMembers(ArchiveMemberList &list, const Path &pattern) const;
|
||||||
virtual int listMembers(ArchiveMemberList &list) const;
|
virtual int listMembers(ArchiveMemberList &list) const;
|
||||||
|
|
||||||
virtual const ArchiveMemberPtr getMember(const Path &path) const;
|
virtual const ArchiveMemberPtr getMember(const Path &path) const;
|
||||||
|
|
|
@ -334,7 +334,7 @@ void FSDirectory::ensureCached() const {
|
||||||
_cached = true;
|
_cached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &pattern) const {
|
int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const Path &pattern) const {
|
||||||
if (!_node.isDirectory())
|
if (!_node.isDirectory())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &patt
|
||||||
|
|
||||||
// need to match lowercase key, since all entries in our file cache are
|
// need to match lowercase key, since all entries in our file cache are
|
||||||
// stored as lowercase.
|
// stored as lowercase.
|
||||||
String lowercasePattern(pattern);
|
String lowercasePattern(pattern.rawString());
|
||||||
lowercasePattern.toLowercase();
|
lowercasePattern.toLowercase();
|
||||||
|
|
||||||
// Prevent wildcards from matching the directory separator.
|
// Prevent wildcards from matching the directory separator.
|
||||||
|
|
|
@ -375,7 +375,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Return a list of matching file names. Pattern can use GLOB wildcards.
|
* Return a list of matching file names. Pattern can use GLOB wildcards.
|
||||||
*/
|
*/
|
||||||
virtual int listMatchingMembers(ArchiveMemberList &list, const String &pattern) const;
|
virtual int listMatchingMembers(ArchiveMemberList &list, const Path &pattern) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of all the files in the cache.
|
* Return a list of all the files in the cache.
|
||||||
|
|
|
@ -216,7 +216,7 @@ void MacResManager::listFiles(StringArray &files, const String &pattern) {
|
||||||
SearchMan.listMatchingMembers(memberList, pattern);
|
SearchMan.listMatchingMembers(memberList, pattern);
|
||||||
SearchMan.listMatchingMembers(memberList, pattern + ".rsrc");
|
SearchMan.listMatchingMembers(memberList, pattern + ".rsrc");
|
||||||
SearchMan.listMatchingMembers(memberList, pattern + ".bin");
|
SearchMan.listMatchingMembers(memberList, pattern + ".bin");
|
||||||
SearchMan.listMatchingMembers(memberList, constructAppleDoubleName(pattern).toString());
|
SearchMan.listMatchingMembers(memberList, constructAppleDoubleName(pattern));
|
||||||
|
|
||||||
for (ArchiveMemberList::const_iterator i = memberList.begin(), end = memberList.end(); i != end; ++i) {
|
for (ArchiveMemberList::const_iterator i = memberList.begin(), end = memberList.end(); i != end; ++i) {
|
||||||
String filename = (*i)->getName();
|
String filename = (*i)->getName();
|
||||||
|
|
|
@ -147,10 +147,11 @@ bool XARCArchive::hasFile(const Common::Path &path) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int XARCArchive::listMatchingMembers(Common::ArchiveMemberList &list, const Common::String &pattern) const {
|
int XARCArchive::listMatchingMembers(Common::ArchiveMemberList &list, const Common::Path &pattern) const {
|
||||||
|
Common::String patternString = pattern.toString();
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
for (Common::ArchiveMemberList::const_iterator it = _members.begin(); it != _members.end(); ++it) {
|
for (Common::ArchiveMemberList::const_iterator it = _members.begin(); it != _members.end(); ++it) {
|
||||||
if ((*it)->getName().matchString(pattern)) {
|
if ((*it)->getName().matchString(patternString)) {
|
||||||
// This file matches, add it
|
// This file matches, add it
|
||||||
list.push_back(*it);
|
list.push_back(*it);
|
||||||
matches++;
|
matches++;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
|
|
||||||
// Archive API
|
// Archive API
|
||||||
bool hasFile(const Common::Path &path) const;
|
bool hasFile(const Common::Path &path) const;
|
||||||
int listMatchingMembers(Common::ArchiveMemberList &list, const Common::String &pattern) const;
|
int listMatchingMembers(Common::ArchiveMemberList &list, const Common::Path &pattern) const;
|
||||||
int listMembers(Common::ArchiveMemberList &list) const;
|
int listMembers(Common::ArchiveMemberList &list) const;
|
||||||
const Common::ArchiveMemberPtr getMember(const Common::Path &path) const;
|
const Common::ArchiveMemberPtr getMember(const Common::Path &path) const;
|
||||||
Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const;
|
Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const;
|
||||||
|
|
|
@ -125,10 +125,10 @@ bool UltimaDataArchive::hasFile(const Common::Path &path) const {
|
||||||
return _zip->hasFile(realFilename);
|
return _zip->hasFile(realFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
int UltimaDataArchive::listMatchingMembers(Common::ArchiveMemberList &list, const Common::String &pattern) const {
|
int UltimaDataArchive::listMatchingMembers(Common::ArchiveMemberList &list, const Common::Path &pattern) const {
|
||||||
Common::String patt = pattern;
|
Common::String patt = pattern.toString();
|
||||||
if (pattern.hasPrefixIgnoreCase(_publicFolder))
|
if (patt.hasPrefixIgnoreCase(_publicFolder))
|
||||||
patt = innerToPublic(pattern);
|
patt = innerToPublic(patt);
|
||||||
|
|
||||||
// Get any matching files
|
// Get any matching files
|
||||||
Common::ArchiveMemberList innerList;
|
Common::ArchiveMemberList innerList;
|
||||||
|
|
|
@ -81,7 +81,7 @@ public:
|
||||||
* @return the number of members added to list
|
* @return the number of members added to list
|
||||||
*/
|
*/
|
||||||
int listMatchingMembers(Common::ArchiveMemberList &list,
|
int listMatchingMembers(Common::ArchiveMemberList &list,
|
||||||
const Common::String &pattern) const override;
|
const Common::Path &pattern) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add all members of the Archive to list.
|
* Add all members of the Archive to list.
|
||||||
|
@ -148,7 +148,7 @@ public:
|
||||||
* @return the number of members added to list
|
* @return the number of members added to list
|
||||||
*/
|
*/
|
||||||
int listMatchingMembers(Common::ArchiveMemberList &list,
|
int listMatchingMembers(Common::ArchiveMemberList &list,
|
||||||
const Common::String &pattern) const override {
|
const Common::Path &pattern) const override {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue