Skip to content

Commit

Permalink
DREAMCAST: Fix listing of savefiles.
Browse files Browse the repository at this point in the history
We introduced a new pattern '#' in 06641f2.
Starting from that commit all backends were supposed to support it. Dreamcast
was missed. To support it in Dreamcast we now use Common::String::matchString
to do pattern matching.

(cherry picked from commit 47f82d4)
  • Loading branch information
Johannes Schickel committed Feb 25, 2016
1 parent 9b25b3a commit c9ed793
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions backends/platform/dc/vmsave.cpp
Expand Up @@ -165,30 +165,7 @@ static bool tryDelete(const char *filename, int vm)
return true;
}

static bool matches(const char *glob, const char *name)
{
while(*glob)
if(*glob == '*') {
while(*glob == '*')
glob++;
do {
if((*name == *glob || *glob == '?') &&
matches(glob, name))
return true;
} while(*name++);
return false;
} else if(!*name)
return false;
else if(*glob == '?' || *glob == *name) {
glob++;
name++;
}
else
return false;
return !*name;
}

static void tryList(const char *glob, int vm, Common::StringArray &list)
static void tryList(const Common::String &glob, int vm, Common::StringArray &list)
{
struct vmsinfo info;
struct superblock super;
Expand All @@ -205,7 +182,7 @@ static void tryList(const char *glob, int vm, Common::StringArray &list)
char buf[16];
strncpy(buf, (char *)de.entry+4, 12);
buf[12] = 0;
if (matches(glob, buf))
if (glob.matchString(buf))
list.push_back(buf);
}
}
Expand Down Expand Up @@ -425,7 +402,7 @@ Common::StringArray VMSaveManager::listSavefiles(const Common::String &pattern)
Common::StringArray list;

for (int i=0; i<24; i++)
tryList(pattern.c_str(), i, list);
tryList(pattern, i, list);

return list;
}
Expand Down

0 comments on commit c9ed793

Please sign in to comment.