diff options
author | Max Horn | 2006-04-14 01:48:51 +0000 |
---|---|---|
committer | Max Horn | 2006-04-14 01:48:51 +0000 |
commit | 1470dadb1de3250dfceeaa246604ca0f26889bbf (patch) | |
tree | 3bd75cabff52222dba1fc1f408e4f21917749aed | |
parent | 507281610935fb2adcbae0c5f0d6239defdd8ffa (diff) | |
download | scummvm-rg350-1470dadb1de3250dfceeaa246604ca0f26889bbf.tar.gz scummvm-rg350-1470dadb1de3250dfceeaa246604ca0f26889bbf.tar.bz2 scummvm-rg350-1470dadb1de3250dfceeaa246604ca0f26889bbf.zip |
Changed File::open to take a Common::String as file name parameter
svn-id: r21867
-rw-r--r-- | common/config-file.cpp | 4 | ||||
-rw-r--r-- | common/config-manager.cpp | 2 | ||||
-rw-r--r-- | common/file.cpp | 10 | ||||
-rw-r--r-- | common/file.h | 4 | ||||
-rw-r--r-- | engines/kyra/resource.cpp | 2 | ||||
-rw-r--r-- | engines/queen/queen.cpp | 2 | ||||
-rw-r--r-- | engines/saga/game.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/file.cpp | 20 | ||||
-rw-r--r-- | engines/scumm/file.h | 16 | ||||
-rw-r--r-- | engines/scumm/resource.cpp | 2 | ||||
-rw-r--r-- | engines/simon/game.cpp | 2 | ||||
-rw-r--r-- | graphics/imagedec.cpp | 2 |
12 files changed, 33 insertions, 35 deletions
diff --git a/common/config-file.cpp b/common/config-file.cpp index 568b5f554f..4baeb0e816 100644 --- a/common/config-file.cpp +++ b/common/config-file.cpp @@ -68,7 +68,7 @@ void ConfigFile::clear() { bool ConfigFile::loadFromFile(const String &filename) { File file; - if (file.open(filename.c_str(), File::kFileReadMode)) + if (file.open(filename, File::kFileReadMode)) return loadFromStream(file); else return false; @@ -170,7 +170,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) { bool ConfigFile::saveToFile(const String &filename) { File file; - if (file.open(filename.c_str(), File::kFileWriteMode)) + if (file.open(filename, File::kFileWriteMode)) return saveToStream(file); else return false; diff --git a/common/config-manager.cpp b/common/config-manager.cpp index 1c9089a025..bf87fb3b71 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -137,7 +137,7 @@ void ConfigManager::loadConfigFile(const String &filename) { void ConfigManager::loadFile(const String &filename) { File cfg_file; - if (!cfg_file.open(filename.c_str())) { + if (!cfg_file.open(filename)) { printf("Creating configuration file: %s\n", filename.c_str()); } else { char buf[MAXLINELEN]; diff --git a/common/file.cpp b/common/file.cpp index 038e7e3fd2..00707c4f7e 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -67,7 +67,6 @@ static FILE *fopenNoCase(const String &filename, const String &directory, const // Try again, with file name converted to upper case // if (!file) { - for (i = offsetToFileName; i < buf.size(); ++i) { buf[i] = toupper(buf[i]); } @@ -185,20 +184,19 @@ void File::decRef() { } -bool File::open(const char *f, AccessMode mode, const char *directory) { +bool File::open(const String &filename, AccessMode mode, const char *directory) { assert(mode == kFileReadMode || mode == kFileWriteMode); - if (f == NULL || *f == 0) { + if (filename.empty()) { error("File::open: No filename was specified!"); } if (_handle) { - error("File::open: This file object already is opened (%s), won't open '%s'", _name.c_str(), f); + error("File::open: This file object already is opened (%s), won't open '%s'", _name.c_str(), filename.c_str()); } clearIOFailed(); - String filename(f); String fname(filename); fname.toLowercase(); @@ -265,7 +263,7 @@ bool File::open(const char *f, AccessMode mode, const char *directory) { return true; } -bool File::exists(const char *filename, const char *directory) { +bool File::exists(const String &filename, const char *directory) { // FIXME: Ugly ugly hack! File tmp; return tmp.open(filename, kFileReadMode, directory); diff --git a/common/file.h b/common/file.h index 567292c440..27d062a41d 100644 --- a/common/file.h +++ b/common/file.h @@ -60,8 +60,8 @@ public: void incRef(); void decRef(); - virtual bool open(const char *filename, AccessMode mode = kFileReadMode, const char *directory = NULL); - static bool exists(const char *filename, const char *directory = NULL); + virtual bool open(const String &filename, AccessMode mode = kFileReadMode, const char *directory = NULL); + static bool exists(const String &filename, const char *directory = NULL); virtual void close(); bool isOpen() const; diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index 42c8d3894f..27388aaa06 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -239,7 +239,7 @@ PAKFile::PAKFile(const Common::String& file, bool isAmiga) { uint8 *buffer = 0; _open = false; - if (!pakfile.open(file.c_str())) { + if (!pakfile.open(file)) { debug(3, "couldn't open pakfile '%s'\n", file.c_str()); return; } diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp index 7c0d767912..d1219fb59e 100644 --- a/engines/queen/queen.cpp +++ b/engines/queen/queen.cpp @@ -101,7 +101,7 @@ DetectedGameList Engine_QUEEN_detectGames(const FSList &fslist) { if (0 == scumm_stricmp("queen.1", gameName) || 0 == scumm_stricmp("queen.1c", gameName)) { Common::File dataFile; - dataFile.open(file->path().c_str()); + dataFile.open(file->path()); assert(dataFile.isOpen()); if (0 == scumm_stricmp("queen.1", gameName)) { //an unmodified file diff --git a/engines/saga/game.cpp b/engines/saga/game.cpp index a8bac4bddd..4154173f33 100644 --- a/engines/saga/game.cpp +++ b/engines/saga/game.cpp @@ -1556,7 +1556,7 @@ static int detectGame(const FSList *fslist, Common::Language language, Common::P tstr.toLowercase(); if(!filesMD5.contains(tstr)) { - if (testFile.open(file->_key.c_str())) { + if (testFile.open(file->_key)) { testFile.close(); if (Common::md5_file(file->_key.c_str(), md5sum, NULL, FILE_MD5_BYTES)) { diff --git a/engines/scumm/file.cpp b/engines/scumm/file.cpp index 7a17d8c97b..efc23e53c8 100644 --- a/engines/scumm/file.cpp +++ b/engines/scumm/file.cpp @@ -56,7 +56,7 @@ void ScummFile::resetSubfile() { seek(0, SEEK_SET); } -bool ScummFile::open(const char *filename, AccessMode mode) { +bool ScummFile::open(const Common::String &filename, AccessMode mode) { if (File::open(filename, mode)) { resetSubfile(); return true; @@ -65,7 +65,7 @@ bool ScummFile::open(const char *filename, AccessMode mode) { } } -bool ScummFile::openSubFile(const char *filename) { +bool ScummFile::openSubFile(const Common::String &filename) { assert(isOpen()); // Disable the XOR encryption and reset any current subfile range @@ -112,7 +112,7 @@ bool ScummFile::openSubFile(const char *filename) { return false; } - if (scumm_stricmp(file_name, filename) == 0) { + if (scumm_stricmp(file_name, filename.c_str()) == 0) { // We got a match! setSubfileRange(file_off, file_len); return true; @@ -1380,11 +1380,11 @@ bool ScummNESFile::generateIndex() { return true; } -bool ScummNESFile::open(const char *filename, AccessMode mode) { +bool ScummNESFile::open(const Common::String &filename, AccessMode mode) { uint8 md5sum[16]; if (_ROMset == kROMsetNum) { - if (Common::md5_file(filename, md5sum)) { + if (Common::md5_file(filename.c_str(), md5sum)) { char md5str[32+1]; for (int j = 0; j < 16; j++) { sprintf(md5str + j*2, "%02x", (int)md5sum[j]); @@ -1439,10 +1439,10 @@ void ScummNESFile::close() { File::close(); } -bool ScummNESFile::openSubFile(const char *filename) { +bool ScummNESFile::openSubFile(const Common::String &filename) { assert(isOpen()); - const char *ext = strrchr(filename, '.'); + const char *ext = strrchr(filename.c_str(), '.'); char resNum[3]; int res; @@ -1556,7 +1556,7 @@ bool ScummC64File::openDisk(char num) { return true; } -bool ScummC64File::open(const char *filename, AccessMode mode) { +bool ScummC64File::open(const Common::String &filename, AccessMode mode) { uint16 signature; // check signature @@ -1708,10 +1708,10 @@ void ScummC64File::close() { File::close(); } -bool ScummC64File::openSubFile(const char *filename) { +bool ScummC64File::openSubFile(const Common::String &filename) { assert(isOpen()); - const char *ext = strrchr(filename, '.'); + const char *ext = strrchr(filename.c_str(), '.'); char resNum[3]; int res; diff --git a/engines/scumm/file.h b/engines/scumm/file.h index fa5e4d35a5..2fbf9f01e4 100644 --- a/engines/scumm/file.h +++ b/engines/scumm/file.h @@ -31,8 +31,8 @@ class BaseScummFile : public Common::File { public: virtual void setEnc(byte value) = 0; - virtual bool open(const char *filename, AccessMode mode = kFileReadMode) = 0; - virtual bool openSubFile(const char *filename) = 0; + virtual bool open(const Common::String &filename, AccessMode mode = kFileReadMode) = 0; + virtual bool openSubFile(const Common::String &filename) = 0; virtual bool eof() = 0; virtual uint32 pos() = 0; @@ -54,8 +54,8 @@ public: void setSubfileRange(uint32 start, uint32 len); void resetSubfile(); - bool open(const char *filename, AccessMode mode = kFileReadMode); - bool openSubFile(const char *filename); + bool open(const Common::String &filename, AccessMode mode = kFileReadMode); + bool openSubFile(const Common::String &filename); bool eof(); uint32 pos(); @@ -96,8 +96,8 @@ public: ScummNESFile(); void setEnc(byte value); - bool open(const char *filename, AccessMode mode = kFileReadMode); - bool openSubFile(const char *filename); + bool open(const Common::String &filename, AccessMode mode = kFileReadMode); + bool openSubFile(const Common::String &filename); void close(); bool eof() { return _stream->eos(); } @@ -142,8 +142,8 @@ public: ScummC64File(const char *disk1, const char *disk2, bool maniac); void setEnc(byte value); - bool open(const char *filename, AccessMode mode = kFileReadMode); - bool openSubFile(const char *filename); + bool open(const Common::String &filename, AccessMode mode = kFileReadMode); + bool openSubFile(const Common::String &filename); void close(); bool eof() { return _stream->eos(); } diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp index f54b80b239..d8eba584ee 100644 --- a/engines/scumm/resource.cpp +++ b/engines/scumm/resource.cpp @@ -250,7 +250,7 @@ bool ScummEngine::openFile(BaseScummFile &file, const char *filename, bool resou char name[128]; file.close(); - file.open(_containerFile.c_str()); + file.open(_containerFile); assert(file.isOpen()); strncpy(name, filename, 128); diff --git a/engines/simon/game.cpp b/engines/simon/game.cpp index b8b4cb8788..9e83b4d9ca 100644 --- a/engines/simon/game.cpp +++ b/engines/simon/game.cpp @@ -1305,7 +1305,7 @@ static int detectGame(const FSList *fslist, Common::Language language, Common::P tstr.toLowercase(); if(!filesMD5.contains(tstr)) { - if (testFile.open(file->_key.c_str())) { + if (testFile.open(file->_key)) { testFile.close(); if (Common::md5_file(file->_key.c_str(), md5sum, NULL, FILE_MD5_BYTES)) { diff --git a/graphics/imagedec.cpp b/graphics/imagedec.cpp index 2cc21aa62f..5d9eac3f4b 100644 --- a/graphics/imagedec.cpp +++ b/graphics/imagedec.cpp @@ -140,7 +140,7 @@ Surface *ImageDecoder::loadFile(const Common::String &name) { Surface *newSurf = 0; Common::File imageFile; - if (imageFile.open(name.c_str())) { + if (imageFile.open(name)) { newSurf = loadFile(imageFile); } |