[Scummvm-cvs-logs] SF.net SVN: scummvm: [27073] scummvm/branches/gsoc2007-fsnode/backends/fs

david_corrales at users.sourceforge.net david_corrales at users.sourceforge.net
Mon Jun 4 05:46:57 CEST 2007


Revision: 27073
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27073&view=rev
Author:   david_corrales
Date:     2007-06-03 20:46:56 -0700 (Sun, 03 Jun 2007)

Log Message:
-----------
Added a missing include in non-POSIX factories.
For the POSIX and Windows architectures, added exists(), isReadable() and isWritable()

Modified Paths:
--------------
    scummvm/branches/gsoc2007-fsnode/backends/fs/abstract-fs.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/amigaos4-fs-factory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/dc/ronincd-fs-factory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/ds/ds-fs-factory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/gp32-fs-factory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/abox-fs-factory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/palmos-fs-factory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/posix/posix-fs.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/ps2-fs-factory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/psp/psp-fs-factory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/symbian/symbian-fs-factory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/windows/windows-fs-factory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/windows/windows-fs.cpp

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/abstract-fs.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/abstract-fs.h	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/abstract-fs.h	2007-06-04 03:46:56 UTC (rev 27073)
@@ -78,12 +78,18 @@
 	 */
 	virtual ~AbstractFilesystemNode() {}
 
+	/*
+	 * Indicates whether this path exists in the filesystem or not.
+	 */
+	virtual bool exists() const = 0;
+
 	/**
 	 * Return a list of child nodes of this directory node. If called on a node
 	 * that does not represent a directory, false is returned.
 	 * 
 	 * @param list List to put the contents of the directory in.
 	 * @param mode Mode to use while listing the directory.
+	 * 
 	 * @return true if succesful, false otherwise (e.g. when the directory does not exist).
 	 */
 	virtual bool getChildren(AbstractFSList &list, ListMode mode) const = 0;
@@ -111,18 +117,22 @@
 	virtual bool isDirectory() const = 0;
 	
 	/**
+	 * Indicates whether this path can be read from or not.
+	 */
+	virtual bool isReadable() const = 0;
+	
+	/**
+	 * Indicates whether this path can be written to or not.
+	 */
+	virtual bool isWritable() const = 0;
+	
+	/**
 	 * Indicates whether this path is valid or not for usage.
 	 */
 	virtual bool isValid() const = 0;
 
 	/* TODO:
-	bool exists();
-
-	bool isDirectory();
 	bool isFile();
-
-	bool isReadable();
-	bool isWritable();
 	*/
 };
 

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/amigaos4-fs-factory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/amigaos4-fs-factory.h	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/amigaos4-fs-factory.h	2007-06-04 03:46:56 UTC (rev 27073)
@@ -1,6 +1,7 @@
 #ifndef AMIGAOS_FILESYSTEM_FACTORY_H
 #define AMIGAOS_FILESYSTEM_FACTORY_H
 
+#include "common/singleton.h"
 #include "backends/fs/abstract-fs-factory.h"
 
 /**

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/dc/ronincd-fs-factory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/dc/ronincd-fs-factory.h	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/dc/ronincd-fs-factory.h	2007-06-04 03:46:56 UTC (rev 27073)
@@ -1,6 +1,7 @@
 #ifndef RONINCD_FILESYSTEM_FACTORY_H
 #define RONINCD_FILESYSTEM_FACTORY_H
 
+#include "common/singleton.h"
 #include "backends/fs/abstract-fs-factory.h"
 
 /**

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/ds/ds-fs-factory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/ds/ds-fs-factory.h	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/ds/ds-fs-factory.h	2007-06-04 03:46:56 UTC (rev 27073)
@@ -1,6 +1,7 @@
 #ifndef DS_FILESYSTEM_FACTORY_H
 #define DS_FILESYSTEM_FACTORY_H
 
+#include "common/singleton.h"
 #include "backends/fs/abstract-fs-factory.h"
 
 /**

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/gp32-fs-factory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/gp32-fs-factory.h	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/gp32-fs-factory.h	2007-06-04 03:46:56 UTC (rev 27073)
@@ -1,6 +1,7 @@
 #ifndef GP32_FILESYSTEM_FACTORY_H
 #define GP32_FILESYSTEM_FACTORY_H
 
+#include "common/singleton.h"
 #include "backends/fs/abstract-fs-factory.h"
 
 /**

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/abox-fs-factory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/abox-fs-factory.h	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/abox-fs-factory.h	2007-06-04 03:46:56 UTC (rev 27073)
@@ -1,6 +1,7 @@
 #ifndef ABOX_FILESYSTEM_FACTORY_H
 #define ABOX_FILESYSTEM_FACTORY_H
 
+#include "common/singleton.h"
 #include "backends/fs/abstract-fs-factory.h"
 
 /**

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/palmos-fs-factory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/palmos-fs-factory.h	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/palmos-fs-factory.h	2007-06-04 03:46:56 UTC (rev 27073)
@@ -1,6 +1,7 @@
 #ifndef PALMOS_FILESYSTEM_FACTORY_H
 #define PALMOS_FILESYSTEM_FACTORY_H
 
+#include "common/singleton.h"
 #include "backends/fs/abstract-fs-factory.h"
 
 /**

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/posix/posix-fs.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/posix/posix-fs.cpp	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/posix/posix-fs.cpp	2007-06-04 03:46:56 UTC (rev 27073)
@@ -62,10 +62,13 @@
 	 */
 	POSIXFilesystemNode(const String &path, bool verify);
 	
