Get rid of errno; add some (optional) error checking facilities to SaveFile classes (they are ugly, and to simple, but better than nothing)
svn-id: r17589
This commit is contained in:
parent
a5993b2112
commit
839c8add38
5 changed files with 45 additions and 41 deletions
|
@ -21,13 +21,6 @@
|
|||
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
// FIXME TODO FIXME: Using errno is not really portable!
|
||||
// We should get rid of this, possibly by adding (clear)ioFailed methods
|
||||
// to the SaveFile class.
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include "gui/about.h"
|
||||
#include "gui/message.h"
|
||||
|
||||
|
@ -413,11 +406,6 @@ bool SimonEngine::save_game(uint slot, char *caption) {
|
|||
|
||||
_lock_word |= 0x100;
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
errno = 0;
|
||||
#endif
|
||||
|
||||
|
||||
f = _saveFileMan->openForSaving(gen_savename(slot));
|
||||
if (f == NULL) {
|
||||
_lock_word &= ~0x100;
|
||||
|
@ -514,11 +502,6 @@ bool SimonEngine::load_game(uint slot) {
|
|||
|
||||
_lock_word |= 0x100;
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
errno = 0;
|
||||
#endif
|
||||
|
||||
|
||||
f = _saveFileMan->openForLoading(gen_savename(slot));
|
||||
if (f == NULL) {
|
||||
_lock_word &= ~0x100;
|
||||
|
@ -606,6 +589,10 @@ bool SimonEngine::load_game(uint slot) {
|
|||
// Write the bits in array 1 & 2
|
||||
for (i = 0; i != 32; i++)
|
||||
_bit_array[i] = f->readUint16BE();
|
||||
|
||||
if (f->readingFailed()) {
|
||||
error("load failed");
|
||||
}
|
||||
|
||||
delete f;
|
||||
|
||||
|
@ -613,11 +600,6 @@ bool SimonEngine::load_game(uint slot) {
|
|||
|
||||
_lock_word &= ~0x100;
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
if (errno != 0)
|
||||
error("load failed");
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue