[Scummvm-cvs-logs] SF.net SVN: scummvm: [23274] scummvm/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sat Jun 24 10:08:54 CEST 2006
Revision: 23274
Author: fingolfin
Date: 2006-06-24 01:07:48 -0700 (Sat, 24 Jun 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=23274&view=rev
Log Message:
-----------
Move backends/fs/fs.h and .cpp to common/fs/fs.h and .cpp
Rationale: backend implementations belong to backends/, but portable APIs meant to be used by high level code is for common / sound / graphics / ... (compare also with backends/midi vs. sound/mididrv.h)
Modified Paths:
--------------
scummvm/trunk/Makefile.common
scummvm/trunk/backends/dc/selector.cpp
scummvm/trunk/backends/fs/abstract-fs.h
scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp
scummvm/trunk/backends/fs/dc/dc-fs.cpp
scummvm/trunk/backends/fs/gp32/gp32-fs.cpp
scummvm/trunk/backends/fs/morphos/abox-fs.cpp
scummvm/trunk/backends/fs/palmos/palmos-fs.cpp
scummvm/trunk/backends/fs/posix/posix-fs.cpp
scummvm/trunk/backends/fs/ps2/ps2-fs.cpp
scummvm/trunk/backends/fs/psp/psp_fs.cpp
scummvm/trunk/backends/fs/symbian/symbian-fs.cpp
scummvm/trunk/backends/fs/windows/windows-fs.cpp
scummvm/trunk/backends/module.mk
scummvm/trunk/backends/wince/CELauncherDialog.h
scummvm/trunk/base/commandLine.cpp
scummvm/trunk/base/main.cpp
scummvm/trunk/base/plugins.cpp
scummvm/trunk/common/file.cpp
scummvm/trunk/common/module.mk
scummvm/trunk/engines/agi/agi.cpp
scummvm/trunk/engines/agi/agi_v3.cpp
scummvm/trunk/engines/cine/cine.cpp
scummvm/trunk/engines/gob/gob.cpp
scummvm/trunk/engines/kyra/plugin.cpp
scummvm/trunk/engines/lure/lure.cpp
scummvm/trunk/engines/queen/queen.cpp
scummvm/trunk/engines/saga/game.cpp
scummvm/trunk/engines/scumm/plugin.cpp
scummvm/trunk/engines/scumm/scumm.cpp
scummvm/trunk/engines/simon/game.cpp
scummvm/trunk/engines/simon/simon.cpp
scummvm/trunk/engines/sky/sky.cpp
scummvm/trunk/engines/sword1/sword1.cpp
scummvm/trunk/engines/sword2/sword2.cpp
scummvm/trunk/gui/browser.cpp
scummvm/trunk/gui/browser.h
scummvm/trunk/gui/launcher.cpp
scummvm/trunk/gui/options.cpp
Added Paths:
-----------
scummvm/trunk/common/fs.cpp
scummvm/trunk/common/fs.h
Removed Paths:
-------------
scummvm/trunk/backends/fs/fs.cpp
scummvm/trunk/backends/fs/fs.h
Modified: scummvm/trunk/Makefile.common
===================================================================
--- scummvm/trunk/Makefile.common 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/Makefile.common 2006-06-24 08:07:48 UTC (rev 23274)
@@ -40,8 +40,8 @@
gui \
graphics \
sound \
- backends \
- common
+ common \
+ backends
ifdef USE_MT32EMU
MODULES += sound/softsynth/mt32
Modified: scummvm/trunk/backends/dc/selector.cpp
===================================================================
--- scummvm/trunk/backends/dc/selector.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/dc/selector.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -25,7 +25,7 @@
#include <common/scummsys.h>
#include <base/engine.h>
#include <base/plugins.h>
-#include <backends/fs/fs.h>
+#include <common/fs.h>
#include "dc.h"
#include "icon.h"
#include "label.h"
Modified: scummvm/trunk/backends/fs/abstract-fs.h
===================================================================
--- scummvm/trunk/backends/fs/abstract-fs.h 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/abstract-fs.h 2006-06-24 08:07:48 UTC (rev 23274)
@@ -25,7 +25,7 @@
#include "common/array.h"
#include "common/str.h"
-#include "backends/fs/fs.h"
+#include "common/fs.h"
class AbstractFilesystemNode;
Modified: scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -38,7 +38,6 @@
#include "base/engine.h"
#include "backends/fs/abstract-fs.h"
-#include "backends/fs/fs.h"
#define ENTER() /* debug(6, "Enter") */
#define LEAVE() /* debug(6, "Leave") */
Modified: scummvm/trunk/backends/fs/dc/dc-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/dc/dc-fs.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/dc/dc-fs.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -24,7 +24,6 @@
#include "common/stdafx.h"
#include "backends/fs/abstract-fs.h"
-#include "backends/fs/fs.h"
#include <ronin/cdfs.h>
#include <stdio.h>
Deleted: scummvm/trunk/backends/fs/fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/fs.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/fs.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -1,143 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2002-2006 The ScummVM project
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#include "common/stdafx.h"
-
-#include "backends/fs/abstract-fs.h"
-#include "backends/fs/fs.h"
-#include "common/util.h"
-
-
-FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) {
- _realNode = realNode;
- _refCount = new int(1);
-}
-
-FilesystemNode::FilesystemNode() {
- _realNode = 0;
- _refCount = 0;
-}
-
-FilesystemNode::FilesystemNode(const FilesystemNode &node) {
- _realNode = node._realNode;
- _refCount = node._refCount;
- if (_refCount)
- ++(*_refCount);
-}
-
-FilesystemNode::FilesystemNode(const Common::String &p) {
- if (p.empty() || p == ".")
- _realNode = AbstractFilesystemNode::getCurrentDirectory();
- else
- _realNode = AbstractFilesystemNode::getNodeForPath(p);
- _refCount = new int(1);
-}
-
-FilesystemNode::~FilesystemNode() {
- decRefCount();
-}
-
-void FilesystemNode::decRefCount() {
- if (_refCount) {
- assert(*_refCount > 0);
- --(*_refCount);
- if (*_refCount == 0) {
- delete _refCount;
- delete _realNode;
- }
- }
-}
-
-FilesystemNode &FilesystemNode::operator =(const FilesystemNode &node) {
- if (node._refCount)
- ++(*node._refCount);
-
- decRefCount();
-
- _realNode = node._realNode;
- _refCount = node._refCount;
-
- return *this;
-}
-
-FilesystemNode FilesystemNode::getParent() const {
- if (_realNode == 0)
- return *this;
-
- AbstractFilesystemNode *node = _realNode->parent();
- if (node == 0) {
- return *this;
- } else {
- return FilesystemNode(node);
- }
-}
-
-FilesystemNode FilesystemNode::getChild(const String &name) const {
- if (_realNode == 0)
- return *this;
-
- assert(_realNode->isDirectory());
- AbstractFilesystemNode *node = _realNode->child(name);
- return FilesystemNode(node);
-}
-
-bool FilesystemNode::listDir(FSList &fslist, ListMode mode) const {
- if (!_realNode || !_realNode->isDirectory())
- return false;
-
- AbstractFSList tmp;
-
- if (!_realNode->listDir(tmp, mode))
- return false;
-
- fslist.clear();
- for (AbstractFSList::iterator i = tmp.begin(); i != tmp.end(); ++i) {
- fslist.push_back(FilesystemNode(*i));
- }
-
- return true;
-}
-
-Common::String FilesystemNode::displayName() const {
- assert(_realNode);
- return _realNode->displayName();
-}
-
-bool FilesystemNode::isDirectory() const {
- if (_realNode == 0)
- return false;
- return _realNode->isDirectory();
-}
-
-Common::String FilesystemNode::path() const {
- assert(_realNode);
- return _realNode->path();
-}
-
-
-bool FilesystemNode::operator< (const FilesystemNode& node) const
-{
- if (isDirectory() && !node.isDirectory())
- return true;
- if (!isDirectory() && node.isDirectory())
- return false;
- return scumm_stricmp(displayName().c_str(), node.displayName().c_str()) < 0;
-}
Deleted: scummvm/trunk/backends/fs/fs.h
===================================================================
--- scummvm/trunk/backends/fs/fs.h 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/fs.h 2006-06-24 08:07:48 UTC (rev 23274)
@@ -1,172 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2002-2006 The ScummVM project
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#ifndef BACKENDS_FS_H
-#define BACKENDS_FS_H
-
-#include "common/array.h"
-#include "common/str.h"
-
-class FilesystemNode;
-class AbstractFilesystemNode;
-
-
-/**
- * List of multiple file system nodes. E.g. the contents of a given directory.
- * This is subclass instead of just a typedef so that we can use forward
- * declarations of it in other places.
- */
-class FSList : public Common::Array<FilesystemNode> {};
-
-
-/*
- * FilesystemNode provides an abstraction for file pathes, allowing for portable
- * file system browsing. To this ends, multiple or single roots have to be supported
- * (compare Unix with a single root, Windows with multiple roots C:, D:, ...).
- *
- * To this end, we abstract away from paths; implementations can be based on
- * paths (and it's left to them whether / or \ or : is the path separator :-);
- * but it is also possible to use inodes or vrefs (MacOS 9) or anything else.
- *
- * NOTE: Backends still have to provide a way to extract a path from a FSIntern
- *
- * You may ask now: "isn't this cheating? Why do we go through all this when we use
- * a path in the end anyway?!?".
- * Well, for once as long as we don't provide our own file open/read/write API, we
- * still have to use fopen(). Since all our targets already support fopen(), it should
- * be possible to get a fopen() compatible string for any file system node.
- *
- * Secondly, with this abstraction layer, we still avoid a lot of complications based on
- * differences in FS roots, different path separators, or even systems with no real
- * paths (MacOS 9 doesn't even have the notion of a "current directory").
- * And if we ever want to support devices with no FS in the classical sense (Palm...),
- * we can build upon this.
- */
-class FilesystemNode {
- typedef Common::String String;
-private:
- AbstractFilesystemNode *_realNode;
- int *_refCount;
-
- FilesystemNode(AbstractFilesystemNode *realNode);
-
-public:
- /**
- * Flag to tell listDir() which kind of files to list.
- */
- enum ListMode {
- kListFilesOnly = 1,
- kListDirectoriesOnly = 2,
- kListAll = 3
- };
-
- /**
- * Create a new invalid FilesystemNode. In other words, isValid() for that
- * node returns false, and if you try to get it's path, an assert is
- * triggered.
- */
- FilesystemNode();
-
- /**
- * Create a new FilesystemNode referring to the specified path. This is
- * the counterpart to the path() method.
- *
- * If path is empty or equals ".", then a node representing the "current
- * directory" will be created. If that is not possible (since e.g. the
- * operating system doesn't support the concept), some other directory is
- * used (usually the root directory).
- */
- FilesystemNode(const String &path);
-
- /**
- * Copy constructor.
- */
- FilesystemNode(const FilesystemNode &node);
-
- /**
- * Destructor.
- */
- virtual ~FilesystemNode();
-
- /**
- * Copy operator.
- */
- FilesystemNode &operator =(const FilesystemNode &node);
-
- /**
- * Get the parent node of this node. If this node has no parent node,
- * then it returns a duplicate of this node.
- */
- FilesystemNode getParent() const;
-
- /**
- * Fetch a child node of this node, with the given name. Only valid for
- * directory nodes (an assertion is triggered otherwise). If no no child
- * node with the given name exists, an invalid node is returned.
- */
- FilesystemNode getChild(const String &name) const;
-
- /**
- * Return a list of child nodes of this directory node. If called on a node
- * that does not represent a directory, false is returned.
- * @return true if succesful, false otherwise (e.g. when the directory does not exist).
- * @todo Rename this to listChildren or getChildren.
- */
- virtual bool listDir(FSList &fslist, ListMode mode = kListDirectoriesOnly) const;
-
- /**
- * Return a human readable string for this node, usable for display (e.g.
- * in the GUI code). Do *not* rely on it being usable for anything else,
- * like constructing paths!
- * @return the display name
- */
- virtual String displayName() const;
-
- /**
- * Is this node pointing to a directory?
- * @todo Currently we assume that a valid node that is not a directory
- * automatically is a file (ignoring things like symlinks). That might
- * actually be OK... but we could still add an isFile method. Or even replace
- * isValid and isDirectory by a getType() method that can return values like
- * kDirNodeType, kFileNodeType, kInvalidNodeType.
- */
- virtual bool isDirectory() const;
-
- /**
- * Return a string representation of the file which can be passed to fopen(),
- * and is suitable for archiving (i.e. writing to the config file).
- * This will usually be a 'path' (hence the name of the method), but can
- * be anything that fulfilly the above criterions.
- */
- virtual String path() const;
-
- /**
- * Compare the name of this node to the name of another. Directories
- * go before normal files.
- */
- bool operator< (const FilesystemNode& node) const;
-
-protected:
- void decRefCount();
-};
-
-
-#endif
Modified: scummvm/trunk/backends/fs/gp32/gp32-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/gp32/gp32-fs.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/gp32/gp32-fs.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -26,7 +26,6 @@
#include "stdafx.h"
#include "backends/fs/abstract-fs.h"
-#include "backends/fs/fs.h"
class GP32FilesystemNode : public AbstractFilesystemNode {
protected:
Modified: scummvm/trunk/backends/fs/morphos/abox-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/morphos/abox-fs.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/morphos/abox-fs.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -27,7 +27,6 @@
#include "base/engine.h"
#include "backends/fs/abstract-fs.h"
-#include "backends/fs/fs.h"
/*
* Implementation of the ScummVM file system API based on the MorphOS A-Box API.
Modified: scummvm/trunk/backends/fs/palmos/palmos-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/palmos/palmos-fs.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/palmos/palmos-fs.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -23,7 +23,6 @@
#include "common/stdafx.h"
#include "backends/fs/abstract-fs.h"
-#include "backends/fs/fs.h"
#include <stdio.h>
#include <stdlib.h>
Modified: scummvm/trunk/backends/fs/posix/posix-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/posix/posix-fs.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/posix/posix-fs.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -24,7 +24,6 @@
#include "common/stdafx.h"
#include "backends/fs/abstract-fs.h"
-#include "backends/fs/fs.h"
#ifdef MACOSX
#include <sys/types.h>
Modified: scummvm/trunk/backends/fs/ps2/ps2-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/ps2/ps2-fs.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/ps2/ps2-fs.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -20,7 +20,6 @@
*/
#include "backends/fs/abstract-fs.h"
-#include "backends/fs/fs.h"
#include <kernel.h>
#include <stdio.h>
#include <stdlib.h>
Modified: scummvm/trunk/backends/fs/psp/psp_fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/psp/psp_fs.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/psp/psp_fs.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -26,7 +26,6 @@
#include "base/engine.h"
#include "backends/fs/abstract-fs.h"
-#include "backends/fs/fs.h"
#include <sys/stat.h>
#include <unistd.h>
Modified: scummvm/trunk/backends/fs/symbian/symbian-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/symbian/symbian-fs.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/symbian/symbian-fs.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -25,7 +25,6 @@
#if defined (__SYMBIAN32__)
#include "common/stdafx.h"
#include "backends/fs/abstract-fs.h"
-#include "backends/fs/fs.h"
#include <dirent.h>
#include <eikenv.h>
Modified: scummvm/trunk/backends/fs/windows/windows-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/windows/windows-fs.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/fs/windows/windows-fs.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -23,7 +23,6 @@
#include "common/stdafx.h"
#include "backends/fs/abstract-fs.h"
-#include "backends/fs/fs.h"
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
Modified: scummvm/trunk/backends/module.mk
===================================================================
--- scummvm/trunk/backends/module.mk 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/module.mk 2006-06-24 08:07:48 UTC (rev 23274)
@@ -1,7 +1,6 @@
MODULE := backends
MODULE_OBJS := \
- fs/fs.o \
fs/posix/posix-fs.o \
fs/morphos/abox-fs.o \
fs/windows/windows-fs.o \
Modified: scummvm/trunk/backends/wince/CELauncherDialog.h
===================================================================
--- scummvm/trunk/backends/wince/CELauncherDialog.h 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/backends/wince/CELauncherDialog.h 2006-06-24 08:07:48 UTC (rev 23274)
@@ -23,10 +23,8 @@
#ifndef CELAUNCHERDIALOG
#define CELAUNCHERDIALOG
-#include "backends/fs/fs.h"
-
#include "base/plugins.h"
-
+#include "common/fs.h"
#include "gui/launcher.h"
class CELauncherDialog : public GUI::LauncherDialog {
Modified: scummvm/trunk/base/commandLine.cpp
===================================================================
--- scummvm/trunk/base/commandLine.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/base/commandLine.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -51,7 +51,7 @@
#define DETECTOR_TESTING_HACK
#ifdef DETECTOR_TESTING_HACK
-#include "backends/fs/fs.h"
+#include "common/fs.h"
#endif
namespace Base {
Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/base/main.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -30,13 +30,13 @@
*/
#include "common/stdafx.h"
-#include "backends/fs/fs.h"
#include "base/engine.h"
#include "base/commandLine.h"
#include "base/plugins.h"
#include "base/version.h"
#include "common/config-manager.h"
#include "common/file.h"
+#include "common/fs.h"
#include "common/system.h"
#include "common/timer.h"
#include "gui/newgui.h"
Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/base/plugins.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -22,10 +22,10 @@
*/
#include "common/stdafx.h"
-#include "backends/fs/fs.h"
#include "base/plugins.h"
#include "base/engine.h"
#include "common/util.h"
+#include "common/fs.h"
/** Type of factory functions which make new Engine objects. */
typedef PluginError (*EngineFactory)(OSystem *syst, Engine **engine);
Modified: scummvm/trunk/common/file.cpp
===================================================================
--- scummvm/trunk/common/file.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/common/file.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -21,9 +21,9 @@
*/
#include "common/file.h"
+#include "common/fs.h"
#include "common/hashmap.h"
#include "common/util.h"
-#include "backends/fs/fs.h"
#ifdef MACOSX
#include "CoreFoundation/CoreFoundation.h"
Copied: scummvm/trunk/common/fs.cpp (from rev 23262, scummvm/trunk/backends/fs/fs.cpp)
===================================================================
--- scummvm/trunk/common/fs.cpp (rev 0)
+++ scummvm/trunk/common/fs.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -0,0 +1,142 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2002-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#include "common/stdafx.h"
+
+#include "backends/fs/abstract-fs.h"
+#include "common/util.h"
+
+
+FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) {
+ _realNode = realNode;
+ _refCount = new int(1);
+}
+
+FilesystemNode::FilesystemNode() {
+ _realNode = 0;
+ _refCount = 0;
+}
+
+FilesystemNode::FilesystemNode(const FilesystemNode &node) {
+ _realNode = node._realNode;
+ _refCount = node._refCount;
+ if (_refCount)
+ ++(*_refCount);
+}
+
+FilesystemNode::FilesystemNode(const Common::String &p) {
+ if (p.empty() || p == ".")
+ _realNode = AbstractFilesystemNode::getCurrentDirectory();
+ else
+ _realNode = AbstractFilesystemNode::getNodeForPath(p);
+ _refCount = new int(1);
+}
+
+FilesystemNode::~FilesystemNode() {
+ decRefCount();
+}
+
+void FilesystemNode::decRefCount() {
+ if (_refCount) {
+ assert(*_refCount > 0);
+ --(*_refCount);
+ if (*_refCount == 0) {
+ delete _refCount;
+ delete _realNode;
+ }
+ }
+}
+
+FilesystemNode &FilesystemNode::operator =(const FilesystemNode &node) {
+ if (node._refCount)
+ ++(*node._refCount);
+
+ decRefCount();
+
+ _realNode = node._realNode;
+ _refCount = node._refCount;
+
+ return *this;
+}
+
+FilesystemNode FilesystemNode::getParent() const {
+ if (_realNode == 0)
+ return *this;
+
+ AbstractFilesystemNode *node = _realNode->parent();
+ if (node == 0) {
+ return *this;
+ } else {
+ return FilesystemNode(node);
+ }
+}
+
+FilesystemNode FilesystemNode::getChild(const String &name) const {
+ if (_realNode == 0)
+ return *this;
+
+ assert(_realNode->isDirectory());
+ AbstractFilesystemNode *node = _realNode->child(name);
+ return FilesystemNode(node);
+}
+
+bool FilesystemNode::listDir(FSList &fslist, ListMode mode) const {
+ if (!_realNode || !_realNode->isDirectory())
+ return false;
+
+ AbstractFSList tmp;
+
+ if (!_realNode->listDir(tmp, mode))
+ return false;
+
+ fslist.clear();
+ for (AbstractFSList::iterator i = tmp.begin(); i != tmp.end(); ++i) {
+ fslist.push_back(FilesystemNode(*i));
+ }
+
+ return true;
+}
+
+Common::String FilesystemNode::displayName() const {
+ assert(_realNode);
+ return _realNode->displayName();
+}
+
+bool FilesystemNode::isDirectory() const {
+ if (_realNode == 0)
+ return false;
+ return _realNode->isDirectory();
+}
+
+Common::String FilesystemNode::path() const {
+ assert(_realNode);
+ return _realNode->path();
+}
+
+
+bool FilesystemNode::operator< (const FilesystemNode& node) const
+{
+ if (isDirectory() && !node.isDirectory())
+ return true;
+ if (!isDirectory() && node.isDirectory())
+ return false;
+ return scumm_stricmp(displayName().c_str(), node.displayName().c_str()) < 0;
+}
Copied: scummvm/trunk/common/fs.h (from rev 23262, scummvm/trunk/backends/fs/fs.h)
===================================================================
--- scummvm/trunk/common/fs.h (rev 0)
+++ scummvm/trunk/common/fs.h 2006-06-24 08:07:48 UTC (rev 23274)
@@ -0,0 +1,175 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2002-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef COMMON_FS_H
+#define COMMON_FS_H
+
+#include "common/array.h"
+#include "common/str.h"
+
+//namespace Common {
+
+class FilesystemNode;
+class AbstractFilesystemNode;
+
+
+/**
+ * List of multiple file system nodes. E.g. the contents of a given directory.
+ * This is subclass instead of just a typedef so that we can use forward
+ * declarations of it in other places.
+ */
+class FSList : public Common::Array<FilesystemNode> {};
+
+
+/*
+ * FilesystemNode provides an abstraction for file pathes, allowing for portable
+ * file system browsing. To this ends, multiple or single roots have to be supported
+ * (compare Unix with a single root, Windows with multiple roots C:, D:, ...).
+ *
+ * To this end, we abstract away from paths; implementations can be based on
+ * paths (and it's left to them whether / or \ or : is the path separator :-);
+ * but it is also possible to use inodes or vrefs (MacOS 9) or anything else.
+ *
+ * NOTE: Backends still have to provide a way to extract a path from a FSIntern
+ *
+ * You may ask now: "isn't this cheating? Why do we go through all this when we use
+ * a path in the end anyway?!?".
+ * Well, for once as long as we don't provide our own file open/read/write API, we
+ * still have to use fopen(). Since all our targets already support fopen(), it should
+ * be possible to get a fopen() compatible string for any file system node.
+ *
+ * Secondly, with this abstraction layer, we still avoid a lot of complications based on
+ * differences in FS roots, different path separators, or even systems with no real
+ * paths (MacOS 9 doesn't even have the notion of a "current directory").
+ * And if we ever want to support devices with no FS in the classical sense (Palm...),
+ * we can build upon this.
+ */
+class FilesystemNode {
+ typedef Common::String String;
+private:
+ AbstractFilesystemNode *_realNode;
+ int *_refCount;
+
+ FilesystemNode(AbstractFilesystemNode *realNode);
+
+public:
+ /**
+ * Flag to tell listDir() which kind of files to list.
+ */
+ enum ListMode {
+ kListFilesOnly = 1,
+ kListDirectoriesOnly = 2,
+ kListAll = 3
+ };
+
+ /**
+ * Create a new invalid FilesystemNode. In other words, isValid() for that
+ * node returns false, and if you try to get it's path, an assert is
+ * triggered.
+ */
+ FilesystemNode();
+
+ /**
+ * Create a new FilesystemNode referring to the specified path. This is
+ * the counterpart to the path() method.
+ *
+ * If path is empty or equals ".", then a node representing the "current
+ * directory" will be created. If that is not possible (since e.g. the
+ * operating system doesn't support the concept), some other directory is
+ * used (usually the root directory).
+ */
+ FilesystemNode(const String &path);
+
+ /**
+ * Copy constructor.
+ */
+ FilesystemNode(const FilesystemNode &node);
+
+ /**
+ * Destructor.
+ */
+ virtual ~FilesystemNode();
+
+ /**
+ * Copy operator.
+ */
+ FilesystemNode &operator =(const FilesystemNode &node);
+
+ /**
+ * Get the parent node of this node. If this node has no parent node,
+ * then it returns a duplicate of this node.
+ */
+ FilesystemNode getParent() const;
+
+ /**
+ * Fetch a child node of this node, with the given name. Only valid for
+ * directory nodes (an assertion is triggered otherwise). If no no child
+ * node with the given name exists, an invalid node is returned.
+ */
+ FilesystemNode getChild(const String &name) const;
+
+ /**
+ * Return a list of child nodes of this directory node. If called on a node
+ * that does not represent a directory, false is returned.
+ * @return true if succesful, false otherwise (e.g. when the directory does not exist).
+ * @todo Rename this to listChildren or getChildren.
+ */
+ virtual bool listDir(FSList &fslist, ListMode mode = kListDirectoriesOnly) const;
+
+ /**
+ * Return a human readable string for this node, usable for display (e.g.
+ * in the GUI code). Do *not* rely on it being usable for anything else,
+ * like constructing paths!
+ * @return the display name
+ */
+ virtual String displayName() const;
+
+ /**
+ * Is this node pointing to a directory?
+ * @todo Currently we assume that a valid node that is not a directory
+ * automatically is a file (ignoring things like symlinks). That might
+ * actually be OK... but we could still add an isFile method. Or even replace
+ * isValid and isDirectory by a getType() method that can return values like
+ * kDirNodeType, kFileNodeType, kInvalidNodeType.
+ */
+ virtual bool isDirectory() const;
+
+ /**
+ * Return a string representation of the file which can be passed to fopen(),
+ * and is suitable for archiving (i.e. writing to the config file).
+ * This will usually be a 'path' (hence the name of the method), but can
+ * be anything that fulfilly the above criterions.
+ */
+ virtual String path() const;
+
+ /**
+ * Compare the name of this node to the name of another. Directories
+ * go before normal files.
+ */
+ bool operator< (const FilesystemNode& node) const;
+
+protected:
+ void decRefCount();
+};
+
+//} // End of namespace Common
+
+#endif
Modified: scummvm/trunk/common/module.mk
===================================================================
--- scummvm/trunk/common/module.mk 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/common/module.mk 2006-06-24 08:07:48 UTC (rev 23274)
@@ -4,6 +4,7 @@
config-file.o \
config-manager.o \
file.o \
+ fs.o \
hashmap.o \
md5.o \
mutex.o \
Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/agi/agi.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -24,13 +24,12 @@
#include "common/stdafx.h"
#include "common/file.h"
+#include "common/fs.h"
#include "common/savefile.h"
#include "common/config-manager.h"
#include "base/plugins.h"
-#include "backends/fs/fs.h"
-
#include "graphics/cursorman.h"
#include "sound/mididrv.h"
Modified: scummvm/trunk/engines/agi/agi_v3.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi_v3.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/agi/agi_v3.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -27,9 +27,8 @@
#include "agi/agi.h"
#include "agi/lzw.h"
-#include "backends/fs/fs.h"
-
#include "common/config-manager.h"
+#include "common/fs.h"
namespace Agi {
Modified: scummvm/trunk/engines/cine/cine.cpp
===================================================================
--- scummvm/trunk/engines/cine/cine.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/cine/cine.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -24,14 +24,13 @@
#include "common/stdafx.h"
#include "common/file.h"
+#include "common/fs.h"
#include "common/savefile.h"
#include "common/config-manager.h"
#include "common/system.h"
#include "base/plugins.h"
-#include "backends/fs/fs.h"
-
#include "graphics/cursorman.h"
#include "sound/mididrv.h"
Modified: scummvm/trunk/engines/gob/gob.cpp
===================================================================
--- scummvm/trunk/engines/gob/gob.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/gob/gob.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -22,8 +22,8 @@
#include "common/stdafx.h"
#include "base/plugins.h"
-#include "backends/fs/fs.h"
#include "common/config-manager.h"
+#include "common/fs.h"
#include "common/md5.h"
#include "gob/gob.h"
Modified: scummvm/trunk/engines/kyra/plugin.cpp
===================================================================
--- scummvm/trunk/engines/kyra/plugin.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/kyra/plugin.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -21,10 +21,9 @@
#include "kyra/kyra.h"
-#include "backends/fs/fs.h"
-
#include "common/config-manager.h"
#include "common/file.h"
+#include "common/fs.h"
#include "common/system.h"
#include "common/md5.h"
Modified: scummvm/trunk/engines/lure/lure.cpp
===================================================================
--- scummvm/trunk/engines/lure/lure.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/lure/lure.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -22,13 +22,12 @@
#include "common/stdafx.h"
-#include "backends/fs/fs.h"
-
#include "base/plugins.h"
#include "common/config-manager.h"
#include "common/endian.h"
#include "common/file.h"
+#include "common/fs.h"
#include "common/system.h"
#include "common/md5.h"
Modified: scummvm/trunk/engines/queen/queen.cpp
===================================================================
--- scummvm/trunk/engines/queen/queen.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/queen/queen.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -22,12 +22,11 @@
#include "common/stdafx.h"
-#include "backends/fs/fs.h"
-
#include "base/plugins.h"
#include "common/config-manager.h"
#include "common/file.h"
+#include "common/fs.h"
#include "common/savefile.h"
#include "common/system.h"
Modified: scummvm/trunk/engines/saga/game.cpp
===================================================================
--- scummvm/trunk/engines/saga/game.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/saga/game.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -27,11 +27,11 @@
#include "saga/saga.h"
#include "common/file.h"
+#include "common/fs.h"
#include "common/md5.h"
#include "common/hashmap.h"
#include "common/config-manager.h"
#include "base/plugins.h"
-#include "backends/fs/fs.h"
#include "saga/rscfile.h"
#include "saga/interface.h"
Modified: scummvm/trunk/engines/scumm/plugin.cpp
===================================================================
--- scummvm/trunk/engines/scumm/plugin.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/scumm/plugin.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -23,11 +23,10 @@
#include "common/stdafx.h"
-#include "backends/fs/fs.h"
-
#include "base/plugins.h"
#include "common/config-manager.h"
+#include "common/fs.h"
#include "common/list.h"
#include "common/md5.h"
#include "common/system.h" // Only needed for g_system
Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/scumm/scumm.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -23,9 +23,8 @@
#include "common/stdafx.h"
-#include "backends/fs/fs.h"
-
#include "common/config-manager.h"
+#include "common/fs.h"
#include "common/md5.h"
#include "common/system.h"
Modified: scummvm/trunk/engines/simon/game.cpp
===================================================================
--- scummvm/trunk/engines/simon/game.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/simon/game.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -23,12 +23,11 @@
#include "common/stdafx.h"
-#include "backends/fs/fs.h"
-
#include "base/plugins.h"
#include "common/config-manager.h"
#include "common/file.h"
+#include "common/fs.h"
#include "common/md5.h"
#include "simon/simon.h"
Modified: scummvm/trunk/engines/simon/simon.cpp
===================================================================
--- scummvm/trunk/engines/simon/simon.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/simon/simon.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -23,10 +23,9 @@
#include "common/stdafx.h"
-#include "backends/fs/fs.h"
-
#include "common/config-manager.h"
#include "common/file.h"
+#include "common/fs.h"
#include "common/system.h"
#include "gui/about.h"
Modified: scummvm/trunk/engines/sky/sky.cpp
===================================================================
--- scummvm/trunk/engines/sky/sky.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/sky/sky.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -22,12 +22,11 @@
#include "common/stdafx.h"
-#include "backends/fs/fs.h"
-
#include "base/plugins.h"
#include "common/config-manager.h"
#include "common/file.h"
+#include "common/fs.h"
#include "common/system.h"
#include "common/timer.h"
Modified: scummvm/trunk/engines/sword1/sword1.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sword1.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/sword1/sword1.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -23,11 +23,10 @@
#include "common/stdafx.h"
#include "sword1/sword1.h"
-#include "backends/fs/fs.h"
-
#include "base/plugins.h"
#include "common/config-manager.h"
#include "common/file.h"
+#include "common/fs.h"
#include "common/timer.h"
#include "common/system.h"
Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/engines/sword2/sword2.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -21,12 +21,11 @@
#include "common/stdafx.h"
-#include "backends/fs/fs.h"
-
#include "base/plugins.h"
#include "common/config-manager.h"
#include "common/file.h"
+#include "common/fs.h"
#include "common/system.h"
#include "sword2/sword2.h"
Modified: scummvm/trunk/gui/browser.cpp
===================================================================
--- scummvm/trunk/gui/browser.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/gui/browser.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -24,9 +24,8 @@
#include "gui/newgui.h"
#include "gui/ListWidget.h"
-#include "backends/fs/fs.h"
-
#include "common/config-manager.h"
+#include "common/fs.h"
#include "common/system.h"
#include "common/func.h"
Modified: scummvm/trunk/gui/browser.h
===================================================================
--- scummvm/trunk/gui/browser.h 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/gui/browser.h 2006-06-24 08:07:48 UTC (rev 23274)
@@ -24,7 +24,7 @@
#include "gui/dialog.h"
#include "common/str.h"
-#include "backends/fs/fs.h"
+#include "common/fs.h"
#ifdef MACOSX
#include <Carbon/Carbon.h>
Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/gui/launcher.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -21,14 +21,13 @@
#include "common/stdafx.h"
-#include "backends/fs/fs.h"
-
#include "base/engine.h"
#include "base/game.h"
#include "base/plugins.h"
#include "base/version.h"
#include "common/config-manager.h"
+#include "common/fs.h"
#include "common/util.h"
#include "common/system.h"
Modified: scummvm/trunk/gui/options.cpp
===================================================================
--- scummvm/trunk/gui/options.cpp 2006-06-24 07:14:15 UTC (rev 23273)
+++ scummvm/trunk/gui/options.cpp 2006-06-24 08:07:48 UTC (rev 23274)
@@ -28,10 +28,12 @@
#include "gui/PopUpWidget.h"
#include "gui/TabWidget.h"
-#include "backends/fs/fs.h"
+#include "common/fs.h"
#include "common/config-manager.h"
+#include "common/system.h"
+
#include "graphics/scaler.h"
-#include "common/system.h"
+
#include "sound/mididrv.h"
#include "sound/mixer.h"
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