diff options
author | Max Horn | 2011-05-03 10:33:03 +0200 |
---|---|---|
committer | Max Horn | 2011-05-03 13:22:00 +0200 |
commit | f62fd4f25f5fcc237d59054af0d6182da8d8eff8 (patch) | |
tree | 05fd53a36cd791f91419e261a547c7c2406daa98 /backends | |
parent | 5ea9e14c2fcd3c1054ce95867ca7df7c8498a2d8 (diff) | |
download | scummvm-rg350-f62fd4f25f5fcc237d59054af0d6182da8d8eff8.tar.gz scummvm-rg350-f62fd4f25f5fcc237d59054af0d6182da8d8eff8.tar.bz2 scummvm-rg350-f62fd4f25f5fcc237d59054af0d6182da8d8eff8.zip |
BACKENDS: Avoid #including .cpp files
So far, the various *-fs-factory.cpp files were #including the
corresponding *-fs.cpp files. This is surprising and hence could lead to
all kinds of problems). To fix this, provide proper headers for the
*-fs.cpp files.
This also makes code reuse via subclassing possible.
Since not all ports were tested, this will likely lead to a few
easy to fix compile regressions.
Diffstat (limited to 'backends')
30 files changed, 769 insertions, 507 deletions
diff --git a/backends/fs/amigaos4/amigaos4-fs-factory.cpp b/backends/fs/amigaos4/amigaos4-fs-factory.cpp index 2c7dc61278..51c2c294d4 100644 --- a/backends/fs/amigaos4/amigaos4-fs-factory.cpp +++ b/backends/fs/amigaos4/amigaos4-fs-factory.cpp @@ -23,8 +23,9 @@ */ #if defined(__amigaos4__) + #include "backends/fs/amigaos4/amigaos4-fs-factory.h" -#include "backends/fs/amigaos4/amigaos4-fs.cpp" +#include "backends/fs/amigaos4/amigaos4-fs.h" AbstractFSNode *AmigaOSFilesystemFactory::makeRootFileNode() const { return new AmigaOSFilesystemNode(); diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp index 8a57a3cf1c..4f763ef9e8 100644 --- a/backends/fs/amigaos4/amigaos4-fs.cpp +++ b/backends/fs/amigaos4/amigaos4-fs.cpp @@ -23,97 +23,16 @@ */ #if defined(__amigaos4__) -#ifdef __USE_INLINE__ -#undef __USE_INLINE__ -#endif - -#include <proto/exec.h> -#include <proto/dos.h> -#include <stdio.h> - -#ifndef USE_NEWLIB -#include <strings.h> -#endif +#include "backends/fs/amigaos4/amigaos4-fs.h" +#include "backends/fs/stdiostream.h" #include "common/debug.h" #include "common/util.h" -#include "backends/fs/abstract-fs.h" -#include "backends/fs/stdiostream.h" #define ENTER() /* debug(6, "Enter") */ #define LEAVE() /* debug(6, "Leave") */ /** - * Implementation of the ScummVM file system API. - * - * Parts of this class are documented in the base interface class, AbstractFSNode. - */ -class AmigaOSFilesystemNode : public AbstractFSNode { -protected: - BPTR _pFileLock; - Common::String _sDisplayName; - Common::String _sPath; - bool _bIsDirectory; - bool _bIsValid; - uint32 _nProt; - - /** - * Creates a list with all the volumes present in the root node. - */ - virtual AbstractFSList listVolumes() const; - -public: - /** - * Creates an AmigaOSFilesystemNode with the root node as path. - */ - AmigaOSFilesystemNode(); - - /** - * Creates an AmigaOSFilesystemNode for a given path. - * - * @param path Common::String with the path the new node should point to. - */ - AmigaOSFilesystemNode(const Common::String &p); - - /** - * Creates an AmigaOSFilesystemNode given its lock and display name - * - * @param pLock BPTR to the lock. - * @param pDisplayName name to be used for display, in case not supplied the FilePart() of the filename will be used. - * - * @note This shouldn't even be public as it's only internally, at best it should have been protected if not private - */ - 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; - virtual Common::String getDisplayName() const { return _sDisplayName; }; - virtual Common::String getName() const { return _sDisplayName; }; - virtual Common::String getPath() const { return _sPath; }; - virtual bool isDirectory() const { return _bIsDirectory; }; - virtual bool isReadable() const; - virtual bool isWritable() const; - - virtual AbstractFSNode *getChild(const Common::String &n) const; - virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFSNode *getParent() const; - - virtual Common::SeekableReadStream *createReadStream(); - virtual Common::WriteStream *createWriteStream(); -}; - -/** * Returns the last component of a given path. * * @param str Common::String containing the path. @@ -497,11 +416,11 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const { } Common::SeekableReadStream *AmigaOSFilesystemNode::createReadStream() { - return StdioStream::makeFromPath(getPath().c_str(), false); + return StdioStream::makeFromPath(getPath(), false); } Common::WriteStream *AmigaOSFilesystemNode::createWriteStream() { - return StdioStream::makeFromPath(getPath().c_str(), true); + return StdioStream::makeFromPath(getPath(), true); } #endif //defined(__amigaos4__) diff --git a/backends/fs/amigaos4/amigaos4-fs.h b/backends/fs/amigaos4/amigaos4-fs.h new file mode 100644 index 0000000000..83188f89f1 --- /dev/null +++ b/backends/fs/amigaos4/amigaos4-fs.h @@ -0,0 +1,113 @@ +/* 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_H +#define AMIGAOS_FILESYSTEM_H + +#ifdef __USE_INLINE__ +#undef __USE_INLINE__ +#endif + +#include <proto/exec.h> +#include <proto/dos.h> +#include <stdio.h> + +#ifndef USE_NEWLIB +#include <strings.h> +#endif + +#include "backends/fs/abstract-fs.h" + +/** + * Implementation of the ScummVM file system API. + * + * Parts of this class are documented in the base interface class, AbstractFSNode. + */ +class AmigaOSFilesystemNode : public AbstractFSNode { +protected: + BPTR _pFileLock; + Common::String _sDisplayName; + Common::String _sPath; + bool _bIsDirectory; + bool _bIsValid; + uint32 _nProt; + + /** + * Creates a list with all the volumes present in the root node. + */ + virtual AbstractFSList listVolumes() const; + +public: + /** + * Creates an AmigaOSFilesystemNode with the root node as path. + */ + AmigaOSFilesystemNode(); + + /** + * Creates an AmigaOSFilesystemNode for a given path. + * + * @param path Common::String with the path the new node should point to. + */ + AmigaOSFilesystemNode(const Common::String &p); + + /** + * Creates an AmigaOSFilesystemNode given its lock and display name + * + * @param pLock BPTR to the lock. + * @param pDisplayName name to be used for display, in case not supplied the FilePart() of the filename will be used. + * + * @note This shouldn't even be public as it's only internally, at best it should have been protected if not private + */ + 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; + virtual Common::String getDisplayName() const { return _sDisplayName; }; + virtual Common::String getName() const { return _sDisplayName; }; + virtual Common::String getPath() const { return _sPath; }; + virtual bool isDirectory() const { return _bIsDirectory; }; + virtual bool isReadable() const; + virtual bool isWritable() const; + + virtual AbstractFSNode *getChild(const Common::String &n) const; + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; + virtual AbstractFSNode *getParent() const; + + virtual Common::SeekableReadStream *createReadStream(); + virtual Common::WriteStream *createWriteStream(); +}; + + +#endif diff --git a/backends/fs/n64/n64-fs-factory.cpp b/backends/fs/n64/n64-fs-factory.cpp index 7e314693b8..fff0f7804b 100644 --- a/backends/fs/n64/n64-fs-factory.cpp +++ b/backends/fs/n64/n64-fs-factory.cpp @@ -27,7 +27,7 @@ #include <n64utils.h> #include "backends/fs/n64/n64-fs-factory.h" -#include "backends/fs/n64/n64-fs.cpp" +#include "backends/fs/n64/n64-fs.h" AbstractFSNode *N64FilesystemFactory::makeRootFileNode() const { return new N64FilesystemNode(); diff --git a/backends/fs/n64/n64-fs.cpp b/backends/fs/n64/n64-fs.cpp index 4def84afcd..75c1e0bea0 100644 --- a/backends/fs/n64/n64-fs.cpp +++ b/backends/fs/n64/n64-fs.cpp @@ -22,7 +22,7 @@ #ifdef __N64__ -#include "backends/fs/abstract-fs.h" +#include "backends/fs/n64/n64-fs.h" #include "backends/fs/n64/romfsstream.h" #include <sys/param.h> @@ -31,56 +31,6 @@ #define ROOT_PATH "/" -/** - * Implementation of the ScummVM file system API based on N64 Hkz romfs. - * - * Parts of this class are documented in the base interface class, AbstractFSNode. - */ -class N64FilesystemNode : public AbstractFSNode { -protected: - Common::String _displayName; - Common::String _path; - bool _isDirectory; - bool _isValid; - -public: - /** - * Creates a N64FilesystemNode with the root node as path. - */ - N64FilesystemNode(); - - /** - * Creates a N64FilesystemNode for a given path. - * - * @param path Common::String with the path the new node should point to. - * @param verify true if the isValid and isDirectory flags should be verified during the construction. - */ - N64FilesystemNode(const Common::String &p, bool verify = true); - - virtual bool exists() const; - virtual Common::String getDisplayName() const { - return _displayName; - } - virtual Common::String getName() const { - return _displayName; - } - virtual Common::String getPath() const { - return _path; - } - virtual bool isDirectory() const { - return _isDirectory; - } - virtual bool isReadable() const; - virtual bool isWritable() const; - - virtual AbstractFSNode *getChild(const Common::String &n) const; - virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFSNode *getParent() const; - - virtual Common::SeekableReadStream *createReadStream(); - virtual Common::WriteStream *createWriteStream(); -}; - N64FilesystemNode::N64FilesystemNode() { _isDirectory = true; _displayName = "Root"; diff --git a/backends/fs/n64/n64-fs.h b/backends/fs/n64/n64-fs.h new file mode 100644 index 0000000000..3a5dd375b9 --- /dev/null +++ b/backends/fs/n64/n64-fs.h @@ -0,0 +1,80 @@ +/* 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 N64_FILESYSTEM_H +#define N64_FILESYSTEM_H + +#include "backends/fs/abstract-fs.h" + +/** + * Implementation of the ScummVM file system API based on N64 Hkz romfs. + * + * Parts of this class are documented in the base interface class, AbstractFSNode. + */ +class N64FilesystemNode : public AbstractFSNode { +protected: + Common::String _displayName; + Common::String _path; + bool _isDirectory; + bool _isValid; + +public: + /** + * Creates a N64FilesystemNode with the root node as path. + */ + N64FilesystemNode(); + + /** + * Creates a N64FilesystemNode for a given path. + * + * @param path Common::String with the path the new node should point to. + * @param verify true if the isValid and isDirectory flags should be verified during the construction. + */ + N64FilesystemNode(const Common::String &p, bool verify = true); + + virtual bool exists() const; + virtual Common::String getDisplayName() const { + return _displayName; + } + virtual Common::String getName() const { + return _displayName; + } + virtual Common::String getPath() const { + return _path; + } + virtual bool isDirectory() const { + return _isDirectory; + } + virtual bool isReadable() const; + virtual bool isWritable() const; + + virtual AbstractFSNode *getChild(const Common::String &n) const; + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; + virtual AbstractFSNode *getParent() const; + + virtual Common::SeekableReadStream *createReadStream(); + virtual Common::WriteStream *createWriteStream(); +}; + +#endif diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/fs/posix/posix-fs-factory.cpp index 4d23a9e095..a69cf6b3b4 100644 --- a/backends/fs/posix/posix-fs-factory.cpp +++ b/backends/fs/posix/posix-fs-factory.cpp @@ -30,7 +30,7 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_unlink #include "backends/fs/posix/posix-fs-factory.h" -#include "backends/fs/posix/posix-fs.cpp" +#include "backends/fs/posix/posix-fs.h" AbstractFSNode *POSIXFilesystemFactory::makeRootFileNode() const { return new POSIXFilesystemNode("/"); diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index b218e9dd59..7aa17e5cc1 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -24,6 +24,11 @@ #if defined(UNIX) +// Re-enable some forbidden symbols to avoid clashes with stat.h and unistd.h. +#define FORBIDDEN_SYMBOL_EXCEPTION_chdir +#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_unlink + #include "backends/fs/posix/posix-fs.h" #include "backends/fs/stdiostream.h" #include "common/algorithm.h" @@ -238,11 +243,11 @@ AbstractFSNode *POSIXFilesystemNode::getParent() const { } Common::SeekableReadStream *POSIXFilesystemNode::createReadStream() { - return StdioStream::makeFromPath(getPath().c_str(), false); + return StdioStream::makeFromPath(getPath(), false); } Common::WriteStream *POSIXFilesystemNode::createWriteStream() { - return StdioStream::makeFromPath(getPath().c_str(), true); + return StdioStream::makeFromPath(getPath(), true); } #endif //#if defined(UNIX) diff --git a/backends/fs/posix/posix-fs.h b/backends/fs/posix/posix-fs.h index 859e8973b3..003a0b38d0 100644 --- a/backends/fs/posix/posix-fs.h +++ b/backends/fs/posix/posix-fs.h @@ -83,4 +83,4 @@ private: virtual void setFlags(); }; -#endif /*POSIX_FILESYSTEM_H*/ +#endif diff --git a/backends/fs/ps2/ps2-fs-factory.cpp b/backends/fs/ps2/ps2-fs-factory.cpp index 8b5202bff4..9e7ec3fa10 100644 --- a/backends/fs/ps2/ps2-fs-factory.cpp +++ b/backends/fs/ps2/ps2-fs-factory.cpp @@ -28,7 +28,7 @@ #define FORBIDDEN_SYMBOL_ALLOW_ALL #include "backends/fs/ps2/ps2-fs-factory.h" -#include "backends/fs/ps2/ps2-fs.cpp" +#include "backends/fs/ps2/ps2-fs.h" DECLARE_SINGLETON(Ps2FilesystemFactory); @@ -43,4 +43,5 @@ AbstractFSNode *Ps2FilesystemFactory::makeCurrentDirectoryFileNode() const { AbstractFSNode *Ps2FilesystemFactory::makeFileNodePath(const Common::String &path) const { return new Ps2FilesystemNode(path, true); } + #endif diff --git a/backends/fs/ps2/ps2-fs-factory.h b/backends/fs/ps2/ps2-fs-factory.h index 3a1dec252d..f193982d6b 100644 --- a/backends/fs/ps2/ps2-fs-factory.h +++ b/backends/fs/ps2/ps2-fs-factory.h @@ -39,9 +39,6 @@ public: virtual AbstractFSNode *makeCurrentDirectoryFileNode() const; virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; -protected: - Ps2FilesystemFactory() {}; - private: friend class Common::Singleton<SingletonBaseType>; }; diff --git a/backends/fs/ps2/ps2-fs.cpp b/backends/fs/ps2/ps2-fs.cpp index 0968ecc9d3..24cc6bd30a 100644 --- a/backends/fs/ps2/ps2-fs.cpp +++ b/backends/fs/ps2/ps2-fs.cpp @@ -22,7 +22,14 @@ * $Id$ */ -#include "backends/fs/abstract-fs.h" +#if defined(__PLAYSTATION2__) + +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + + +#include "backends/fs/ps2/ps2-fs.h" + #include <kernel.h> #include <stdio.h> #include <stdlib.h> @@ -40,81 +47,6 @@ extern AsyncFio fio; extern OSystem_PS2 *g_systemPs2; -/** - * Implementation of the ScummVM file system API based on the Ps2SDK. - * - * Parts of this class are documented in the base interface class, AbstractFSNode. - */ -class Ps2FilesystemNode : public AbstractFSNode { - -friend class Ps2FilesystemFactory; - -protected: - Common::String _displayName; - Common::String _path; - bool _isDirectory; - bool _isRoot; - bool _isHere; - bool _verified; - -private: - const char *getDeviceDescription() const; - void doverify(); - -public: - /** - * Creates a PS2FilesystemNode with the root node as path. - */ - Ps2FilesystemNode(); - - /** - * Creates a PS2FilesystemNode for a given path. - * - * @param path Common::String with the path the new node should point to. - */ - Ps2FilesystemNode(const Common::String &path); - Ps2FilesystemNode(const Common::String &path, bool verify); - - /** - * Copy constructor. - */ - Ps2FilesystemNode(const Ps2FilesystemNode *node); - - virtual Common::String getDisplayName() const { return _displayName; } - virtual Common::String getName() const { return _displayName; } - virtual Common::String getPath() const { return _path; } - - virtual bool exists() const { - // printf("%s : is %d\n", _path.c_str(), _isHere); - return _isHere; - } - - virtual bool isDirectory() const { - // printf("%s : dir %d\n", _path.c_str(), _isDirectory); - return _isDirectory; - } - - virtual bool isReadable() const { - return _isHere; - } - - virtual bool isWritable() const { - if (strncmp(_path.c_str(), "cdfs", 4)==0) - return false; - return true; // exists(); // creating ? - } - - virtual AbstractFSNode *clone() const { return new Ps2FilesystemNode(this); } - virtual AbstractFSNode *getChild(const Common::String &n) const; - virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFSNode *getParent() const; - - virtual Common::SeekableReadStream *createReadStream(); - virtual Common::WriteStream *createWriteStream(); - - int getDev() { return 0; }; -}; - const char *_lastPathComponent(const Common::String &str) { if (str.empty()) return ""; @@ -502,10 +434,12 @@ const char *Ps2FilesystemNode::getDeviceDescription() const { } Common::SeekableReadStream *Ps2FilesystemNode::createReadStream() { - Common::SeekableReadStream *ss = PS2FileStream::makeFromPath(getPath().c_str(), false); + Common::SeekableReadStream *ss = PS2FileStream::makeFromPath(getPath(), false); return ss; } Common::WriteStream *Ps2FilesystemNode::createWriteStream() { - return PS2FileStream::makeFromPath(getPath().c_str(), true); + return PS2FileStream::makeFromPath(getPath(), true); } + +#endif diff --git a/backends/fs/ps2/ps2-fs.h b/backends/fs/ps2/ps2-fs.h new file mode 100644 index 0000000000..0c37ceeb91 --- /dev/null +++ b/backends/fs/ps2/ps2-fs.h @@ -0,0 +1,105 @@ +/* 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 PS2_FILESYSTEM_H +#define PS2_FILESYSTEM_H + +#include "backends/fs/abstract-fs.h" + +/** + * Implementation of the ScummVM file system API based on the Ps2SDK. + * + * Parts of this class are documented in the base interface class, AbstractFSNode. + */ +class Ps2FilesystemNode : public AbstractFSNode { + +friend class Ps2FilesystemFactory; + +protected: + Common::String _displayName; + Common::String _path; + bool _isDirectory; + bool _isRoot; + bool _isHere; + bool _verified; + +private: + const char *getDeviceDescription() const; + void doverify(); + +public: + /** + * Creates a PS2FilesystemNode with the root node as path. + */ + Ps2FilesystemNode(); + + /** + * Creates a PS2FilesystemNode for a given path. + * + * @param path Common::String with the path the new node should point to. + */ + Ps2FilesystemNode(const Common::String &path); + Ps2FilesystemNode(const Common::String &path, bool verify); + + /** + * Copy constructor. + */ + Ps2FilesystemNode(const Ps2FilesystemNode *node); + + virtual Common::String getDisplayName() const { return _displayName; } + virtual Common::String getName() const { return _displayName; } + virtual Common::String getPath() const { return _path; } + + virtual bool exists() const { + // printf("%s : is %d\n", _path.c_str(), _isHere); + return _isHere; + } + + virtual bool isDirectory() const { + // printf("%s : dir %d\n", _path.c_str(), _isDirectory); + return _isDirectory; + } + + virtual bool isReadable() const { + return _isHere; + } + + virtual bool isWritable() const { + if (strncmp(_path.c_str(), "cdfs", 4)==0) + return false; + return true; // exists(); // creating ? + } + + virtual AbstractFSNode *clone() const { return new Ps2FilesystemNode(this); } + virtual AbstractFSNode *getChild(const Common::String &n) const; + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; + virtual AbstractFSNode *getParent() const; + + virtual Common::SeekableReadStream *createReadStream(); + virtual Common::WriteStream *createWriteStream(); + + int getDev() { return 0; }; +}; + +#endif diff --git a/backends/fs/psp/psp-fs-factory.cpp b/backends/fs/psp/psp-fs-factory.cpp index 7ed84de034..7fd8d8b077 100644 --- a/backends/fs/psp/psp-fs-factory.cpp +++ b/backends/fs/psp/psp-fs-factory.cpp @@ -23,8 +23,9 @@ */ #if defined(__PSP__) + #include "backends/fs/psp/psp-fs-factory.h" -#include "backends/fs/psp/psp-fs.cpp" +#include "backends/fs/psp/psp-fs.h" DECLARE_SINGLETON(PSPFilesystemFactory); @@ -34,7 +35,7 @@ AbstractFSNode *PSPFilesystemFactory::makeRootFileNode() const { AbstractFSNode *PSPFilesystemFactory::makeCurrentDirectoryFileNode() const { char buf[MAXPATHLEN]; - char * ret = 0; + char *ret = 0; PowerMan.beginCriticalSection(); ret = getcwd(buf, MAXPATHLEN); @@ -46,4 +47,5 @@ AbstractFSNode *PSPFilesystemFactory::makeCurrentDirectoryFileNode() const { AbstractFSNode *PSPFilesystemFactory::makeFileNodePath(const Common::String &path) const { return new PSPFilesystemNode(path, true); } + #endif diff --git a/backends/fs/psp/psp-fs.cpp b/backends/fs/psp/psp-fs.cpp index 16a0e9cd5b..e7fa265b31 100644 --- a/backends/fs/psp/psp-fs.cpp +++ b/backends/fs/psp/psp-fs.cpp @@ -22,12 +22,12 @@ * $Id$ */ -#ifdef __PSP__ +#if defined(__PSP__) -#include "engines/engine.h" -#include "backends/fs/abstract-fs.h" +#include "backends/fs/psp/psp-fs.h" #include "backends/fs/psp/psp-stream.h" #include "common/bufferedstream.h" +#include "engines/engine.h" #include <sys/stat.h> #include <unistd.h> @@ -41,48 +41,6 @@ //#define __PSP_DEBUG_PRINT__ /* For debug printouts */ #include "backends/platform/psp/trace.h" -/** - * Implementation of the ScummVM file system API based on PSPSDK API. - * - * Parts of this class are documented in the base interface class, AbstractFSNode. - */ -class PSPFilesystemNode : public AbstractFSNode { -protected: - Common::String _displayName; - Common::String _path; - bool _isDirectory; - bool _isValid; - -public: - /** - * Creates a PSPFilesystemNode with the root node as path. - */ - PSPFilesystemNode(); - - /** - * Creates a PSPFilesystemNode for a given path. - * - * @param path Common::String with the path the new node should point to. - * @param verify true if the isValid and isDirectory flags should be verified during the construction. - */ - PSPFilesystemNode(const Common::String &p, bool verify = true); - - virtual bool exists() const; - virtual Common::String getDisplayName() const { return _displayName; } - virtual Common::String getName() const { return _displayName; } - virtual Common::String getPath() const { return _path; } - virtual bool isDirectory() const { return _isDirectory; } - virtual bool isReadable() const; - virtual bool isWritable() const; - - virtual AbstractFSNode *getChild(const Common::String &n) const; - virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFSNode *getParent() const; - - virtual Common::SeekableReadStream *createReadStream(); - virtual Common::WriteStream *createWriteStream(); -}; - PSPFilesystemNode::PSPFilesystemNode() { _isDirectory = true; _displayName = "Root"; diff --git a/backends/fs/psp/psp-fs.h b/backends/fs/psp/psp-fs.h new file mode 100644 index 0000000000..12d2c540c0 --- /dev/null +++ b/backends/fs/psp/psp-fs.h @@ -0,0 +1,72 @@ +/* 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 PSP_FILESYSTEM_H +#define PSP_FILESYSTEM_H + +#include "backends/fs/abstract-fs.h" + +/** + * Implementation of the ScummVM file system API based on PSPSDK API. + * + * Parts of this class are documented in the base interface class, AbstractFSNode. + */ +class PSPFilesystemNode : public AbstractFSNode { +protected: + Common::String _displayName; + Common::String _path; + bool _isDirectory; + bool _isValid; + +public: + /** + * Creates a PSPFilesystemNode with the root node as path. + */ + PSPFilesystemNode(); + + /** + * Creates a PSPFilesystemNode for a given path. + * + * @param path Common::String with the path the new node should point to. + * @param verify true if the isValid and isDirectory flags should be verified during the construction. + */ + PSPFilesystemNode(const Common::String &p, bool verify = true); + + virtual bool exists() const; + virtual Common::String getDisplayName() const { return _displayName; } + virtual Common::String getName() const { return _displayName; } + virtual Common::String getPath() const { return _path; } + virtual bool isDirectory() const { return _isDirectory; } + virtual bool isReadable() const; + virtual bool isWritable() const; + + virtual AbstractFSNode *getChild(const Common::String &n) const; + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; + virtual AbstractFSNode *getParent() const; + + virtual Common::SeekableReadStream *createReadStream(); + virtual Common::WriteStream *createWriteStream(); +}; + +#endif diff --git a/backends/fs/symbian/symbian-fs-factory.cpp b/backends/fs/symbian/symbian-fs-factory.cpp index c70a67f339..9afacfebf5 100644 --- a/backends/fs/symbian/symbian-fs-factory.cpp +++ b/backends/fs/symbian/symbian-fs-factory.cpp @@ -24,7 +24,7 @@ #if defined(__SYMBIAN32__) #include "backends/fs/symbian/symbian-fs-factory.h" -#include "backends/fs/symbian/symbian-fs.cpp" +#include "backends/fs/symbian/symbian-fs.h" AbstractFSNode *SymbianFilesystemFactory::makeRootFileNode() const { return new SymbianFilesystemNode(true); diff --git a/backends/fs/symbian/symbian-fs.cpp b/backends/fs/symbian/symbian-fs.cpp index 5d4951e269..b8fc5e19f6 100644 --- a/backends/fs/symbian/symbian-fs.cpp +++ b/backends/fs/symbian/symbian-fs.cpp @@ -23,7 +23,8 @@ */ #if defined (__SYMBIAN32__) -#include "backends/fs/abstract-fs.h" + +#include "backends/fs/symbian/symbian-fs.h" #include "backends/fs/symbian/symbianstream.h" #include "backends/platform/symbian/src/symbianos.h" @@ -35,66 +36,11 @@ #define KDriveLabelSize 30 /** - * Implementation of the ScummVM file system API based on POSIX. - * - * Parts of this class are documented in the base interface class, AbstractFSNode. - */ -class SymbianFilesystemNode : public AbstractFSNode { -protected: - Common::String _displayName; - Common::String _path; - TBool _isDirectory; - TBool _isValid; - TBool _isPseudoRoot; -public: - /** - * Creates a SymbianFilesystemNode with the root node as path. - * - * @param aIsRoot true if the node will be a pseudo root, false otherwise. - */ - SymbianFilesystemNode(bool aIsRoot); - - /** - * Creates a SymbianFilesystemNode for a given path. - * - * @param path Common::String with the path the new node should point to. - */ - SymbianFilesystemNode(const Common::String &path); - - virtual bool exists() const { - TFileName fname; - TPtrC8 ptr((const unsigned char*) _path.c_str(), _path.size()); - fname.Copy(ptr); - TBool fileExists = BaflUtils::FileExists(static_cast<OSystem_SDL_Symbian*> (g_system)->FsSession(), fname); - if (!fileExists) { - TParsePtrC parser(fname); - if (parser.PathPresent() && parser.Path().Compare(_L("\\")) == KErrNone && !parser.NameOrExtPresent()) { - fileExists = ETrue; - } - } - return fileExists; - } - virtual Common::String getDisplayName() const { return _displayName; } - virtual Common::String getName() const { return _displayName; } - virtual Common::String getPath() const { return _path; } - virtual bool isDirectory() const { return _isDirectory; } - virtual bool isReadable() const { return access(_path.c_str(), R_OK) == 0; } //FIXME: this is just a stub - virtual bool isWritable() const { return access(_path.c_str(), W_OK) == 0; } //FIXME: this is just a stub - - virtual AbstractFSNode *getChild(const Common::String &n) const; - virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFSNode *getParent() const; - - virtual Common::SeekableReadStream *createReadStream(); - virtual Common::WriteStream *createWriteStream(); -}; - -/** * Fixes the path by changing all slashes to backslashes. * * @param path Common::String with the path to be fixed. */ -static void fixFilePath(Common::String& aPath){ +static void fixFilePath(Common::String &aPath){ TInt len = aPath.size(); for (TInt index = 0; index < len; index++) { @@ -106,18 +52,15 @@ static void fixFilePath(Common::String& aPath){ SymbianFilesystemNode::SymbianFilesystemNode(bool aIsRoot) { _path = ""; - _isValid = ETrue; - _isDirectory = ETrue; + _isValid = true; + _isDirectory = true; _isPseudoRoot = aIsRoot; _displayName = "Root"; } SymbianFilesystemNode::SymbianFilesystemNode(const Common::String &path) { - if (path.size() == 0) - _isPseudoRoot = ETrue; - else - _isPseudoRoot = EFalse; + _isPseudoRoot = path.empty(); _path = path; @@ -131,18 +74,41 @@ SymbianFilesystemNode::SymbianFilesystemNode(const Common::String &path) { fname.Copy(ptr); if (static_cast<OSystem_SDL_Symbian*>(g_system)->FsSession().Entry(fname, fileAttribs) == KErrNone) { - _isValid = ETrue; + _isValid = true; _isDirectory = fileAttribs.IsDir(); } else { - _isValid = ETrue; - _isDirectory = EFalse; + _isValid = true; + _isDirectory = false; TParsePtrC parser(fname); if (parser.PathPresent() && parser.Path().Compare(_L("\\")) == KErrNone && !parser.NameOrExtPresent()) { - _isDirectory = ETrue; + _isDirectory = true; } } } +bool SymbianFilesystemNode::exists() const { + TFileName fname; + TPtrC8 ptr((const unsigned char*) _path.c_str(), _path.size()); + fname.Copy(ptr); + bool fileExists = BaflUtils::FileExists(static_cast<OSystem_SDL_Symbian*> (g_system)->FsSession(), fname); + if (!fileExists) { + TParsePtrC parser(fname); + if (parser.PathPresent() && parser.Path().Compare(_L("\\")) == KErrNone && !parser.NameOrExtPresent()) { + fileExists = true; + } + } + return fileExists; +} + +bool SymbianFilesystemNode::isReadable() const { + return access(_path.c_str(), R_OK) == 0; +} + +bool SymbianFilesystemNode::isWritable() const { + return access(_path.c_str(), W_OK) == 0; +} + + AbstractFSNode *SymbianFilesystemNode::getChild(const Common::String &n) const { assert(_isDirectory); Common::String newPath(_path); @@ -191,9 +157,9 @@ bool SymbianFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b SymbianFilesystemNode entry(false); entry._displayName = (char*) driveString8.PtrZ(); // drive_name - entry._isDirectory = ETrue; - entry._isValid = ETrue; - entry._isPseudoRoot = EFalse; + entry._isDirectory = true; + entry._isValid = true; + entry._isPseudoRoot = false; entry._path = path; myList.push_back(new SymbianFilesystemNode(entry)); } @@ -209,20 +175,20 @@ bool SymbianFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b if (static_cast<OSystem_SDL_Symbian*>(g_system)->FsSession().GetDir(fname, KEntryAttNormal|KEntryAttDir, 0, dirPtr) == KErrNone) { CleanupStack::PushL(dirPtr); - TInt cnt=dirPtr->Count(); - for (TInt loop=0;loop<cnt;loop++) { - TEntry fileentry=(*dirPtr)[loop]; + TInt cnt = dirPtr->Count(); + for (TInt loop = 0; loop < cnt; loop++) { + TEntry fileentry = (*dirPtr)[loop]; nameBuf.Copy(fileentry.iName); - SymbianFilesystemNode entry(EFalse); - entry._isPseudoRoot = EFalse; + SymbianFilesystemNode entry(false); + entry._isPseudoRoot = false; - entry._displayName =(char*) nameBuf.PtrZ(); + entry._displayName =(char *)nameBuf.PtrZ(); entry._path = _path; if (entry._path.lastChar() != '\\') entry._path+= '\\'; - entry._path +=(char*) nameBuf.PtrZ(); + entry._path +=(char *)nameBuf.PtrZ(); entry._isDirectory = fileentry.IsDir(); // Honor the chosen mode @@ -245,29 +211,27 @@ AbstractFSNode *SymbianFilesystemNode::getParent() const { // Root node is its own parent. Still we can't just return this // as the GUI code will call delete on the old node. if (!_isPseudoRoot && _path.size() > 3) { - p = new SymbianFilesystemNode(EFalse); + p = new SymbianFilesystemNode(false); const char *start = _path.c_str(); const char *end = lastPathComponent(_path, '\\'); p->_path = Common::String(start, end - start); - p->_isValid = ETrue; - p->_isDirectory = ETrue; + p->_isValid = true; + p->_isDirectory = true; p->_displayName = lastPathComponent(p->_path, '\\'); - } - else - { - p = new SymbianFilesystemNode(ETrue); + } else { + p = new SymbianFilesystemNode(true); } return p; } Common::SeekableReadStream *SymbianFilesystemNode::createReadStream() { - return SymbianStdioStream::makeFromPath(getPath().c_str(), false); + return SymbianStdioStream::makeFromPath(getPath(), false); } Common::WriteStream *SymbianFilesystemNode::createWriteStream() { - return SymbianStdioStream::makeFromPath(getPath().c_str(), true); + return SymbianStdioStream::makeFromPath(getPath(), true); } #endif //#if defined (__SYMBIAN32__) diff --git a/backends/fs/symbian/symbian-fs.h b/backends/fs/symbian/symbian-fs.h new file mode 100644 index 0000000000..9b0e80c3d6 --- /dev/null +++ b/backends/fs/symbian/symbian-fs.h @@ -0,0 +1,73 @@ +/* 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 SYMBIAN_FILESYSTEM_H +#define SYMBIAN_FILESYSTEM_H + +#include "backends/fs/abstract-fs.h" + +/** + * Implementation of the ScummVM file system API based on POSIX. + * + * Parts of this class are documented in the base interface class, AbstractFSNode. + */ +class SymbianFilesystemNode : public AbstractFSNode { +protected: + Common::String _displayName; + Common::String _path; + bool _isDirectory; + bool _isValid; + bool _isPseudoRoot; +public: + /** + * Creates a SymbianFilesystemNode with the root node as path. + * + * @param aIsRoot true if the node will be a pseudo root, false otherwise. + */ + SymbianFilesystemNode(bool aIsRoot); + + /** + * Creates a SymbianFilesystemNode for a given path. + * + * @param path Common::String with the path the new node should point to. + */ + SymbianFilesystemNode(const Common::String &path); + + virtual bool exists() const; + virtual Common::String getDisplayName() const { return _displayName; } + virtual Common::String getName() const { return _displayName; } + virtual Common::String getPath() const { return _path; } + virtual bool isDirectory() const { return _isDirectory; } + virtual bool isReadable() const; + virtual bool isWritable() const; + + virtual AbstractFSNode *getChild(const Common::String &n) const; + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; + virtual AbstractFSNode *getParent() const; + + virtual Common::SeekableReadStream *createReadStream(); + virtual Common::WriteStream *createWriteStream(); +}; + +#endif diff --git a/backends/fs/wii/wii-fs-factory.cpp b/backends/fs/wii/wii-fs-factory.cpp index 6a11d7d12e..6b35a43a21 100644 --- a/backends/fs/wii/wii-fs-factory.cpp +++ b/backends/fs/wii/wii-fs-factory.cpp @@ -25,7 +25,7 @@ #include <unistd.h> #include "backends/fs/wii/wii-fs-factory.h" -#include "backends/fs/wii/wii-fs.cpp" +#include "backends/fs/wii/wii-fs.h" #ifdef USE_WII_DI #include <di/di.h> diff --git a/backends/fs/wii/wii-fs.cpp b/backends/fs/wii/wii-fs.cpp index e6ba2a4aa0..d94463060c 100644 --- a/backends/fs/wii/wii-fs.cpp +++ b/backends/fs/wii/wii-fs.cpp @@ -22,7 +22,7 @@ #if defined(__WII__) -#include "backends/fs/abstract-fs.h" +#include "backends/fs/wii/wii-fs.h" #include "backends/fs/stdiostream.h" #include <sys/iosupport.h> @@ -34,52 +34,6 @@ #include <gctypes.h> -/** - * Implementation of the ScummVM file system API based on Wii. - * - * Parts of this class are documented in the base interface class, AbstractFSNode. - */ -class WiiFilesystemNode : public AbstractFSNode { -protected: - Common::String _displayName; - Common::String _path; - bool _exists, _isDirectory, _isReadable, _isWritable; - - virtual void initRootNode(); - virtual bool getDevopChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual void setFlags(const struct stat *st); - virtual void clearFlags(); - -public: - /** - * Creates a WiiFilesystemNode with the root node as path. - */ - WiiFilesystemNode(); - - /** - * Creates a WiiFilesystemNode for a given path. - * - * @param path Common::String with the path the new node should point to. - */ - WiiFilesystemNode(const Common::String &path); - WiiFilesystemNode(const Common::String &p, const struct stat *st); - - virtual bool exists() const; - virtual Common::String getDisplayName() const { return _displayName; } - virtual Common::String getName() const { return _displayName; } - virtual Common::String getPath() const { return _path; } - virtual bool isDirectory() const { return _isDirectory; } - virtual bool isReadable() const { return _isReadable; } - virtual bool isWritable() const { return _isWritable; } - - virtual AbstractFSNode *getChild(const Common::String &n) const; - virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFSNode *getParent() const; - - virtual Common::SeekableReadStream *createReadStream(); - virtual Common::WriteStream *createWriteStream(); -}; - // gets all registered devoptab devices bool WiiFilesystemNode::getDevopChildren(AbstractFSList &list, ListMode mode, bool hidden) const { u8 i; @@ -234,11 +188,11 @@ AbstractFSNode *WiiFilesystemNode::getParent() const { } Common::SeekableReadStream *WiiFilesystemNode::createReadStream() { - return StdioStream::makeFromPath(getPath().c_str(), false); + return StdioStream::makeFromPath(getPath(), false); } Common::WriteStream *WiiFilesystemNode::createWriteStream() { - return StdioStream::makeFromPath(getPath().c_str(), true); + return StdioStream::makeFromPath(getPath(), true); } #endif //#if defined(__WII__) diff --git a/backends/fs/wii/wii-fs.h b/backends/fs/wii/wii-fs.h new file mode 100644 index 0000000000..fd160624ca --- /dev/null +++ b/backends/fs/wii/wii-fs.h @@ -0,0 +1,76 @@ +/* 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 WII_FILESYSTEM_H +#define WII_FILESYSTEM_H + +#include "backends/fs/abstract-fs.h" + +/** + * Implementation of the ScummVM file system API based on Wii. + * + * Parts of this class are documented in the base interface class, AbstractFSNode. + */ +class WiiFilesystemNode : public AbstractFSNode { +protected: + Common::String _displayName; + Common::String _path; + bool _exists, _isDirectory, _isReadable, _isWritable; + + virtual void initRootNode(); + virtual bool getDevopChildren(AbstractFSList &list, ListMode mode, bool hidden) const; + virtual void setFlags(const struct stat *st); + virtual void clearFlags(); + +public: + /** + * Creates a WiiFilesystemNode with the root node as path. + */ + WiiFilesystemNode(); + + /** + * Creates a WiiFilesystemNode for a given path. + * + * @param path Common::String with the path the new node should point to. + */ + WiiFilesystemNode(const Common::String &path); + WiiFilesystemNode(const Common::String &p, const struct stat *st); + + virtual bool exists() const; + virtual Common::String getDisplayName() const { return _displayName; } + virtual Common::String getName() const { return _displayName; } + virtual Common::String getPath() const { return _path; } + virtual bool isDirectory() const { return _isDirectory; } + virtual bool isReadable() const { return _isReadable; } + virtual bool isWritable() const { return _isWritable; } + + virtual AbstractFSNode *getChild(const Common::String &n) const; + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; + virtual AbstractFSNode *getParent() const; + + virtual Common::SeekableReadStream *createReadStream(); + virtual Common::WriteStream *createWriteStream(); +}; + +#endif diff --git a/backends/fs/windows/windows-fs-factory.cpp b/backends/fs/windows/windows-fs-factory.cpp index ae9485a121..0b240bcbcf 100644 --- a/backends/fs/windows/windows-fs-factory.cpp +++ b/backends/fs/windows/windows-fs-factory.cpp @@ -22,13 +22,13 @@ * $Id$ */ +#if defined(WIN32) + // Disable symbol overrides so that we can use system headers. #define FORBIDDEN_SYMBOL_ALLOW_ALL -#if defined(WIN32) - #include "backends/fs/windows/windows-fs-factory.h" -#include "backends/fs/windows/windows-fs.cpp" +#include "backends/fs/windows/windows-fs.h" AbstractFSNode *WindowsFilesystemFactory::makeRootFileNode() const { return new WindowsFilesystemNode(); diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp index 00f72773c3..8345c9d7b4 100644 --- a/backends/fs/windows/windows-fs.cpp +++ b/backends/fs/windows/windows-fs.cpp @@ -22,23 +22,13 @@ * $Id$ */ -#ifdef WIN32 +#if defined(WIN32) -#if defined(ARRAYSIZE) -#undef ARRAYSIZE -#endif -#include <windows.h> -// winnt.h defines ARRAYSIZE, but we want our own one... -#undef ARRAYSIZE -#ifdef _WIN32_WCE -#undef GetCurrentDirectory -#endif -#include "backends/fs/abstract-fs.h" +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include "backends/fs/windows/windows-fs.h" #include "backends/fs/stdiostream.h" -#include <io.h> -#include <stdio.h> -#include <stdlib.h> -#include <tchar.h> // F_OK, R_OK and W_OK are not defined under MSVC, so we define them here // For more information on the modes used by MSVC, check: @@ -55,84 +45,17 @@ #define W_OK 2 #endif -/** - * Implementation of the ScummVM file system API based on Windows API. - * - * Parts of this class are documented in the base interface class, AbstractFSNode. - */ -class WindowsFilesystemNode : public AbstractFSNode { -protected: - Common::String _displayName; - Common::String _path; - bool _isDirectory; - bool _isPseudoRoot; - bool _isValid; - -public: - /** - * Creates a WindowsFilesystemNode with the root node as path. - * - * In regular windows systems, a virtual root path is used "". - * In windows CE, the "\" root is used instead. - */ - WindowsFilesystemNode(); - - /** - * Creates a WindowsFilesystemNode for a given path. - * - * Examples: - * path=c:\foo\bar.txt, currentDir=false -> c:\foo\bar.txt - * path=c:\foo\bar.txt, currentDir=true -> current directory - * path=NULL, currentDir=true -> current directory - * - * @param path Common::String with the path the new node should point to. - * @param currentDir if true, the path parameter will be ignored and the resulting node will point to the current directory. - */ - WindowsFilesystemNode(const Common::String &path, const bool currentDir); - - virtual bool exists() const { return _access(_path.c_str(), F_OK) == 0; } - virtual Common::String getDisplayName() const { return _displayName; } - virtual Common::String getName() const { return _displayName; } - virtual Common::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 AbstractFSNode *getChild(const Common::String &n) const; - virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFSNode *getParent() const; - - virtual Common::SeekableReadStream *createReadStream(); - virtual Common::WriteStream *createWriteStream(); - -private: - /** - * Adds a single WindowsFilesystemNode to a given list. - * This method is used by getChildren() to populate the directory entries list. - * - * @param list List to put the file entry node in. - * @param mode Mode to use while adding the file entry to the list. - * @param base Common::String with the directory being listed. - * @param find_data Describes a file that the FindFirstFile, FindFirstFileEx, or FindNextFile functions find. - */ - static void addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data); - - /** - * Converts a Unicode string to Ascii format. - * - * @param str Common::String to convert from Unicode to Ascii. - * @return str in Ascii format. - */ - static char *toAscii(TCHAR *str); - - /** - * Converts an Ascii string to Unicode format. - * - * @param str Common::String to convert from Ascii to Unicode. - * @return str in Unicode format. - */ - static const TCHAR* toUnicode(const char *str); -}; +bool WindowsFilesystemNode::exists() const { + return _access(_path.c_str(), F_OK) == 0; +} + +bool WindowsFilesystemNode::isReadable() const { + return _access(_path.c_str(), R_OK) == 0; +} + +bool WindowsFilesystemNode::isWritable() const { + return _access(_path.c_str(), W_OK) == 0; +} void WindowsFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data) { WindowsFilesystemNode entry; @@ -314,11 +237,11 @@ AbstractFSNode *WindowsFilesystemNode::getParent() const { } Common::SeekableReadStream *WindowsFilesystemNode::createReadStream() { - return StdioStream::makeFromPath(getPath().c_str(), false); + return StdioStream::makeFromPath(getPath(), false); } Common::WriteStream *WindowsFilesystemNode::createWriteStream() { - return StdioStream::makeFromPath(getPath().c_str(), true); + return StdioStream::makeFromPath(getPath(), true); } #endif //#ifdef WIN32 diff --git a/backends/fs/windows/windows-fs.h b/backends/fs/windows/windows-fs.h new file mode 100644 index 0000000000..8e4880ce23 --- /dev/null +++ b/backends/fs/windows/windows-fs.h @@ -0,0 +1,123 @@ +/* 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 WINDOWS_FILESYSTEM_H +#define WINDOWS_FILESYSTEM_H + +#include "backends/fs/abstract-fs.h" + +#if defined(ARRAYSIZE) +#undef ARRAYSIZE +#endif +#include <windows.h> +// winnt.h defines ARRAYSIZE, but we want our own one... +#undef ARRAYSIZE +#ifdef _WIN32_WCE +#undef GetCurrentDirectory +#endif +#include <io.h> +#include <stdio.h> +#include <stdlib.h> +#include <tchar.h> + +/** + * Implementation of the ScummVM file system API based on Windows API. + * + * Parts of this class are documented in the base interface class, AbstractFSNode. + */ +class WindowsFilesystemNode : public AbstractFSNode { +protected: + Common::String _displayName; + Common::String _path; + bool _isDirectory; + bool _isPseudoRoot; + bool _isValid; + +public: + /** + * Creates a WindowsFilesystemNode with the root node as path. + * + * In regular windows systems, a virtual root path is used "". + * In windows CE, the "\" root is used instead. + */ + WindowsFilesystemNode(); + + /** + * Creates a WindowsFilesystemNode for a given path. + * + * Examples: + * path=c:\foo\bar.txt, currentDir=false -> c:\foo\bar.txt + * path=c:\foo\bar.txt, currentDir=true -> current directory + * path=NULL, currentDir=true -> current directory + * + * @param path Common::String with the path the new node should point to. + * @param currentDir if true, the path parameter will be ignored and the resulting node will point to the current directory. + */ + WindowsFilesystemNode(const Common::String &path, const bool currentDir); + + virtual bool exists() const; + virtual Common::String getDisplayName() const { return _displayName; } + virtual Common::String getName() const { return _displayName; } + virtual Common::String getPath() const { return _path; } + virtual bool isDirectory() const { return _isDirectory; } + virtual bool isReadable() const; + virtual bool isWritable() const; + + virtual AbstractFSNode *getChild(const Common::String &n) const; + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; + virtual AbstractFSNode *getParent() const; + + virtual Common::SeekableReadStream *createReadStream(); + virtual Common::WriteStream *createWriteStream(); + +private: + /** + * Adds a single WindowsFilesystemNode to a given list. + * This method is used by getChildren() to populate the directory entries list. + * + * @param list List to put the file entry node in. + * @param mode Mode to use while adding the file entry to the list. + * @param base Common::String with the directory being listed. + * @param find_data Describes a file that the FindFirstFile, FindFirstFileEx, or FindNextFile functions find. + */ + static void addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data); + + /** + * Converts a Unicode string to Ascii format. + * + * @param str Common::String to convert from Unicode to Ascii. + * @return str in Ascii format. + */ + static char *toAscii(TCHAR *str); + + /** + * Converts an Ascii string to Unicode format. + * + * @param str Common::String to convert from Ascii to Unicode. + * @return str in Unicode format. + */ + static const TCHAR* toUnicode(const char *str); +}; + +#endif diff --git a/backends/module.mk b/backends/module.mk index cd0e2a56de..e4abf49ba8 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -18,9 +18,13 @@ MODULE_OBJS := \ events/wincesdl/wincesdl-events.o \ fs/abstract-fs.o \ fs/stdiostream.o \ + fs/amigaos4/amigaos4-fs.o \ fs/amigaos4/amigaos4-fs-factory.o \ + fs/posix/posix-fs.o \ fs/posix/posix-fs-factory.o \ + fs/symbian/symbian-fs.o \ fs/symbian/symbian-fs-factory.o \ + fs/windows/windows-fs.o \ fs/windows/windows-fs-factory.o \ graphics/dinguxsdl/dinguxsdl-graphics.o \ graphics/gp2xsdl/gp2xsdl-graphics.o \ @@ -77,25 +81,28 @@ MODULE_OBJS := \ ifeq ($(BACKEND),ds) MODULE_OBJS += \ - fs/ds/ds-fs-factory.o \ fs/ds/ds-fs.o \ + fs/ds/ds-fs-factory.o \ plugins/ds/ds-provider.o endif ifeq ($(BACKEND),n64) MODULE_OBJS += \ + fs/n64/n64-fs.o \ fs/n64/n64-fs-factory.o \ fs/n64/romfsstream.o endif ifeq ($(BACKEND),ps2) MODULE_OBJS += \ + fs/ps2/ps2-fs.o \ fs/ps2/ps2-fs-factory.o \ plugins/ps2/ps2-provider.o endif ifeq ($(BACKEND),psp) MODULE_OBJS += \ + fs/psp/psp-fs.o \ fs/psp/psp-fs-factory.o \ fs/psp/psp-stream.o \ plugins/psp/psp-provider.o \ @@ -105,6 +112,7 @@ endif ifeq ($(BACKEND),wii) MODULE_OBJS += \ + fs/wii/wii-fs.o \ fs/wii/wii-fs-factory.o \ plugins/wii/wii-provider.o endif diff --git a/backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in b/backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in index 8e644ae634..4e0a66793c 100644 --- a/backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in +++ b/backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in @@ -119,6 +119,7 @@ SOURCE backends\platform\sdl\hardwarekeys.cpp SOURCE backends\platform\sdl\sdl.cpp SOURCE backends\audiocd\sdl\sdl-audiocd.cpp SOURCE backends\audiocd\default\default-audiocd.cpp +SOURCE backends\fs\symbian\symbian-fs.cpp SOURCE backends\fs\symbian\symbian-fs-factory.cpp SOURCE backends\platform\symbian\src\SymbianOS.cpp SOURCE backends\platform\symbian\src\SymbianActions.cpp diff --git a/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in b/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in index f3c12c6b19..1929723fb6 100644 --- a/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in +++ b/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in @@ -119,6 +119,7 @@ SOURCE backends\platform\sdl\hardwarekeys.cpp SOURCE backends\platform\sdl\sdl.cpp SOURCE backends\audiocd\sdl\sdl-audiocd.cpp SOURCE backends\audiocd\default\default-audiocd.cpp +SOURCE backends\fs\symbian\symbian-fs.cpp SOURCE backends\fs\symbian\symbian-fs-factory.cpp SOURCE backends\platform\symbian\src\SymbianOS.cpp SOURCE backends\platform\symbian\src\SymbianActions.cpp diff --git a/backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in b/backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in index 5cf1b1bb11..f5bdaac237 100644 --- a/backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in +++ b/backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in @@ -117,6 +117,7 @@ SOURCE backends\platform\sdl\hardwarekeys.cpp SOURCE backends\platform\sdl\sdl.cpp SOURCE backends\audiocd\sdl\sdl-audiocd.cpp SOURCE backends\audiocd\default\default-audiocd.cpp +SOURCE backends\fs\symbian\symbian-fs.cpp SOURCE backends\fs\symbian\symbian-fs-factory.cpp SOURCE backends\platform\symbian\src\SymbianOS.cpp SOURCE backends\platform\symbian\src\SymbianActions.cpp diff --git a/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in b/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in index 44ec5aaf4a..2354161e47 100644 --- a/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in +++ b/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in @@ -117,6 +117,7 @@ SOURCE backends\platform\sdl\hardwarekeys.cpp SOURCE backends\platform\sdl\sdl.cpp SOURCE backends\audiocd\sdl\sdl-audiocd.cpp SOURCE backends\audiocd\default\default-audiocd.cpp +SOURCE backends\fs\symbian\symbian-fs.cpp SOURCE backends\fs\symbian\symbian-fs-factory.cpp SOURCE backends\platform\symbian\src\SymbianOS.cpp SOURCE backends\platform\symbian\src\SymbianActions.cpp |