aboutsummaryrefslogtreecommitdiff
path: root/common/savefile.cpp
diff options
context:
space:
mode:
authorMax Horn2004-04-17 09:57:15 +0000
committerMax Horn2004-04-17 09:57:15 +0000
commite17a15d96e46939d2ec4403ee5241baafdd562c0 (patch)
tree4e51f687eb2c57d5eba1604ad2f0d412416f64a5 /common/savefile.cpp
parent9b904682b18c4a4a7540fb1dca721544a8d448a3 (diff)
downloadscummvm-rg350-e17a15d96e46939d2ec4403ee5241baafdd562c0.tar.gz
scummvm-rg350-e17a15d96e46939d2ec4403ee5241baafdd562c0.tar.bz2
scummvm-rg350-e17a15d96e46939d2ec4403ee5241baafdd562c0.zip
Introduce ReadStream and WriteStream (as explained in my File class design mails on scummvm-devel)
svn-id: r13595
Diffstat (limited to 'common/savefile.cpp')
-rw-r--r--common/savefile.cpp59
1 files changed, 3 insertions, 56 deletions
diff --git a/common/savefile.cpp b/common/savefile.cpp
index 4084fd01c7..3aba3fdc36 100644
--- a/common/savefile.cpp
+++ b/common/savefile.cpp
@@ -23,6 +23,9 @@
#include "common/util.h"
#include "common/savefile.h"
+#include <stdio.h>
+#include <string.h>
+
#ifdef USE_ZLIB
#include <zlib.h>
#endif
@@ -31,66 +34,10 @@ uint32 SaveFile::read(void *ptr, uint32 size) {
return fread(ptr, 1, size);
}
-byte SaveFile::readByte() {
- byte b;
- // TODO: Proper error handling
- if (fread(&b, 1, 1) != 1)
- return 0;
- return b;
-}
-
-uint16 SaveFile::readUint16LE() {
- uint16 a = readByte();
- uint16 b = readByte();
- return a | (b << 8);
-}
-
-uint32 SaveFile::readUint32LE() {
- uint32 a = readUint16LE();
- uint32 b = readUint16LE();
- return (b << 16) | a;
-}
-
-uint16 SaveFile::readUint16BE() {
- uint16 b = readByte();
- uint16 a = readByte();
- return a | (b << 8);
-}
-
-uint32 SaveFile::readUint32BE() {
- uint32 b = readUint16BE();
- uint32 a = readUint16BE();
- return (b << 16) | a;
-}
-
uint32 SaveFile::write(const void *ptr, uint32 size) {
return fwrite(ptr, 1, size);
}
-void SaveFile::writeByte(byte value) {
- fwrite(&value, 1, 1);
-}
-
-void SaveFile::writeUint16LE(uint16 value) {
- writeByte((byte)(value & 0xff));
- writeByte((byte)(value >> 8));
-}
-
-void SaveFile::writeUint32LE(uint32 value) {
- writeUint16LE((uint16)(value & 0xffff));
- writeUint16LE((uint16)(value >> 16));
-}
-
-void SaveFile::writeUint16BE(uint16 value) {
- writeByte((byte)(value >> 8));
- writeByte((byte)(value & 0xff));
-}
-
-void SaveFile::writeUint32BE(uint32 value) {
- writeUint16BE((uint16)(value >> 16));
- writeUint16BE((uint16)(value & 0xffff));
-}
-
class StdioSaveFile : public SaveFile {
private: