diff options
Diffstat (limited to 'backends/platform/dc/vmsave.cpp')
-rw-r--r-- | backends/platform/dc/vmsave.cpp | 48 |
1 files changed, 13 insertions, 35 deletions
diff --git a/backends/platform/dc/vmsave.cpp b/backends/platform/dc/vmsave.cpp index 5f5cdff24f..d896ba1299 100644 --- a/backends/platform/dc/vmsave.cpp +++ b/backends/platform/dc/vmsave.cpp @@ -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; @@ -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 (Common::matchString(buf, glob.c_str())) list.push_back(buf); } } @@ -292,15 +269,16 @@ public: class OutVMSave : public Common::OutSaveFile { private: char *buffer; - int pos, size, committed; + int _pos, size, committed; char filename[16]; bool iofailed; public: uint32 write(const void *buf, uint32 cnt); + virtual int32 pos() const { return _pos; } OutVMSave(const char *_filename) - : pos(0), committed(-1), iofailed(false) + : _pos(0), committed(-1), iofailed(false) { strncpy(filename, _filename, 16); buffer = new char[size = MAX_SAVE_SIZE]; @@ -343,14 +321,14 @@ void OutVMSave::finalize() extern const char *gGameName; extern Icon icon; - if (committed >= pos) + if (committed >= _pos) return; char *data = buffer; - int len = pos; + int len = _pos; vmsaveResult r = writeSaveGame(gGameName, data, len, filename, icon); - committed = pos; + committed = _pos; if (r != VMSAVE_OK) iofailed = true; displaySaveResult(r); @@ -409,13 +387,13 @@ bool InVMSave::seek(int32 offs, int whence) uint32 OutVMSave::write(const void *buf, uint32 cnt) { int nbyt = cnt; - if (pos + nbyt > size) { - cnt = (size - pos); + if (_pos + nbyt > size) { + cnt = (size - _pos); nbyt = cnt; } if (nbyt) - memcpy(buffer + pos, buf, nbyt); - pos += nbyt; + memcpy(buffer + _pos, buf, nbyt); + _pos += nbyt; return cnt; } @@ -425,7 +403,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; } |