diff options
author | Max Horn | 2008-07-29 16:09:10 +0000 |
---|---|---|
committer | Max Horn | 2008-07-29 16:09:10 +0000 |
commit | 0be985ce833d03e4458bb4512d5bed377c13d9c7 (patch) | |
tree | 0306c88a96f5eba14268fb33cc3cb45a5c8ba51e /engines/scumm | |
parent | c9051fcfbd9b1f227bf5bddd81aac478d139e358 (diff) | |
download | scummvm-rg350-0be985ce833d03e4458bb4512d5bed377c13d9c7.tar.gz scummvm-rg350-0be985ce833d03e4458bb4512d5bed377c13d9c7.tar.bz2 scummvm-rg350-0be985ce833d03e4458bb4512d5bed377c13d9c7.zip |
Changed class File (and derived classes) to only support read-only access; added a new class DumpFile for writing
svn-id: r33412
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/charset.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/debugger.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/file.cpp | 16 | ||||
-rw-r--r-- | engines/scumm/file.h | 9 | ||||
-rw-r--r-- | engines/scumm/file_nes.cpp | 15 | ||||
-rw-r--r-- | engines/scumm/file_nes.h | 3 | ||||
-rw-r--r-- | engines/scumm/he/script_v60he.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/he/script_v72he.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/he/script_v80he.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/he/wiz_he.cpp | 6 | ||||
-rw-r--r-- | engines/scumm/resource.cpp | 4 |
11 files changed, 21 insertions, 42 deletions
diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index 8f3175f098..5a45fb7da9 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -56,7 +56,7 @@ void ScummEngine::loadCJKFont() { _2byteWidth = 16; _2byteHeight = 16; // use FM-TOWNS font rom, since game files don't have kanji font resources - if (fp.open("fmt_fnt.rom", Common::File::kFileReadMode)) { + if (fp.open("fmt_fnt.rom")) { _useCJKMode = true; debug(2, "Loading FM-TOWNS Kanji rom"); _2byteFontPtr = new byte[((_2byteWidth + 7) / 8) * _2byteHeight * numChar]; diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp index 9f9115e207..23af1f9672 100644 --- a/engines/scumm/debugger.cpp +++ b/engines/scumm/debugger.cpp @@ -298,7 +298,7 @@ bool ScummDebugger::Cmd_ImportRes(int argc, const char** argv) { // FIXME add bounds check if (!strncmp(argv[1], "scr", 3)) { - file.open(argv[2], Common::File::kFileReadMode); + file.open(argv[2]); if (file.isOpen() == false) { DebugPrintf("Could not open file %s\n", argv[2]); return true; diff --git a/engines/scumm/file.cpp b/engines/scumm/file.cpp index bc5fc38225..bf13308a0c 100644 --- a/engines/scumm/file.cpp +++ b/engines/scumm/file.cpp @@ -58,8 +58,8 @@ void ScummFile::resetSubfile() { seek(0, SEEK_SET); } -bool ScummFile::open(const Common::String &filename, AccessMode mode) { - if (File::open(filename, mode)) { +bool ScummFile::open(const Common::String &filename) { + if (File::open(filename)) { resetSubfile(); return true; } else { @@ -187,11 +187,6 @@ uint32 ScummFile::read(void *dataPtr, uint32 dataSize) { return realLen; } -uint32 ScummFile::write(const void *, uint32) { - error("ScummFile does not support writing!"); - return 0; -} - #pragma mark - #pragma mark --- ScummDiskImage --- #pragma mark - @@ -250,11 +245,6 @@ ScummDiskImage::ScummDiskImage(const char *disk1, const char *disk2, GameSetting } } -uint32 ScummDiskImage::write(const void *, uint32) { - error("ScummDiskImage does not support writing!"); - return 0; -} - void ScummDiskImage::setEnc(byte enc) { _stream->setEnc(enc); } @@ -300,7 +290,7 @@ bool ScummDiskImage::openDisk(char num) { return true; } -bool ScummDiskImage::open(const Common::String &filename, AccessMode mode) { +bool ScummDiskImage::open(const Common::String &filename) { uint16 signature; // check signature diff --git a/engines/scumm/file.h b/engines/scumm/file.h index 7064654f89..a2695cac59 100644 --- a/engines/scumm/file.h +++ b/engines/scumm/file.h @@ -36,7 +36,7 @@ class BaseScummFile : public Common::File { public: virtual void setEnc(byte value) = 0; - virtual bool open(const Common::String &filename, AccessMode mode = kFileReadMode) = 0; + virtual bool open(const Common::String &filename) = 0; virtual bool openSubFile(const Common::String &filename) = 0; virtual bool eof() = 0; @@ -44,7 +44,6 @@ public: virtual uint32 size() = 0; virtual void seek(int32 offs, int whence = SEEK_SET) = 0; virtual uint32 read(void *dataPtr, uint32 dataSize) = 0; - virtual uint32 write(const void *dataPtr, uint32 dataSize) = 0; }; class ScummFile : public BaseScummFile { @@ -59,7 +58,7 @@ public: void setSubfileRange(uint32 start, uint32 len); void resetSubfile(); - bool open(const Common::String &filename, AccessMode mode = kFileReadMode); + bool open(const Common::String &filename); bool openSubFile(const Common::String &filename); bool eof(); @@ -67,7 +66,6 @@ public: uint32 size(); void seek(int32 offs, int whence = SEEK_SET); uint32 read(void *dataPtr, uint32 dataSize); - uint32 write(const void *dataPtr, uint32 dataSize); }; class ScummDiskImage : public BaseScummFile { @@ -104,7 +102,7 @@ public: ScummDiskImage(const char *disk1, const char *disk2, GameSettings game); void setEnc(byte value); - bool open(const Common::String &filename, AccessMode mode = kFileReadMode); + bool open(const Common::String &filename); bool openSubFile(const Common::String &filename); void close(); @@ -113,7 +111,6 @@ public: uint32 size() { return _stream->size(); } void seek(int32 offs, int whence = SEEK_SET) { _stream->seek(offs, whence); } uint32 read(void *dataPtr, uint32 dataSize) { return _stream->read(dataPtr, dataSize); } - uint32 write(const void *dataPtr, uint32 dataSize); }; } // End of namespace Scumm diff --git a/engines/scumm/file_nes.cpp b/engines/scumm/file_nes.cpp index 95f5eec4ea..8325436f87 100644 --- a/engines/scumm/file_nes.cpp +++ b/engines/scumm/file_nes.cpp @@ -62,11 +62,6 @@ struct ScummNESFile::Resource { ScummNESFile::ScummNESFile() : _stream(0), _buf(0), _ROMset(kROMsetNum) { } -uint32 ScummNESFile::write(const void *, uint32) { - error("ScummNESFile does not support writing!"); - return 0; -} - void ScummNESFile::setEnc(byte enc) { _stream->setEnc(enc); } @@ -1234,7 +1229,7 @@ bool ScummNESFile::generateIndex() { return true; } -bool ScummNESFile::open(const Common::String &filename, AccessMode mode) { +bool ScummNESFile::open(const Common::String &filename) { if (_ROMset == kROMsetNum) { char md5str[32+1]; @@ -1267,9 +1262,8 @@ bool ScummNESFile::open(const Common::String &filename, AccessMode mode) { } } - if (File::open(filename, mode)) { - if (_stream) - delete _stream; + if (File::open(filename)) { + delete _stream; _stream = 0; free(_buf); @@ -1282,8 +1276,7 @@ bool ScummNESFile::open(const Common::String &filename, AccessMode mode) { } void ScummNESFile::close() { - if (_stream) - delete _stream; + delete _stream; _stream = 0; free(_buf); diff --git a/engines/scumm/file_nes.h b/engines/scumm/file_nes.h index d601c2c496..4d2d6de275 100644 --- a/engines/scumm/file_nes.h +++ b/engines/scumm/file_nes.h @@ -64,7 +64,7 @@ public: ScummNESFile(); void setEnc(byte value); - bool open(const Common::String &filename, AccessMode mode = kFileReadMode); + bool open(const Common::String &filename); bool openSubFile(const Common::String &filename); void close(); @@ -73,7 +73,6 @@ public: uint32 size() { return _stream->size(); } void seek(int32 offs, int whence = SEEK_SET) { _stream->seek(offs, whence); } uint32 read(void *dataPtr, uint32 dataSize) { return _stream->read(dataPtr, dataSize); } - uint32 write(const void *dataPtr, uint32 dataSize); }; } // End of namespace Scumm diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp index 4d5ec668a0..9429f8d086 100644 --- a/engines/scumm/he/script_v60he.cpp +++ b/engines/scumm/he/script_v60he.cpp @@ -1012,7 +1012,7 @@ void ScummEngine_v60he::o60_openFile() { _hInFileTable[slot] = _saveFileMan->openForLoading(filename); if (_hInFileTable[slot] == 0) { Common::File *f = new Common::File(); - f->open(filename, Common::File::kFileReadMode); + f->open(filename); if (!f->isOpen()) delete f; else diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp index df3d857642..6c3d0023d8 100644 --- a/engines/scumm/he/script_v72he.cpp +++ b/engines/scumm/he/script_v72he.cpp @@ -1692,7 +1692,7 @@ void ScummEngine_v72he::o72_openFile() { _hInFileTable[slot] = _saveFileMan->openForLoading(filename); if (_hInFileTable[slot] == 0) { Common::File *f = new Common::File(); - f->open(filename, Common::File::kFileReadMode); + f->open(filename); if (!f->isOpen()) delete f; else diff --git a/engines/scumm/he/script_v80he.cpp b/engines/scumm/he/script_v80he.cpp index 393e1d3a8f..39ec715d94 100644 --- a/engines/scumm/he/script_v80he.cpp +++ b/engines/scumm/he/script_v80he.cpp @@ -409,7 +409,7 @@ void ScummEngine_v80he::o80_getFileSize() { Common::SeekableReadStream *f = _saveFileMan->openForLoading((const char *)filename); if (!f) { Common::File *file = new Common::File(); - file->open((const char *)filename, Common::File::kFileReadMode); + file->open((const char *)filename); if (!file->isOpen()) delete f; else diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index df472307eb..f514449bff 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -1881,7 +1881,7 @@ void Wiz::processWizImage(const WizParameters *params) { memcpy(filename, params->filename, 260); _vm->convertFilePath(filename); - if (f.open((const char *)filename, Common::File::kFileReadMode)) { + if (f.open((const char *)filename)) { uint32 id = f.readUint32BE(); if (id == MKID_BE('AWIZ') || id == MKID_BE('MULT')) { uint32 size = f.readUint32BE(); @@ -1911,7 +1911,7 @@ void Wiz::processWizImage(const WizParameters *params) { break; case 4: if (params->processFlags & kWPFUseFile) { - Common::File f; + Common::DumpFile f; switch (params->fileWriteMode) { case 2: @@ -1924,7 +1924,7 @@ void Wiz::processWizImage(const WizParameters *params) { memcpy(filename, params->filename, 260); _vm->convertFilePath(filename); - if (!f.open((const char *)filename, Common::File::kFileWriteMode)) { + if (!f.open((const char *)filename)) { debug(0, "Unable to open for write '%s'", filename); _vm->VAR(119) = -3; } else { diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp index acdc2bc222..6bd62c1761 100644 --- a/engines/scumm/resource.cpp +++ b/engines/scumm/resource.cpp @@ -1299,7 +1299,7 @@ void ScummEngine::allocateArrays() { void ScummEngine::dumpResource(const char *tag, int idx, const byte *ptr, int length) { char buf[256]; - Common::File out; + Common::DumpFile out; uint32 size; if (length >= 0) @@ -1313,7 +1313,7 @@ void ScummEngine::dumpResource(const char *tag, int idx, const byte *ptr, int le sprintf(buf, "dumps/%s%d.dmp", tag, idx); - out.open(buf, Common::File::kFileWriteMode); + out.open(buf); if (out.isOpen() == false) return; out.write(ptr, size); |