diff options
author | Robert Göffringmann | 2005-10-26 06:30:28 +0000 |
---|---|---|
committer | Robert Göffringmann | 2005-10-26 06:30:28 +0000 |
commit | ccd7557a87ff63a4dca00c589f24cb9f4baf100c (patch) | |
tree | 085e41c7a560ee201c930242631b0c68fb9a0cc5 /sword1/control.cpp | |
parent | 722e9a7986ee7d02f6b6ccc0fce588a4d1150d12 (diff) | |
download | scummvm-rg350-ccd7557a87ff63a4dca00c589f24cb9f4baf100c.tar.gz scummvm-rg350-ccd7557a87ff63a4dca00c589f24cb9f4baf100c.tar.bz2 scummvm-rg350-ccd7557a87ff63a4dca00c589f24cb9f4baf100c.zip |
added call to OutSaveFile::flush() and some more I/O error checks
svn-id: r19302
Diffstat (limited to 'sword1/control.cpp')
-rw-r--r-- | sword1/control.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sword1/control.cpp b/sword1/control.cpp index b7afc1ada6..8613e387bf 100644 --- a/sword1/control.cpp +++ b/sword1/control.cpp @@ -750,7 +750,7 @@ void Control::writeSavegameDescriptions(void) { if (!outf) { // Display an error message, and do nothing - displayMessage(0, "Unable to write to path '%s'", _saveFileMan->getSavePath()); + displayMessage(0, "Can't create SAVEGAME.INF in directory '%s'", _saveFileMan->getSavePath()); return; } @@ -765,6 +765,9 @@ void Control::writeSavegameDescriptions(void) { else outf->writeByte(255); } + outf->flush(); + if (outf->ioFailed()) + displayMessage(0, "Can't write to SAVEGAME.INF in directory '%s'. Device full?", _saveFileMan->getSavePath()); delete outf; } @@ -934,7 +937,7 @@ void Control::saveGameToFile(uint8 slot) { Common::OutSaveFile *outf; outf = _saveFileMan->openForSaving(fName); if (!outf) { - // Display an error message, and do nothing + // Display an error message and do nothing displayMessage(0, "Unable to create file '%s' in directory '%s'", fName, _saveFileMan->getSavePath()); return; } @@ -957,6 +960,9 @@ void Control::saveGameToFile(uint8 slot) { uint32 *playerRaw = (uint32*)cpt; for (uint32 cnt2 = 0; cnt2 < playerSize; cnt2++) outf->writeUint32LE(playerRaw[cnt2]); + outf->flush(); + if (outf->ioFailed()) + displayMessage(0, "Couldn't write to file '%s' in directory '%s'. Device full?", fName, _saveFileMan->getSavePath()); delete outf; } @@ -991,6 +997,13 @@ bool Control::restoreGameFromFile(uint8 slot) { for (uint32 cnt2 = 0; cnt2 < playerSize; cnt2++) playerBuf[cnt2] = inf->readUint32LE(); + if (inf->ioFailed()) { + displayMessage(0, "Can't read from file '%s' in directory '%s'", fName, _saveFileMan->getSavePath()); + delete inf; + free(_restoreBuf); + _restoreBuf = NULL; + return false; + } delete inf; return true; } |