aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/fs/abstract-fs.h22
-rw-r--r--backends/fs/amigaos4/amigaos4-fs-factory.h1
-rw-r--r--backends/fs/dc/ronincd-fs-factory.h1
-rw-r--r--backends/fs/ds/ds-fs-factory.h1
-rw-r--r--backends/fs/gp32/gp32-fs-factory.h1
-rw-r--r--backends/fs/morphos/abox-fs-factory.h1
-rw-r--r--backends/fs/palmos/palmos-fs-factory.h1
-rw-r--r--backends/fs/posix/posix-fs.cpp8
-rw-r--r--backends/fs/ps2/ps2-fs-factory.h1
-rw-r--r--backends/fs/psp/psp-fs-factory.h1
-rw-r--r--backends/fs/symbian/symbian-fs-factory.h1
-rw-r--r--backends/fs/windows/windows-fs-factory.h1
-rw-r--r--backends/fs/windows/windows-fs.cpp13
13 files changed, 41 insertions, 12 deletions
diff --git a/backends/fs/abstract-fs.h b/backends/fs/abstract-fs.h
index 19d8aaa37d..aaae65eed3 100644
--- a/backends/fs/abstract-fs.h
+++ b/backends/fs/abstract-fs.h
@@ -78,12 +78,18 @@ public:
*/
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 @@ public:
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();
*/
};
diff --git a/backends/fs/amigaos4/amigaos4-fs-factory.h b/backends/fs/amigaos4/amigaos4-fs-factory.h
index 861f28b794..ed8af24648 100644
--- a/backends/fs/amigaos4/amigaos4-fs-factory.h
+++ b/backends/fs/amigaos4/amigaos4-fs-factory.h
@@ -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"
/**
diff --git a/backends/fs/dc/ronincd-fs-factory.h b/backends/fs/dc/ronincd-fs-factory.h
index 12590e8fa4..426ef7ef2c 100644
--- a/backends/fs/dc/ronincd-fs-factory.h
+++ b/backends/fs/dc/ronincd-fs-factory.h
@@ -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"
/**
diff --git a/backends/fs/ds/ds-fs-factory.h b/backends/fs/ds/ds-fs-factory.h
index 5bc847a7b2..a2e96aa548 100644
--- a/backends/fs/ds/ds-fs-factory.h
+++ b/backends/fs/ds/ds-fs-factory.h
@@ -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"
/**
diff --git a/backends/fs/gp32/gp32-fs-factory.h b/backends/fs/gp32/gp32-fs-factory.h
index 22c502d69f..fc15b52bc6 100644
--- a/backends/fs/gp32/gp32-fs-factory.h
+++ b/backends/fs/gp32/gp32-fs-factory.h
@@ -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"
/**
diff --git a/backends/fs/morphos/abox-fs-factory.h b/backends/fs/morphos/abox-fs-factory.h
index b0d1dfb340..35f4472b8b 100644
--- a/backends/fs/morphos/abox-fs-factory.h
+++ b/backends/fs/morphos/abox-fs-factory.h
@@ -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"
/**
diff --git a/backends/fs/palmos/palmos-fs-factory.h b/backends/fs/palmos/palmos-fs-factory.h
index 4bb94ab4c1..cfe246e806 100644
--- a/backends/fs/palmos/palmos-fs-factory.h
+++ b/backends/fs/palmos/palmos-fs-factory.h
@@ -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"
/**
diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp
index 966bfe34e6..712a8ce68d 100644
--- a/backends/fs/posix/posix-fs.cpp
+++ b/backends/fs/posix/posix-fs.cpp
@@ -62,10 +62,13 @@ public:
*/
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 @@ static const char *lastPathComponent(const Common::String &str) {
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 @@ POSIXFilesystemNode::POSIXFilesystemNode(const String &p, bool verify) {
_path = p;
_displayName = lastPathComponent(_path);
- _isValid = true;
- _isDirectory = true;
if (verify) {
setFlags();
diff --git a/backends/fs/ps2/ps2-fs-factory.h b/backends/fs/ps2/ps2-fs-factory.h
index 2dceb5a6dc..6f0da114c5 100644
--- a/backends/fs/ps2/ps2-fs-factory.h
+++ b/backends/fs/ps2/ps2-fs-factory.h
@@ -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"
/**
diff --git a/backends/fs/psp/psp-fs-factory.h b/backends/fs/psp/psp-fs-factory.h
index e751afbe1a..b1a44b90c4 100644
--- a/backends/fs/psp/psp-fs-factory.h
+++ b/backends/fs/psp/psp-fs-factory.h
@@ -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"
/**
diff --git a/backends/fs/symbian/symbian-fs-factory.h b/backends/fs/symbian/symbian-fs-factory.h
index 4acca7924c..69749cbd7e 100644
--- a/backends/fs/symbian/symbian-fs-factory.h
+++ b/backends/fs/symbian/symbian-fs-factory.h
@@ -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"
/**
diff --git a/backends/fs/windows/windows-fs-factory.h b/backends/fs/windows/windows-fs-factory.h
index b260eab65a..7d17802b52 100644
--- a/backends/fs/windows/windows-fs-factory.h
+++ b/backends/fs/windows/windows-fs-factory.h
@@ -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"
/**
diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp
index 88d04e1643..9cd6aa40a0 100644
--- a/backends/fs/windows/windows-fs.cpp
+++ b/backends/fs/windows/windows-fs.cpp
@@ -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 @@ public:
* @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 @@ WindowsFilesystemNode::WindowsFilesystemNode(const String &p, const bool current
DWORD fileAttribs = GetFileAttributes(toUnicode(_path.c_str()));
if (fileAttribs == INVALID_FILE_ATTRIBUTES) {
- _isValid = false;
_isDirectory = false;
+ _isValid = false;
} else {
- _isValid = true;
_isDirectory = ((fileAttribs & FILE_ATTRIBUTE_DIRECTORY) != 0);
+ _isValid = true;
}
_isPseudoRoot = false;
}
@@ -276,9 +280,12 @@ bool WindowsFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode) c
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);