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" ?)
|
||||
ArchiveMemberList allNames;
|
||||
listMembers(allNames);
|
||||
|
||||
String patternString = pattern.toString();
|
||||
int matches = 0;
|
||||
|
||||
ArchiveMemberList::const_iterator it = allNames.begin();
|
||||
for (; it != allNames.end(); ++it) {
|
||||
// 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.
|
||||
if ((*it)->getName().matchString(pattern, true, "/")) {
|
||||
if ((*it)->getName().matchString(patternString, true, "/")) {
|
||||
list.push_back(*it);
|
||||
matches++;
|
||||
}
|
||||
|
@ -218,7 +219,7 @@ bool SearchSet::hasFile(const Path &path) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
int SearchSet::listMatchingMembers(ArchiveMemberList &list, const String &pattern) const {
|
||||
int SearchSet::listMatchingMembers(ArchiveMemberList &list, const Path &pattern) const {
|
||||
int matches = 0;
|
||||
|
||||
ArchiveNodeList::const_iterator it = _list.begin();
|
||||
|
|
|
@ -116,7 +116,7 @@ public:
|
|||
*
|
||||
* @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.
|
||||
|
@ -253,7 +253,7 @@ public:
|
|||
void setPriority(const String& name, int priority);
|
||||
|
||||
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 const ArchiveMemberPtr getMember(const Path &path) const;
|
||||
|
|
|
@ -334,7 +334,7 @@ void FSDirectory::ensureCached() const {
|
|||
_cached = true;
|
||||
}
|
||||
|
||||
int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &pattern) const {
|
||||
int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const Path &pattern) const {
|
||||
if (!_node.isDirectory())
|
||||
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
|
||||
// stored as lowercase.
|
||||
String lowercasePattern(pattern);
|
||||
String lowercasePattern(pattern.rawString());
|
||||
lowercasePattern.toLowercase();
|
||||
|
||||
// Prevent wildcards from matching the directory separator.
|
||||
|
|
|
@ -375,7 +375,7 @@ public:
|
|||
/**
|
||||
* 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.
|
||||
|
|
|
@ -216,7 +216,7 @@ void MacResManager::listFiles(StringArray &files, const String &pattern) {
|
|||
SearchMan.listMatchingMembers(memberList, pattern);
|
||||
SearchMan.listMatchingMembers(memberList, pattern + ".rsrc");
|
||||
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) {
|
||||
String filename = (*i)->getName();
|
||||
|
|
|
@ -147,10 +147,11 @@ bool XARCArchive::hasFile(const Common::Path &path) const {
|
|||
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;
|
||||
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
|
||||
list.push_back(*it);
|
||||
matches++;
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
|
||||
// Archive API
|
||||
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;
|
||||
const Common::ArchiveMemberPtr getMember(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);
|
||||
}
|
||||
|
||||
int UltimaDataArchive::listMatchingMembers(Common::ArchiveMemberList &list, const Common::String &pattern) const {
|
||||
Common::String patt = pattern;
|
||||
if (pattern.hasPrefixIgnoreCase(_publicFolder))
|
||||
patt = innerToPublic(pattern);
|
||||
int UltimaDataArchive::listMatchingMembers(Common::ArchiveMemberList &list, const Common::Path &pattern) const {
|
||||
Common::String patt = pattern.toString();
|
||||
if (patt.hasPrefixIgnoreCase(_publicFolder))
|
||||
patt = innerToPublic(patt);
|
||||
|
||||
// Get any matching files
|
||||
Common::ArchiveMemberList innerList;
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
* @return the number of members added to 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.
|
||||
|
@ -148,7 +148,7 @@ public:
|
|||
* @return the number of members added to list
|
||||
*/
|
||||
int listMatchingMembers(Common::ArchiveMemberList &list,
|
||||
const Common::String &pattern) const override {
|
||||
const Common::Path &pattern) const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue