diff options
author | Max Horn | 2007-09-18 20:02:04 +0000 |
---|---|---|
committer | Max Horn | 2007-09-18 20:02:04 +0000 |
commit | c3d3aebe87d16d4fc3b7ac8581b99fb97241c9ac (patch) | |
tree | 17b2ba9f45743d2cf8f8e5faa6c9511e213f15f3 /backends/fs/amigaos4 | |
parent | 5c08cb1bcf84828cc93114fadbc89dd6f9909d06 (diff) | |
parent | 1dc13a641dd82825334e81bb3eb3b4ebd69d2552 (diff) | |
download | scummvm-rg350-c3d3aebe87d16d4fc3b7ac8581b99fb97241c9ac.tar.gz scummvm-rg350-c3d3aebe87d16d4fc3b7ac8581b99fb97241c9ac.tar.bz2 scummvm-rg350-c3d3aebe87d16d4fc3b7ac8581b99fb97241c9ac.zip |
Patch #1768757: Merge fsnode-gsoc into trunk (MAJOR change, will break compilation on some ports)
svn-id: r28944
Diffstat (limited to 'backends/fs/amigaos4')
-rw-r--r-- | backends/fs/amigaos4/amigaos4-fs-factory.cpp | 40 | ||||
-rw-r--r-- | backends/fs/amigaos4/amigaos4-fs-factory.h | 51 | ||||
-rw-r--r-- | backends/fs/amigaos4/amigaos4-fs.cpp | 166 |
3 files changed, 184 insertions, 73 deletions
diff --git a/backends/fs/amigaos4/amigaos4-fs-factory.cpp b/backends/fs/amigaos4/amigaos4-fs-factory.cpp new file mode 100644 index 0000000000..7307deb4bf --- /dev/null +++ b/backends/fs/amigaos4/amigaos4-fs-factory.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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 "backends/fs/amigaos4/amigaos4-fs-factory.h" +#include "backends/fs/amigaos4/amigaos4-fs.cpp" + +DECLARE_SINGLETON(AmigaOSFilesystemFactory); + +AbstractFilesystemNode *AmigaOSFilesystemFactory::makeRootFileNode() const { + return new AmigaOSFilesystemNode(); +} + +AbstractFilesystemNode *AmigaOSFilesystemFactory::makeCurrentDirectoryFileNode() const { + return new AmigaOSFilesystemNode(); +} + +AbstractFilesystemNode *AmigaOSFilesystemFactory::makeFileNodePath(const String &path) const { + return new AmigaOSFilesystemNode(path); +} diff --git a/backends/fs/amigaos4/amigaos4-fs-factory.h b/backends/fs/amigaos4/amigaos4-fs-factory.h new file mode 100644 index 0000000000..01a976bdd7 --- /dev/null +++ b/backends/fs/amigaos4/amigaos4-fs-factory.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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 AMIGAOS_FILESYSTEM_FACTORY_H +#define AMIGAOS_FILESYSTEM_FACTORY_H + +#include "common/singleton.h" +#include "backends/fs/abstract-fs-factory.h" + +/** + * Creates AmigaOSFilesystemNode objects. + * + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. + */ +class AmigaOSFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<AmigaOSFilesystemFactory> { +public: + typedef Common::String String; + + virtual AbstractFilesystemNode *makeRootFileNode() const; + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + +protected: + AmigaOSFilesystemFactory() {}; + +private: + friend class Common::Singleton<SingletonBaseType>; +}; + +#endif /*AMIGAOS_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp index ffed8bc87c..3eefd6507e 100644 --- a/backends/fs/amigaos4/amigaos4-fs.cpp +++ b/backends/fs/amigaos4/amigaos4-fs.cpp @@ -38,58 +38,76 @@ #include <common/stdafx.h> #include "common/util.h" - #include "engines/engine.h" #include "backends/fs/abstract-fs.h" #define ENTER() /* debug(6, "Enter") */ #define LEAVE() /* debug(6, "Leave") */ - const uint32 kExAllBufferSize = 40960; // TODO: is this okay for sure? +/** + * Implementation of the ScummVM file system API. + * + * Parts of this class are documented in the base interface class, AbstractFilesystemNode. + */ class AmigaOSFilesystemNode : public AbstractFilesystemNode { - protected: - BPTR _pFileLock; - String _sDisplayName; - bool _bIsDirectory; - bool _bIsValid; - String _sPath; - - public: - AmigaOSFilesystemNode(); - AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName = 0); - AmigaOSFilesystemNode(const String &p); - - // Note: Copy constructor is needed because it duplicates the file lock - AmigaOSFilesystemNode(const AmigaOSFilesystemNode &node); - - virtual ~AmigaOSFilesystemNode(); - - virtual String displayName() const { return _sDisplayName; }; - virtual String name() const { return _sDisplayName; }; - virtual bool isValid() const { return _bIsValid; }; - virtual bool isDirectory() const { return _bIsDirectory; }; - virtual String path() const { return _sPath; }; - - virtual bool listDir(AbstractFSList &list, ListMode mode) const; - virtual AbstractFSList listVolumes() const; - virtual AbstractFilesystemNode *parent() const; - virtual AbstractFilesystemNode *child(const String &n) const; +protected: + BPTR _pFileLock; + String _sDisplayName; + String _sPath; + bool _bIsDirectory; + bool _bIsValid; + +public: + /** + * Creates a AmigaOSFilesystemNode with the root node as path. + */ + AmigaOSFilesystemNode(); + + /** + * Creates a AmigaOSFilesystemNode for a given path. + * + * @param path String with the path the new node should point to. + */ + AmigaOSFilesystemNode(const String &p); + + /** + * FIXME: document this constructor. + */ + AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName = 0); + + /** + * Copy constructor. + * + * @note Needed because it duplicates the file lock + */ + AmigaOSFilesystemNode(const AmigaOSFilesystemNode &node); + + /** + * Destructor. + */ + virtual ~AmigaOSFilesystemNode(); + + virtual bool exists() const { return true; } //FIXME: this is just a stub + virtual String getDisplayName() const { return _sDisplayName; }; + virtual String getName() const { return _sDisplayName; }; + virtual String getPath() const { return _sPath; }; + virtual bool isDirectory() const { return _bIsDirectory; }; + virtual bool isReadable() const { return true; } //FIXME: this is just a stub + virtual bool isValid() const { return _bIsValid; }; + virtual bool isWritable() const { return true; } //FIXME: this is just a stub + + virtual AbstractFilesystemNode *getChild(const String &n) const; + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; + virtual AbstractFilesystemNode *getParent() const; + + /** + * Creates a list with all the volumes present in the root node. + */ + virtual AbstractFSList listVolumes() const; }; -AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() { - return AbstractFilesystemNode::getRoot(); -} - -AbstractFilesystemNode *AbstractFilesystemNode::getRoot() { - return new AmigaOSFilesystemNode(); -} - -AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) { - return new AmigaOSFilesystemNode(path); -} - AmigaOSFilesystemNode::AmigaOSFilesystemNode() { ENTER(); _sDisplayName = "Available Disks"; @@ -100,7 +118,6 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode() { LEAVE(); } - AmigaOSFilesystemNode::AmigaOSFilesystemNode(const String &p) { ENTER(); @@ -150,7 +167,6 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(const String &p) { const char c = _sPath.lastChar(); if (c != '/' && c != ':') _sPath += '/'; - } else { //_bIsDirectory = false; @@ -170,7 +186,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayNam int bufSize = MAXPATHLEN; _pFileLock = 0; - while (1) { + while (true) { char *n = new char[bufSize]; if (IDOS->NameFromLock(pLock, (STRPTR)n, bufSize) != DOSFALSE) { _sPath = n; @@ -186,6 +202,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayNam delete [] n; return; } + bufSize *= 2; delete [] n; } @@ -238,9 +255,35 @@ AmigaOSFilesystemNode::~AmigaOSFilesystemNode() { LEAVE(); } -bool AmigaOSFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const { +AbstractFilesystemNode *AmigaOSFilesystemNode::getChild(const String &n) const { + if (!_bIsDirectory) { + debug(6, "Not a directory"); + return 0; + } + + String newPath(_sPath); + + if (_sPath.lastChar() != '/') + newPath += '/'; + + newPath += n; + BPTR lock = IDOS->Lock(newPath.c_str(), SHARED_LOCK); + + if (!lock) { + debug(6, "Bad path"); + return 0; + } + + IDOS->UnLock(lock); + + return new AmigaOSFilesystemNode(newPath); +} + +bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const { ENTER(); + //TODO: honor the hidden flag + if (!_bIsValid) { debug(6, "Invalid node"); LEAVE(); @@ -308,10 +351,11 @@ bool AmigaOSFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const } LEAVE(); + return true; } -AbstractFilesystemNode *AmigaOSFilesystemNode::parent() const { +AbstractFilesystemNode *AmigaOSFilesystemNode::getParent() const { ENTER(); if (!_bIsDirectory) { @@ -337,33 +381,8 @@ AbstractFilesystemNode *AmigaOSFilesystemNode::parent() const { node = new AmigaOSFilesystemNode(); LEAVE(); - return node; -} - -AbstractFilesystemNode *AmigaOSFilesystemNode::child(const String &n) const { - if (!_bIsDirectory) { - debug(6, "Not a directory"); - return 0; - } - - String newPath(_sPath); - - if (_sPath.lastChar() != '/') - newPath += '/'; - - newPath += n; - - BPTR lock = IDOS->Lock(newPath.c_str(), SHARED_LOCK); - - if (!lock) { - debug(6, "Bad path"); - return 0; - } - - IDOS->UnLock(lock); - - return new AmigaOSFilesystemNode(newPath); + return node; } AbstractFSList AmigaOSFilesystemNode::listVolumes() const { @@ -431,7 +450,8 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const { IDOS->UnLockDosList(kLockFlags); LEAVE(); + return myList; } -#endif +#endif //defined(__amigaos4__) |