[Scummvm-cvs-logs] SF.net SVN: scummvm: [21867] scummvm/trunk/common

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Apr 13 18:50:01 CEST 2006


Revision: 21867
Author:   fingolfin
Date:     2006-04-13 18:48:51 -0700 (Thu, 13 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21867&view=rev

Log Message:
-----------
Changed File::open to take a Common::String as file name parameter

Modified Paths:
--------------
    scummvm/trunk/common/config-file.cpp
    scummvm/trunk/common/config-manager.cpp
    scummvm/trunk/common/file.cpp
    scummvm/trunk/common/file.h
    scummvm/trunk/engines/kyra/resource.cpp
    scummvm/trunk/engines/queen/queen.cpp
    scummvm/trunk/engines/saga/game.cpp
    scummvm/trunk/engines/scumm/file.cpp
    scummvm/trunk/engines/scumm/file.h
    scummvm/trunk/engines/scumm/resource.cpp
    scummvm/trunk/engines/simon/game.cpp
    scummvm/trunk/graphics/imagedec.cpp
Modified: scummvm/trunk/common/config-file.cpp
===================================================================
--- scummvm/trunk/common/config-file.cpp	2006-04-14 01:47:33 UTC (rev 21866)
+++ scummvm/trunk/common/config-file.cpp	2006-04-14 01:48:51 UTC (rev 21867)
@@ -68,7 +68,7 @@
 
 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::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;

Modified: scummvm/trunk/common/config-manager.cpp
===================================================================
--- scummvm/trunk/common/config-manager.cpp	2006-04-14 01:47:33 UTC (rev 21866)
+++ scummvm/trunk/common/config-manager.cpp	2006-04-14 01:48:51 UTC (rev 21867)
@@ -137,7 +137,7 @@
 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];

Modified: scummvm/trunk/common/file.cpp
===================================================================
--- scummvm/trunk/common/file.cpp	2006-04-14 01:47:33 UTC (rev 21866)
+++ scummvm/trunk/common/file.cpp	2006-04-14 01:48:51 UTC (rev 21867)
@@ -67,7 +67,6 @@
 	// 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 @@
 }
 
 
-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 @@
 	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);

Modified: scummvm/trunk/common/file.h
===================================================================
--- scummvm/trunk/common/file.h	2006-04-14 01:47:33 UTC (rev 21866)
+++ scummvm/trunk/common/file.h	2006-04-14 01:48:51 UTC (rev 21867)
@@ -60,8 +60,8 @@
 	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;

Modified: scummvm/trunk/engines/kyra/resource.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource.cpp	2006-04-14 01:47:33 UTC (rev 21866)
+++ scummvm/trunk/engines/kyra/resource.cpp	2006-04-14 01:48:51 UTC (rev 21867)
@@ -239,7 +239,7 @@
 	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;
 	}

Modified: scummvm/trunk/engines/queen/queen.cpp
===================================================================
--- scummvm/trunk/engines/queen/queen.cpp	2006-04-14 01:47:33 UTC (rev 21866)
+++ scummvm/trunk/engines/queen/queen.cpp	2006-04-14 01:48:51 UTC (rev 21867)
@@ -101,7 +101,7 @@
 
 			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

Modified: scummvm/trunk/engines/saga/game.cpp
===================================================================
--- scummvm/trunk/engines/saga/game.cpp	2006-04-14 01:47:33 UTC (rev 21866)
+++ scummvm/trunk/engines/saga/game.cpp	2006-04-14 01:48:51 UTC (rev 21867)
@@ -1556,7 +1556,7 @@
 			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)) {

Modified: scummvm/trunk/engines/scumm/file.cpp
===================================================================
--- scummvm/trunk/engines/scumm/file.cpp	2006-04-14 01:47:33 UTC (rev 21866)
+++ scummvm/trunk/engines/scumm/file.cpp	2006-04-14 01:48:51 UTC (rev 21867)
@@ -56,7 +56,7 @@
 	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::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 @@
 			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 @@
 	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 @@
 	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 @@
 	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 @@
 	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;
 

Modified: scummvm/trunk/engines/scumm/file.h
===================================================================
--- scummvm/trunk/engines/scumm/file.h	2006-04-14 01:47:33 UTC (rev 21866)
+++ scummvm/trunk/engines/scumm/file.h	2006-04-14 01:48:51 UTC (rev 21867)
@@ -31,8 +31,8 @@
 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 @@
 	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 @@
 	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 @@
 	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(); }

Modified: scummvm/trunk/engines/scumm/resource.cpp
===================================================================
--- scummvm/trunk/engines/scumm/resource.cpp	2006-04-14 01:47:33 UTC (rev 21866)
+++ scummvm/trunk/engines/scumm/resource.cpp	2006-04-14 01:48:51 UTC (rev 21867)
@@ -250,7 +250,7 @@
 		char name[128];
 
 		file.close();
-		file.open(_containerFile.c_str());
+		file.open(_containerFile);
 		assert(file.isOpen());
 
 		strncpy(name, filename, 128);

Modified: scummvm/trunk/engines/simon/game.cpp
===================================================================
--- scummvm/trunk/engines/simon/game.cpp	2006-04-14 01:47:33 UTC (rev 21866)
+++ scummvm/trunk/engines/simon/game.cpp	2006-04-14 01:48:51 UTC (rev 21867)
@@ -1305,7 +1305,7 @@
 			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)) {

Modified: scummvm/trunk/graphics/imagedec.cpp
===================================================================
--- scummvm/trunk/graphics/imagedec.cpp	2006-04-14 01:47:33 UTC (rev 21866)
+++ scummvm/trunk/graphics/imagedec.cpp	2006-04-14 01:48:51 UTC (rev 21867)
@@ -140,7 +140,7 @@
 	Surface *newSurf = 0;
 
 	Common::File imageFile;
-	if (imageFile.open(name.c_str())) {
+	if (imageFile.open(name)) {
 		newSurf = loadFile(imageFile);
 	}
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list