Ticket #8762: getsavepath.patch
File getsavepath.patch, 8.5 KB (added by , 17 years ago) |
---|
-
home/david/Projects/scummvm/backends/saves/default/default-saves.cpp
Property changes on: /home/david/Projects/scummvm ___________________________________________________________________ Name: svn:ignore - config.log scummvm scummvm-static config.h config.mk .gdb_history dumps Credits.rtf *.mshark + .project config.h config.mk reconf.sh scummvm plugins
29 29 #include "common/util.h" 30 30 #include "common/fs.h" 31 31 #include "common/file.h" 32 #include "common/config-manager.h" 32 33 #include "backends/saves/default/default-saves.h" 33 34 #include "backends/saves/compressed/compressed-saves.h" 34 35 … … 249 250 } 250 251 } 251 252 253 const char *DefaultSaveFileManager::getSavePath() const { 254 255 #if defined(PALMOS_MODE) || defined(__PSP__) 256 return SCUMMVM_SAVEPATH; 257 #else 258 259 const char *dir = NULL; 260 261 // Try to use game specific savepath from config 262 dir = ConfMan.get("savepath").c_str(); 263 264 // Work around a bug (#999122) in the original 0.6.1 release of 265 // ScummVM, which would insert a bad savepath value into config files. 266 if (0 == strcmp(dir, "None")) { 267 ConfMan.removeKey("savepath", ConfMan.getActiveDomainName()); 268 ConfMan.flushToDisk(); 269 dir = ConfMan.get("savepath").c_str(); 270 } 271 272 #ifdef _WIN32_WCE 273 if (dir[0] == 0) 274 dir = ConfMan.get("path").c_str(); 275 #endif 276 277 assert(dir); 278 279 return dir; 280 #endif 281 } 282 252 283 #endif // !defined(DISABLE_DEFAULT_SAVEFILEMANAGER) -
home/david/Projects/scummvm/backends/saves/default/default-saves.h
29 29 #include "common/savefile.h" 30 30 #include "common/str.h" 31 31 32 /** 33 * Provides a default savefile manager implementation for common platforms. 34 */ 32 35 class DefaultSaveFileManager : public Common::SaveFileManager { 33 36 public: 34 37 virtual Common::StringList listSavefiles(const char *regex); … … 35 38 virtual Common::InSaveFile *openForLoading(const char *filename); 36 39 virtual Common::OutSaveFile *openForSaving(const char *filename); 37 40 virtual bool removeSavefile(const char *filename); 41 42 protected: 43 /** 44 * Get the path to the save game directory. 45 * Should only be used internally since some platforms 46 * might implement savefiles in a completely different way. 47 */ 48 virtual const char *getSavePath() const; 38 49 }; 39 50 40 51 #endif -
home/david/Projects/scummvm/backends/saves/savefile.cpp
24 24 */ 25 25 26 26 #include "common/util.h" 27 #include "common/config-manager.h"28 27 #include "common/savefile.h" 29 28 30 29 #include <stdio.h> … … 72 71 return success; 73 72 } 74 73 75 const char *SaveFileManager::getSavePath() const { 76 77 #if defined(PALMOS_MODE) || defined(__PSP__) 78 return SCUMMVM_SAVEPATH; 79 #else 80 81 const char *dir = NULL; 82 83 // Try to use game specific savepath from config 84 dir = ConfMan.get("savepath").c_str(); 85 86 // Work around a bug (#999122) in the original 0.6.1 release of 87 // ScummVM, which would insert a bad savepath value into config files. 88 if (0 == strcmp(dir, "None")) { 89 ConfMan.removeKey("savepath", ConfMan.getActiveDomainName()); 90 ConfMan.flushToDisk(); 91 dir = ConfMan.get("savepath").c_str(); 92 } 93 94 #ifdef _WIN32_WCE 95 if (dir[0] == 0) 96 dir = ConfMan.get("path").c_str(); 97 #endif 98 99 assert(dir); 100 101 return dir; 102 #endif 74 String SaveFileManager::popErrorDesc() { 75 String err = _errorDesc; 76 clearError(); 77 78 return err; 103 79 } 104 80 105 81 } // End of namespace Common -
home/david/Projects/scummvm/common/savefile.h
109 109 * @return A string describing the last error. 110 110 */ 111 111 virtual String getErrorDesc() { return _errorDesc; } 112 112 113 /** 114 * Returns the last ocurred error description. If none ocurred, returns 0. 115 * Also clears the last error state and description. 116 * 117 * @return A string describing the last error. 118 */ 119 virtual String popErrorDesc(); 120 113 121 /** 114 122 * Open the file with name filename in the given directory for saving. 115 123 * @param filename the filename … … 145 153 * returns a list of strings for all present file names. 146 154 */ 147 155 virtual Common::StringList listSavefiles(const char *regex) = 0; 148 149 /**150 * Get the path to the save game directory.151 * Should only be used for error messages, *never* to construct file paths152 * from it, since that is highly unportable!153 */154 virtual const char *getSavePath() const;155 156 }; 156 157 157 158 } // End of namespace Common -
home/david/Projects/scummvm/engines/sky/control.cpp
944 944 refreshNames = true; 945 945 } 946 946 if (clickRes == NO_DISK_SPACE) { 947 displayMessage(0, "Could not save game in directory '%s'", _saveFileMan->getSavePath());947 displayMessage(0, _saveFileMan->popErrorDesc().c_str()); 948 948 quitPanel = true; 949 949 } 950 950 if ((clickRes == CANCEL_PRESSED) || (clickRes == GAME_RESTORED)) … … 1153 1153 delete outf; 1154 1154 } 1155 1155 if (ioFailed) 1156 displayMessage(NULL, "Unable to store Savegame names to file SKY-VM.SAV in directory %s", _saveFileMan->getSavePath());1156 displayMessage(NULL, _saveFileMan->popErrorDesc().c_str()); 1157 1157 free(tmpBuf); 1158 1158 } 1159 1159 … … 1167 1167 1168 1168 outf = _saveFileMan->openForSaving(fName); 1169 1169 if (outf == NULL) { 1170 displayMessage(0, "Unable to create autosave file '%s' in directory '%s'", fName, _saveFileMan->getSavePath());1170 displayMessage(0, _saveFileMan->popErrorDesc().c_str()); 1171 1171 return; 1172 1172 } 1173 1173 uint8 *saveData = (uint8 *)malloc(0x20000); … … 1177 1177 outf->finalize(); 1178 1178 1179 1179 if (outf->ioFailed()) 1180 displayMessage(0, "Unable to write autosave file '%s' in directory '%s'. Disk full?", fName, _saveFileMan->getSavePath());1180 displayMessage(0, _saveFileMan->popErrorDesc().c_str()); 1181 1181 1182 1182 delete outf; 1183 1183 free(saveData); -
home/david/Projects/scummvm/engines/sword1/control.cpp
738 738 739 739 if (!outf) { 740 740 // Display an error message, and do nothing 741 displayMessage(0, "Can't create SAVEGAME.INF in directory '%s'", _saveFileMan->getSavePath());741 displayMessage(0, _saveFileMan->popErrorDesc().c_str()); 742 742 return; 743 743 } 744 744 … … 757 757 } 758 758 outf->finalize(); 759 759 if (outf->ioFailed()) 760 displayMessage(0, "Can't write to SAVEGAME.INF in directory '%s'. Device full?", _saveFileMan->getSavePath());760 displayMessage(0, _saveFileMan->popErrorDesc().c_str()); 761 761 delete outf; 762 762 } 763 763 … … 928 928 outf = _saveFileMan->openForSaving(fName); 929 929 if (!outf) { 930 930 // Display an error message and do nothing 931 displayMessage(0, "Unable to create file '%s' in directory '%s'", fName, _saveFileMan->getSavePath());931 displayMessage(0, _saveFileMan->getErrorDesc().c_str()); 932 932 return; 933 933 } 934 934 … … 952 952 outf->writeUint32LE(playerRaw[cnt2]); 953 953 outf->finalize(); 954 954 if (outf->ioFailed()) 955 displayMessage(0, "Couldn't write to file '%s' in directory '%s'. Device full?", fName, _saveFileMan->getSavePath());955 displayMessage(0, _saveFileMan->popErrorDesc().c_str()); 956 956 delete outf; 957 957 } 958 958 … … 964 964 inf = _saveFileMan->openForLoading(fName); 965 965 if (!inf) { 966 966 // Display an error message, and do nothing 967 displayMessage(0, "Can't open file '%s' in directory '%s'", fName, _saveFileMan->getSavePath());967 displayMessage(0, _saveFileMan->popErrorDesc().c_str()); 968 968 return false; 969 969 } 970 970 … … 988 988 playerBuf[cnt2] = inf->readUint32LE(); 989 989 990 990 if (inf->ioFailed()) { 991 displayMessage(0, "Can't read from file '%s' in directory '%s'", fName, _saveFileMan->getSavePath());991 displayMessage(0, _saveFileMan->popErrorDesc().c_str()); 992 992 delete inf; 993 993 free(_restoreBuf); 994 994 _restoreBuf = NULL;