diff options
author | Max Horn | 2009-05-29 14:38:22 +0000 |
---|---|---|
committer | Max Horn | 2009-05-29 14:38:22 +0000 |
commit | fb79b185717c9aae7c793e7f07d5d6b94aec4abf (patch) | |
tree | 6df973c3f64d5712d6df36caa0af30b6b6012561 /backends/platform/ps2 | |
parent | 518e005ec27ef323275b364a3cd16d24d7491674 (diff) | |
download | scummvm-rg350-fb79b185717c9aae7c793e7f07d5d6b94aec4abf.tar.gz scummvm-rg350-fb79b185717c9aae7c793e7f07d5d6b94aec4abf.tar.bz2 scummvm-rg350-fb79b185717c9aae7c793e7f07d5d6b94aec4abf.zip |
Changed SaveFileManager methods to take Common::String params (instead of char pointers)
svn-id: r41000
Diffstat (limited to 'backends/platform/ps2')
-rw-r--r-- | backends/platform/ps2/savefilemgr.cpp | 56 | ||||
-rw-r--r-- | backends/platform/ps2/savefilemgr.h | 8 |
2 files changed, 34 insertions, 30 deletions
diff --git a/backends/platform/ps2/savefilemgr.cpp b/backends/platform/ps2/savefilemgr.cpp index d15beb418a..1271a43d42 100644 --- a/backends/platform/ps2/savefilemgr.cpp +++ b/backends/platform/ps2/savefilemgr.cpp @@ -82,7 +82,7 @@ void Ps2SaveFileManager::mcSplit(char *full, char *game, char *ext) { // TODO } -Common::InSaveFile *Ps2SaveFileManager::openForLoading(const char *filename) { +Common::InSaveFile *Ps2SaveFileManager::openForLoading(const Common::String &filename) { Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast? Common::SeekableReadStream *sf; @@ -93,33 +93,35 @@ Common::InSaveFile *Ps2SaveFileManager::openForLoading(const char *filename) { if (_getDev(savePath) == MC_DEV) { // if (strncmp(savePath.getPath().c_str(), "mc0:", 4) == 0) { - char *game=0, *ext=0, path[32], temp[32]; + char path[32]; // FIXME : hack for indy4 iq-points - if (strcmp(filename, "iq-points") == 0) { + if (filename == "iq-points") { mcCheck("mc0:ScummVM/indy4"); sprintf(path, "mc0:ScummVM/indy4/iq-points"); } // FIXME : hack for bs1 saved games - else if (strcmp(filename, "SAVEGAME.INF") == 0) { + else if (filename == "SAVEGAME.INF") { mcCheck("mc0:ScummVM/sword1"); sprintf(path, "mc0:ScummVM/sword1/SAVEGAME.INF"); } else { - printf("MC : filename = %s\n", filename); - strcpy(temp, filename); + char temp[32]; + printf("MC : filename = %s\n", filename.c_str()); + strcpy(temp, filename.c_str()); // mcSplit(temp, game, ext); - game = strdup(strtok(temp, ".")); - ext = strdup(strtok(NULL, "*")); + char *game = strdup(strtok(temp, ".")); + char *ext = strdup(strtok(NULL, "*")); sprintf(path, "mc0:ScummVM/%s", game); // per game path // mcCheck(path); // needed on load ? sprintf(path, "mc0:ScummVM/%s/%s.sav", game, ext); + + free(game); + free(ext); } - free(game); - free(ext); Common::FSNode file(path); @@ -142,11 +144,11 @@ Common::InSaveFile *Ps2SaveFileManager::openForLoading(const char *filename) { return Common::wrapCompressedReadStream(sf); } -Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const char *filename) { +Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &filename) { Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast? Common::WriteStream *sf; - printf("openForSaving : %s\n", filename); + printf("openForSaving : %s\n", filename.c_str()); if (!savePath.exists() || !savePath.isDirectory()) return NULL; @@ -155,33 +157,35 @@ Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const char *filename) { if (_getDev(savePath) == MC_DEV) { // if (strncmp(savePath.getPath().c_str(), "mc0:", 4) == 0) { - char *game=0, *ext=0, path[32], temp[32]; + char path[32]; // FIXME : hack for indy4 iq-points - if (strcmp(filename, "iq-points") == 0) { + if (filename == "iq-points") { mcCheck("mc0:ScummVM/indy4"); sprintf(path, "mc0:ScummVM/indy4/iq-points"); } // FIXME : hack for bs1 saved games - else if (strcmp(filename, "SAVEGAME.INF") == 0) { + else if (filename == "SAVEGAME.INF") { mcCheck("mc0:ScummVM/sword1"); sprintf(path, "mc0:ScummVM/sword1/SAVEGAME.INF"); } else { - strcpy(temp, filename); + char temp[32]; + strcpy(temp, filename.c_str()); // mcSplit(temp, game, ext); - game = strdup(strtok(temp, ".")); - ext = strdup(strtok(NULL, "*")); + char *game = strdup(strtok(temp, ".")); + char *ext = strdup(strtok(NULL, "*")); sprintf(path, "mc0:ScummVM/%s", game); // per game path mcCheck(path); sprintf(path, "mc0:ScummVM/%s/%s.sav", game, ext); + + free(game); + free(ext); } Common::FSNode file(path); sf = file.createWriteStream(); - free(game); - free(ext); } else { Common::FSNode file = savePath.getChild(filename); sf = file.createWriteStream(); @@ -191,7 +195,7 @@ Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const char *filename) { return Common::wrapCompressedWriteStream(sf); } -bool Ps2SaveFileManager::removeSavefile(const char *filename) { +bool Ps2SaveFileManager::removeSavefile(const Common::String &filename) { Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast? Common::FSNode file; @@ -200,12 +204,12 @@ bool Ps2SaveFileManager::removeSavefile(const char *filename) { if (_getDev(savePath) == MC_DEV) { // if (strncmp(savePath.getPath().c_str(), "mc0:", 4) == 0) { - char *game=0, *ext=0, path[32], temp[32]; - strcpy(temp, filename); + char path[32], temp[32]; + strcpy(temp, filename.c_str()); // mcSplit(temp, game, ext); - game = strdup(strtok(temp, ".")); - ext = strdup(strtok(NULL, "*")); + char *game = strdup(strtok(temp, ".")); + char *ext = strdup(strtok(NULL, "*")); sprintf(path, "mc0:ScummVM/%s", game); // per game path mcCheck(path); sprintf(path, "mc0:ScummVM/%s/%s.sav", game, ext); @@ -224,7 +228,7 @@ bool Ps2SaveFileManager::removeSavefile(const char *filename) { return true; } -Common::StringList Ps2SaveFileManager::listSavefiles(const char *pattern) { +Common::StringList Ps2SaveFileManager::listSavefiles(const Common::String &pattern) { Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast? Common::String _dir; Common::String search; diff --git a/backends/platform/ps2/savefilemgr.h b/backends/platform/ps2/savefilemgr.h index 806aae0913..b1599c70f6 100644 --- a/backends/platform/ps2/savefilemgr.h +++ b/backends/platform/ps2/savefilemgr.h @@ -37,10 +37,10 @@ public: Ps2SaveFileManager(OSystem_PS2 *system, Gs2dScreen *screen); virtual ~Ps2SaveFileManager(); - virtual Common::InSaveFile *openForLoading(const char *filename); - virtual Common::OutSaveFile *openForSaving(const char *filename); - virtual Common::StringList listSavefiles(const char *regex); - virtual bool removeSavefile(const char *filename); + virtual Common::InSaveFile *openForLoading(const Common::String &filename); + virtual Common::OutSaveFile *openForSaving(const Common::String &filename); + virtual Common::StringList listSavefiles(const Common::String &pattern); + virtual bool removeSavefile(const Common::String &filename); // void writeSaveNonblocking(char *name, void *buf, uint32 size); // void saveThread(void); |