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

david_corrales at users.sourceforge.net david_corrales at users.sourceforge.net
Wed Oct 31 14:59:59 CET 2007


Revision: 29337
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29337&view=rev
Author:   david_corrales
Date:     2007-10-31 06:59:59 -0700 (Wed, 31 Oct 2007)

Log Message:
-----------
Removed the Common::File::removeFile() methods, and moved their implementation to the Common::DefaultSaveFileManager::removeSavefile() method, as per Marcus' appraisal and Max's approval.

Modified Paths:
--------------
    scummvm/trunk/backends/saves/default/default-saves.cpp
    scummvm/trunk/common/file.cpp
    scummvm/trunk/common/file.h

Modified: scummvm/trunk/backends/saves/default/default-saves.cpp
===================================================================
--- scummvm/trunk/backends/saves/default/default-saves.cpp	2007-10-31 08:56:32 UTC (rev 29336)
+++ scummvm/trunk/backends/saves/default/default-saves.cpp	2007-10-31 13:59:59 UTC (rev 29337)
@@ -120,7 +120,7 @@
 	Common::String search(regex);
 
 	if (savePath.lookupFile(savefiles, search, false, true)) {
-		for (FSList::const_iterator file = savefiles.begin(); file != savefiles.end(); file++) {
+		for (FSList::const_iterator file = savefiles.begin(); file != savefiles.end(); ++file) {
 			results.push_back(file->getPath());
 		}
 	}
@@ -219,7 +219,6 @@
 	}
 #endif
 
-
 	join_paths(filename, savePath, buf, sizeof(buf));
 
 	StdioSaveFile *sf = new StdioSaveFile(buf, true);
@@ -235,10 +234,18 @@
 bool DefaultSaveFileManager::removeSavefile(const char *filename) {
 	char buf[256];
 	join_paths(filename, getSavePath(), buf, sizeof(buf));
-
-	Common::File file;
-	FilesystemNode savePath((const char *)buf);
-	return file.removeFile(savePath);
+	
+	if (remove(buf) != 0) {
+		if (errno == EACCES)
+			setError(SFM_DIR_ACCESS, Common::String("Search or write permission denied"));
+		
+		if (errno == ENOENT)
+			setError(SFM_DIR_NOENT, Common::String("A component of the path path does not exist, or the path is an empty string"));
+		
+		return false;
+	} else {
+		return true;
+	}	
 }
 
 #endif // !defined(DISABLE_DEFAULT_SAVEFILEMANAGER)

Modified: scummvm/trunk/common/file.cpp
===================================================================
--- scummvm/trunk/common/file.cpp	2007-10-31 08:56:32 UTC (rev 29336)
+++ scummvm/trunk/common/file.cpp	2007-10-31 13:59:59 UTC (rev 29337)
@@ -423,36 +423,6 @@
 	return true;
 }
 
-bool File::removeFile(const String &filename){
-	if (remove(filename.c_str()) != 0) {
-		if (errno == EACCES) {
-			//TODO: read-only file
-		}
-		if (errno == ENOENT) {
-			//TODO: non-existent file
-		}
-		
-		return false;
-	} else {
-		return true;
-	}
-}
-
-bool File::removeFile(const FilesystemNode &node){
-	if (remove(node.getPath().c_str()) != 0) {
-		if (errno == EACCES) {
-			//TODO: read-only file
-		}
-		if (errno == ENOENT) {
-			//TODO: non-existent file
-		}
-				
-		return false;
-	} else {
-		return true;
-	}
-}
-
 bool File::exists(const String &filename) {
 	FilesystemNode* file;
 	String fname = filename;

Modified: scummvm/trunk/common/file.h
===================================================================
--- scummvm/trunk/common/file.h	2007-10-31 08:56:32 UTC (rev 29336)
+++ scummvm/trunk/common/file.h	2007-10-31 13:59:59 UTC (rev 29337)
@@ -85,9 +85,6 @@
 
 	virtual void close();
 
-	virtual bool removeFile(const String &filename);
-	virtual bool removeFile(const FilesystemNode &node);
-
 	/**
 	 * Checks if the object opened a file successfully.
 	 *


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