+	virtual bool exists() const { return access(_path.c_str(), F_OK) == 0; }
 	virtual String getDisplayName() const { return _displayName; }
 	virtual String getName() const { return _displayName; }
 	virtual String getPath() const { return _path; }
 	virtual bool isDirectory() const { return _isDirectory; }
+	virtual bool isReadable() const { return access(_path.c_str(), R_OK) == 0; }
+	virtual bool isWritable() const { return access(_path.c_str(), W_OK) == 0; }
 	virtual bool isValid() const { return _isValid; }
 	
 	virtual AbstractFilesystemNode *getChild(const String &n) const;
@@ -102,8 +105,9 @@
 
 void POSIXFilesystemNode::setFlags() {
 	struct stat st;
+	
 	_isValid = (0 == stat(_path.c_str(), &st));
-	_isDirectory = _isValid ? S_ISDIR(st.st_mode) : false;	
+	_isDirectory = _isValid ? S_ISDIR(st.st_mode) : false;
 }
 
 POSIXFilesystemNode::POSIXFilesystemNode() {
@@ -140,8 +144,6 @@
 
 	_path = p;
 	_displayName = lastPathComponent(_path);
-	_isValid = true;
-	_isDirectory = true;
 
 	if (verify) {
 		setFlags();

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/ps2-fs-factory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/ps2-fs-factory.h	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/ps2-fs-factory.h	2007-06-04 03:46:56 UTC (rev 27073)
@@ -1,6 +1,7 @@
 #ifndef PS2_FILESYSTEM_FACTORY_H
 #define PS2_FILESYSTEM_FACTORY_H
 
+#include "common/singleton.h"
 #include "backends/fs/abstract-fs-factory.h"
 
 /**

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/psp/psp-fs-factory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/psp/psp-fs-factory.h	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/psp/psp-fs-factory.h	2007-06-04 03:46:56 UTC (rev 27073)
@@ -1,6 +1,7 @@
 #ifndef PSP_FILESYSTEM_FACTORY_H
 #define PSP_FILESYSTEM_FACTORY_H
 
+#include "common/singleton.h"
 #include "backends/fs/abstract-fs-factory.h"
 
 /**

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/symbian/symbian-fs-factory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/symbian/symbian-fs-factory.h	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/symbian/symbian-fs-factory.h	2007-06-04 03:46:56 UTC (rev 27073)
@@ -1,6 +1,7 @@
 #ifndef SYMBIAN_FILESYSTEM_FACTORY_H
 #define SYMBIAN_FILESYSTEM_FACTORY_H
 
+#include "common/singleton.h"
 #include "backends/fs/abstract-fs-factory.h"
 
 /**

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/windows/windows-fs-factory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/windows/windows-fs-factory.h	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/windows/windows-fs-factory.h	2007-06-04 03:46:56 UTC (rev 27073)
@@ -1,6 +1,7 @@
 #ifndef WINDOWS_FILESYSTEM_FACTORY_H
 #define WINDOWS_FILESYSTEM_FACTORY_H
 
+#include "common/singleton.h"
 #include "backends/fs/abstract-fs-factory.h"
 
 /**

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/windows/windows-fs.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/windows/windows-fs.cpp	2007-06-03 22:00:18 UTC (rev 27072)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/windows/windows-fs.cpp	2007-06-04 03:46:56 UTC (rev 27073)
@@ -29,6 +29,7 @@
 #endif
 #include "common/stdafx.h"
 #include "backends/fs/abstract-fs.h"
+#include <io.h>
 #include <stdio.h>
 #include <stdlib.h>
 #ifndef _WIN32_WCE
@@ -70,11 +71,14 @@
 	 * @param currentDir if true, the path parameter will be ignored and the resulting node will point to the current directory.
 	 */
 	WindowsFilesystemNode(const String &path, const bool currentDir);
-
+	
+	virtual bool exists() const { return _access(_path.c_str(), F_OK) == 0; }
 	virtual String getDisplayName() const { return _displayName; }
 	virtual String getName() const { return _displayName; }
 	virtual String getPath() const { return _path; }
 	virtual bool isDirectory() const { return _isDirectory; }
+	virtual bool isReadable() const { return _access(_path.c_str(), R_OK) == 0; }
+	virtual bool isWritable() const { return _access(_path.c_str(), W_OK) == 0; }
 	virtual bool isValid() const { return _isValid; }
 
 	virtual AbstractFilesystemNode *getChild(const String &n) const;
@@ -217,11 +221,11 @@
 	DWORD fileAttribs = GetFileAttributes(toUnicode(_path.c_str()));
 
 	if (fileAttribs == INVALID_FILE_ATTRIBUTES) {
+		_isDirectory = false;
 		_isValid = false;
-		_isDirectory = false;
 	} else {
+		_isDirectory = ((fileAttribs & FILE_ATTRIBUTE_DIRECTORY) != 0);
 		_isValid = true;
-		_isDirectory = ((fileAttribs & FILE_ATTRIBUTE_DIRECTORY) != 0);
 	}
 	_isPseudoRoot = false;
 }
@@ -276,9 +280,12 @@
 		sprintf(searchPath, "%s*", _path.c_str());
 
 		handle = FindFirstFile(toUnicode(searchPath), &desc);
+		
 		if (handle == INVALID_HANDLE_VALUE)
 			return false;
+			
 		addFile(myList, mode, _path.c_str(), &desc);
+		
 		while (FindNextFile(handle, &desc))
 			addFile(myList, mode, _path.c_str(), &desc);
 


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