aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Göffringmann2005-10-26 06:00:18 +0000
committerRobert Göffringmann2005-10-26 06:00:18 +0000
commit6f1016e71f61e398b7b7cf1e4cfeb8dcdbb11766 (patch)
treeb60584cc7db9d8a2cd2862eff7337e43ed161945
parentf043bfa38d90ceb5d51dd7dc57b14b5d3dd1706b (diff)
downloadscummvm-rg350-6f1016e71f61e398b7b7cf1e4cfeb8dcdbb11766.tar.gz
scummvm-rg350-6f1016e71f61e398b7b7cf1e4cfeb8dcdbb11766.tar.bz2
scummvm-rg350-6f1016e71f61e398b7b7cf1e4cfeb8dcdbb11766.zip
call OutSaveFile::flush() to check for errors
svn-id: r19298
-rw-r--r--sky/control.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/sky/control.cpp b/sky/control.cpp
index f76a36be49..3a6f205f30 100644
--- a/sky/control.cpp
+++ b/sky/control.cpp
@@ -1098,10 +1098,16 @@ void Control::saveDescriptions(uint8 *srcBuf) {
Common::OutSaveFile *outf;
outf = _saveFileMan->openForSaving("SKY-VM.SAV");
- if (outf != NULL) {
+ bool ioFailed = true;
+ if (outf) {
outf->write(tmpBuf, tmpPos - tmpBuf);
+ outf->flush();
+ if (!outf->ioFailed())
+ ioFailed = false;
delete outf;
}
+ if (ioFailed)
+ displayMessage(NULL, "Unable to store Savegame names to file SKY-VM.SAV in directory %s", _saveFileMan->getSavePath());
free(tmpBuf);
}
@@ -1121,7 +1127,10 @@ void Control::doAutoSave(void) {
uint8 *saveData = (uint8 *)malloc(0x20000);
uint32 fSize = prepareSaveData(saveData);
- if (outf->write(saveData, fSize) != fSize)
+ outf->write(saveData, fSize);
+ outf->flush();
+
+ if (outf->ioFailed())
displayMessage(0, "Unable to write autosave file '%s' in directory '%s'. Disk full?", fName, _saveFileMan->getSavePath());
delete outf;
@@ -1134,21 +1143,20 @@ uint16 Control::saveGameToFile(void) {
Common::OutSaveFile *outf;
outf = _saveFileMan->openForSaving(fName);
- if (outf == NULL) {
+ if (outf == NULL)
return NO_DISK_SPACE;
- }
uint8 *saveData = (uint8 *)malloc(0x20000);
uint32 fSize = prepareSaveData(saveData);
- if (outf->write(saveData, fSize) != fSize) {
- free(saveData);
- delete outf;
- return NO_DISK_SPACE;
- }
- delete outf;
+ uint32 writeRes = outf->write(saveData, fSize);
+ outf->flush();
+ if (outf->ioFailed())
+ writeRes = 0;
free(saveData);
- return GAME_SAVED;
+ delete outf;
+
+ return (writeRes == fSize) ? GAME_SAVED : NO_DISK_SPACE;
}
#define STOSD(ptr, val) { *(uint32 *)(ptr) = TO_LE_32(val); (ptr) += 4; }