[Scummvm-cvs-logs] SF.net SVN: scummvm: [28150] scummvm/branches/gsoc2007-fsnode/common
david_corrales at users.sourceforge.net
david_corrales at users.sourceforge.net
Fri Jul 20 21:42:39 CEST 2007
Revision: 28150
http://scummvm.svn.sourceforge.net/scummvm/?rev=28150&view=rev
Author: david_corrales
Date: 2007-07-20 12:42:38 -0700 (Fri, 20 Jul 2007)
Log Message:
-----------
Added a remove() function to the Common::File class. Also changed the exists() function to account for new capabilities in the FSNode layer.
Modified Paths:
--------------
scummvm/branches/gsoc2007-fsnode/common/file.cpp
scummvm/branches/gsoc2007-fsnode/common/file.h
Modified: scummvm/branches/gsoc2007-fsnode/common/file.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/common/file.cpp 2007-07-19 20:21:47 UTC (rev 28149)
+++ scummvm/branches/gsoc2007-fsnode/common/file.cpp 2007-07-20 19:42:38 UTC (rev 28150)
@@ -29,6 +29,10 @@
#include "common/util.h"
#include "common/hash-str.h"
+#if defined(UNIX) || defined(__SYMBIAN32__)
+#include <errno.h>
+#endif
+
#ifdef MACOSX
#include "CoreFoundation/CoreFoundation.h"
#endif
@@ -408,16 +412,40 @@
return true;
}
+bool File::remove(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::remove(const FilesystemNode &node){
+ if (remove(node.getPath()) != 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) {
// First try to find the file it via a FilesystemNode (in case an absolute
// path was passed). But we only use this to filter out directories.
FilesystemNode file(filename);
- // FIXME: can't use isValid() here since at the time of writing
- // FilesystemNode is to be unable to find for example files
- // added in extrapath
- if (file.isDirectory() || !file.exists())
- return false;
-
+
+ return (!file.isDirectory() && file.exists());
+
+ //***DEPRECATED COMMENTS BELOW, LEFT FOR DISCUSSION***
// Next, try to locate the file by *opening* it in read mode. This has
// multiple effects:
// 1) It takes _filesMap and _defaultDirectories into consideration -> good
Modified: scummvm/branches/gsoc2007-fsnode/common/file.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/common/file.h 2007-07-19 20:21:47 UTC (rev 28149)
+++ scummvm/branches/gsoc2007-fsnode/common/file.h 2007-07-20 19:42:38 UTC (rev 28150)
@@ -86,6 +86,9 @@
virtual void close();
+ virtual bool remove(const String &filename);
+ virtual bool remove(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