aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2013-07-18 09:27:55 -0400
committerPaul Gilbert2013-07-18 09:27:55 -0400
commit73bb5c5fbe66329f9074c2661a2035435e6756a4 (patch)
treebefe383329bbabfae30416652d5f7b5985a30d20
parent5f2465466e6dd99fc17e7bd8dad3cb54b1ee4387 (diff)
downloadscummvm-rg350-73bb5c5fbe66329f9074c2661a2035435e6756a4.tar.gz
scummvm-rg350-73bb5c5fbe66329f9074c2661a2035435e6756a4.tar.bz2
scummvm-rg350-73bb5c5fbe66329f9074c2661a2035435e6756a4.zip
DEVTOOLS: Moved implementation of create_mortdat File class from the header file
-rw-r--r--devtools/create_mortdat/create_mortdat.cpp62
-rw-r--r--devtools/create_mortdat/create_mortdat.h63
2 files changed, 76 insertions, 49 deletions
diff --git a/devtools/create_mortdat/create_mortdat.cpp b/devtools/create_mortdat/create_mortdat.cpp
index 2dff398de2..cb7d6aa189 100644
--- a/devtools/create_mortdat/create_mortdat.cpp
+++ b/devtools/create_mortdat/create_mortdat.cpp
@@ -42,6 +42,68 @@
#include "enginetext.h"
#include "gametext.h"
+
+bool File::open(const char *filename, AccessMode mode) {
+ f = fopen(filename, (mode == kFileReadMode) ? "rb" : "wb");
+ return (f != NULL);
+}
+
+void File::close() {
+ fclose(f);
+ f = NULL;
+}
+
+int File::seek(int32 offset, int whence) {
+ return fseek(f, offset, whence);
+}
+
+long File::read(void *buffer, int len) {
+ return fread(buffer, 1, len, f);
+}
+void File::write(const void *buffer, int len) {
+ fwrite(buffer, 1, len, f);
+}
+
+byte File::readByte() {
+ byte v;
+ read(&v, sizeof(byte));
+ return v;
+}
+
+uint16 File::readWord() {
+ uint16 v;
+ read(&v, sizeof(uint16));
+ return FROM_LE_16(v);
+}
+
+uint32 File::readLong() {
+ uint32 v;
+ read(&v, sizeof(uint32));
+ return FROM_LE_32(v);
+}
+
+void File::writeByte(byte v) {
+ write(&v, sizeof(byte));
+}
+
+void File::writeWord(uint16 v) {
+ uint16 vTemp = TO_LE_16(v);
+ write(&vTemp, sizeof(uint16));
+}
+
+void File::writeLong(uint32 v) {
+ uint32 vTemp = TO_LE_32(v);
+ write(&vTemp, sizeof(uint32));
+}
+
+void File::writeString(const char *s) {
+ write(s, strlen(s) + 1);
+}
+
+uint32 File::pos() {
+ return ftell(f);
+}
+
/*-------------------------------------------------------------------------*/
void openOutputFile(const char *outFilename) {
diff --git a/devtools/create_mortdat/create_mortdat.h b/devtools/create_mortdat/create_mortdat.h
index 908cb61951..8c210d32d9 100644
--- a/devtools/create_mortdat/create_mortdat.h
+++ b/devtools/create_mortdat/create_mortdat.h
@@ -43,55 +43,20 @@ class File {
private:
FILE *f;
public:
- bool open(const char *filename, AccessMode mode = kFileReadMode) {
- f = fopen(filename, (mode == kFileReadMode) ? "rb" : "wb");
- return (f != NULL);
- }
- void close() {
- fclose(f);
- f = NULL;
- }
- int seek(int32 offset, int whence = SEEK_SET) {
- return fseek(f, offset, whence);
- }
- long read(void *buffer, int len) {
- return fread(buffer, 1, len, f);
- }
- void write(const void *buffer, int len) {
- fwrite(buffer, 1, len, f);
- }
- byte readByte() {
- byte v;
- read(&v, sizeof(byte));
- return v;
- }
- uint16 readWord() {
- uint16 v;
- read(&v, sizeof(uint16));
- return FROM_LE_16(v);
- }
- uint32 readLong() {
- uint32 v;
- read(&v, sizeof(uint32));
- return FROM_LE_32(v);
- }
- void writeByte(byte v) {
- write(&v, sizeof(byte));
- }
- void writeWord(uint16 v) {
- uint16 vTemp = TO_LE_16(v);
- write(&vTemp, sizeof(uint16));
- }
- void writeLong(uint32 v) {
- uint32 vTemp = TO_LE_32(v);
- write(&vTemp, sizeof(uint32));
- }
- void writeString(const char *s) {
- write(s, strlen(s) + 1);
- }
- uint32 pos() {
- return ftell(f);
- }
+ bool open(const char *filename, AccessMode mode = kFileReadMode);
+ void close();
+ int seek(int32 offset, int whence = SEEK_SET);
+ uint32 pos();
+ long read(void *buffer, int len);
+ void write(const void *buffer, int len);
+
+ byte readByte();
+ uint16 readWord();
+ uint32 readLong();
+ void writeByte(byte v);
+ void writeWord(uint16 v);
+ void writeLong(uint32 v);
+ void writeString(const char *s);
};
File outputFile, mortCom;