diff options
Diffstat (limited to 'backends/factories')
24 files changed, 726 insertions, 0 deletions
diff --git a/backends/factories/abstract-fs-factory.h b/backends/factories/abstract-fs-factory.h new file mode 100644 index 0000000000..b06ad63228 --- /dev/null +++ b/backends/factories/abstract-fs-factory.h @@ -0,0 +1,56 @@ +#ifndef ABSTRACT_FILESYSTEM_FACTORY_H +#define ABSTRACT_FILESYSTEM_FACTORY_H + +#include "common/str.h" +#include "backends/fs/abstract-fs.h" +#include "backends/file/base-file.h" + +/** + * Creates concrete FilesystemNode objects depending on the current architecture. + */ +class AbstractFilesystemFactory { +public: + typedef Common::String String; + + /** + * Destructor. + */ + virtual ~AbstractFilesystemFactory() {} + + /** + * Returns a node representing the "current directory". + * If your system does not support this concept, you can either try to + * emulate it or simply return some "sensible" default directory node, + * e.g. the same value as getRoot() returns. + */ + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const = 0; + + /** + * Construct a node based on a path; the path is in the same format as it + * would be for calls to fopen(). + * + * Furthermore getNodeForPath(oldNode.path()) should create a new node + * identical to oldNode. Hence, we can use the "path" value for persistent + * storage e.g. in the config file. + * + * @param path The path string to create a FilesystemNode for. + */ + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const = 0; + + /** + * Returns a special node representing the filesystem root. + * The starting point for any file system browsing. + * + * On Unix, this will be simply the node for / (the root directory). + * On Windows, it will be a special node which "contains" all drives (C:, D:, E:). + */ + virtual AbstractFilesystemNode *makeRootFileNode() const = 0; + + /** + * Creates a base file usable by the Common::File wrapper to implement several + * methods. + */ + virtual BaseFile *makeBaseFile() const = 0; +}; + +#endif /*ABSTRACT_FILESYSTEM_FACTORY_H*/ diff --git a/backends/factories/amigaos4/amigaos4-fs-factory.cpp b/backends/factories/amigaos4/amigaos4-fs-factory.cpp new file mode 100644 index 0000000000..2d73c4dbdc --- /dev/null +++ b/backends/factories/amigaos4/amigaos4-fs-factory.cpp @@ -0,0 +1,21 @@ +#include "backends/factories/amigaos4/amigaos4-fs-factory.h" +#include "backends/fs/amigaos4/amigaos4-fs.cpp" +#include "backends/file/amigaos4/amigaos4-file.h" + +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); +} + +BaseFile *AmigaOSFilesystemFactory::makeBaseFile() const { + return new AmigaOSFile(); +} diff --git a/backends/factories/amigaos4/amigaos4-fs-factory.h b/backends/factories/amigaos4/amigaos4-fs-factory.h new file mode 100644 index 0000000000..86f77ca6fa --- /dev/null +++ b/backends/factories/amigaos4/amigaos4-fs-factory.h @@ -0,0 +1,28 @@ +#ifndef AMIGAOS_FILESYSTEM_FACTORY_H +#define AMIGAOS_FILESYSTEM_FACTORY_H + +#include "common/singleton.h" +#include "backends/factories/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; + virtual BaseFile *makeBaseFile() const; + +protected: + AmigaOSFilesystemFactory() {}; + +private: + friend class Common::Singleton<SingletonBaseType>; +}; + +#endif /*AMIGAOS_FILESYSTEM_FACTORY_H*/ diff --git a/backends/factories/dc/ronincd-fs-factory.cpp b/backends/factories/dc/ronincd-fs-factory.cpp new file mode 100644 index 0000000000..c28d735aec --- /dev/null +++ b/backends/factories/dc/ronincd-fs-factory.cpp @@ -0,0 +1,21 @@ +#include "backends/factories/dc/ronincd-fs-factory.h" +#include "backends/fs/dc/dc-fs.cpp" +#include "backends/file/base-file.h" + +DECLARE_SINGLETON(RoninCDFilesystemFactory); + +AbstractFilesystemNode *RoninCDFilesystemFactory::makeRootFileNode() const { + return new RoninCDFilesystemNode(); +} + +AbstractFilesystemNode *RoninCDFilesystemFactory::makeCurrentDirectoryFileNode() const { + return new RoninCDFilesystemNode(); +} + +AbstractFilesystemNode *RoninCDFilesystemFactory::makeFileNodePath(const String &path) const { + return new RoninCDFilesystemNode(path, true); +} + +BaseFile *RoninCDFilesystemFactory::makeBaseFile() const { + return new BaseFile(); +} diff --git a/backends/factories/dc/ronincd-fs-factory.h b/backends/factories/dc/ronincd-fs-factory.h new file mode 100644 index 0000000000..5aa6f7a91f --- /dev/null +++ b/backends/factories/dc/ronincd-fs-factory.h @@ -0,0 +1,28 @@ +#ifndef RONINCD_FILESYSTEM_FACTORY_H +#define RONINCD_FILESYSTEM_FACTORY_H + +#include "common/singleton.h" +#include "backends/factories/abstract-fs-factory.h" + +/** + * Creates RoninCDFilesystemNode objects. + * + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. + */ +class RoninCDFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<RoninCDFilesystemFactory> { +public: + typedef Common::String String; + + virtual AbstractFilesystemNode *makeRootFileNode() const; + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; + +protected: + RoninCDFilesystemFactory() {}; + +private: + friend class Common::Singleton<SingletonBaseType>; +}; + +#endif /*RONINCD_FILESYSTEM_FACTORY_H*/ diff --git a/backends/factories/ds/ds-fs-factory.cpp b/backends/factories/ds/ds-fs-factory.cpp new file mode 100644 index 0000000000..94bf8e75d0 --- /dev/null +++ b/backends/factories/ds/ds-fs-factory.cpp @@ -0,0 +1,34 @@ +#include "backends/factories/ds/ds-fs-factory.h" +#include "backends/fs/ds/ds-fs.cpp" +#include "backends/file/ds/ds-file.h" +#include "dsmain.h" //for the isGBAMPAvailable() function + +DECLARE_SINGLETON(DSFilesystemFactory); + +AbstractFilesystemNode *DSFilesystemFactory::makeRootFileNode() const { + if (DS::isGBAMPAvailable()) { + return new DS::GBAMPFileSystemNode(); + } else { + return new DS::DSFileSystemNode(); + } +} + +AbstractFilesystemNode *DSFilesystemFactory::makeCurrentDirectoryFileNode() const { + if (DS::isGBAMPAvailable()) { + return new DS::GBAMPFileSystemNode(); + } else { + return new DS::DSFileSystemNode(); + } +} + +AbstractFilesystemNode *DSFilesystemFactory::makeFileNodePath(const String &path) const { + if (DS::isGBAMPAvailable()) { + return new DS::GBAMPFileSystemNode(path); + } else { + return new DS::DSFileSystemNode(path); + } +} + +BaseFile *DSFilesystemFactory::makeBaseFile() const { + return new DSFile(); +} diff --git a/backends/factories/ds/ds-fs-factory.h b/backends/factories/ds/ds-fs-factory.h new file mode 100644 index 0000000000..eecd406682 --- /dev/null +++ b/backends/factories/ds/ds-fs-factory.h @@ -0,0 +1,28 @@ +#ifndef DS_FILESYSTEM_FACTORY_H +#define DS_FILESYSTEM_FACTORY_H + +#include "common/singleton.h" +#include "backends/factories/abstract-fs-factory.h" + +/** + * Creates DSFilesystemNode objects. + * + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. + */ +class DSFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<DSFilesystemFactory> { +public: + typedef Common::String String; + + virtual AbstractFilesystemNode *makeRootFileNode() const; + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; + +protected: + DSFilesystemFactory() {}; + +private: + friend class Common::Singleton<SingletonBaseType>; +}; + +#endif /*DS_FILESYSTEM_FACTORY_H*/ diff --git a/backends/factories/fs-factory-maker.cpp b/backends/factories/fs-factory-maker.cpp new file mode 100644 index 0000000000..8bef982f37 --- /dev/null +++ b/backends/factories/fs-factory-maker.cpp @@ -0,0 +1,113 @@ +#include "backends/factories/abstract-fs-factory.h" + +/* + * All the following includes choose, at compile time, which specific backend will be used + * during the execution of the ScummVM. + * + * It has to be done this way because not all the necessary libraries will be available in + * all build environments. Additionally, this results in smaller binaries. + */ +#if defined(__amigaos4__) + #include "backends/factories/amigaos4/amigaos4-fs-factory.cpp" +#endif + +#if defined(__DC__) + #include "backends/factories/dc/ronincd-fs-factory.cpp" +#endif + +#if defined(__DS__) + #include "backends/factories/ds/ds-fs-factory.cpp" +#endif + +#if defined(__GP32__) + #include "backends/factories/gp32/gp32-fs-factory.cpp" +#endif + +#if defined(__MORPHOS__) + #include "backends/factories/morphos/abox-fs-factory.cpp" +#endif + +#if defined(PALMOS_MODE) + #include "backends/factories/palmos/palmos-fs-factory.cpp" +#endif + +#if defined(__PLAYSTATION2__) + #include "backends/factories/ps2/ps2-fs-factory.cpp" +#endif + +#if defined(__PSP__) + #include "backends/factories/psp/psp-fs-factory.cpp" +#endif + +#if defined(__SYMBIAN32__) + #include "backends/factories/symbian/symbian-fs-factory.cpp" +#endif + +#if defined(UNIX) + #include "backends/factories/posix/posix-fs-factory.cpp" +#endif + +#if defined(WIN32) + #include "backends/factories/windows/windows-fs-factory.cpp" +#endif + +/** + * Creates concrete FilesystemFactory and FileFactory objects depending on the current architecture. + */ +class FilesystemFactoryMaker { +public: + + /** + * Returns the correct concrete filesystem factory depending on the current build architecture. + */ + static AbstractFilesystemFactory *makeFactory(); + +protected: + FilesystemFactoryMaker() {}; // avoid instances of this class +}; + +AbstractFilesystemFactory *FilesystemFactoryMaker::makeFactory(){ + #if defined(__amigaos4__) + return &AmigaOSFilesystemFactory::instance(); + #endif + + #if defined(__DC__) + return &RoninCDFilesystemFactory::instance(); + #endif + + #if defined(__DS__) + return &DSFilesystemFactory::instance(); + #endif + + #if defined(__GP32__) + return &GP32FilesystemFactory::instance(); + #endif + + #if defined(__MORPHOS__) + return &ABoxFilesystemFactory::instance(); + #endif + + #if defined(PALMOS_MODE) + return &PalmOSFilesystemFactory::instance(); + #endif + + #if defined(__PLAYSTATION2__) + return &Ps2FilesystemFactory::instance(); + #endif + + #if defined(__PSP__) + return &PSPFilesystemFactory::instance(); + #endif + + #if defined(__SYMBIAN32__) + return &SymbianFilesystemFactory::instance(); + #endif + + #if defined(UNIX) + return &POSIXFilesystemFactory::instance(); + #endif + + #if defined(WIN32) + return &WindowsFilesystemFactory::instance(); + #endif +} diff --git a/backends/factories/gp32/gp32-fs-factory.cpp b/backends/factories/gp32/gp32-fs-factory.cpp new file mode 100644 index 0000000000..bffbffa21d --- /dev/null +++ b/backends/factories/gp32/gp32-fs-factory.cpp @@ -0,0 +1,21 @@ +#include "backends/factories/gp32/gp32-fs-factory.h" +#include "backends/fs/gp32/gp32-fs.cpp" +#include "backends/file/base-file.h" + +DECLARE_SINGLETON(GP32FilesystemFactory); + +AbstractFilesystemNode *GP32FilesystemFactory::makeRootFileNode() const { + return new GP32FilesystemNode(); +} + +AbstractFilesystemNode *GP32FilesystemFactory::makeCurrentDirectoryFileNode() const { + return new GP32FilesystemNode(); +} + +AbstractFilesystemNode *GP32FilesystemFactory::makeFileNodePath(const String &path) const { + return new GP32FilesystemNode(path); +} + +BaseFile *GP32FilesystemFactory::makeBaseFile() const { + return new BaseFile(); +} diff --git a/backends/factories/gp32/gp32-fs-factory.h b/backends/factories/gp32/gp32-fs-factory.h new file mode 100644 index 0000000000..b5e5df3b6b --- /dev/null +++ b/backends/factories/gp32/gp32-fs-factory.h @@ -0,0 +1,28 @@ +#ifndef GP32_FILESYSTEM_FACTORY_H +#define GP32_FILESYSTEM_FACTORY_H + +#include "common/singleton.h" +#include "backends/factories/abstract-fs-factory.h" + +/** + * Creates GP32FilesystemNode objects. + * + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. + */ +class GP32FilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<GP32FilesystemFactory> { +public: + typedef Common::String String; + + virtual AbstractFilesystemNode *makeRootFileNode() const; + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; + +protected: + GP32FilesystemFactory() {}; + +private: + friend class Common::Singleton<SingletonBaseType>; +}; + +#endif /*GP32_FILESYSTEM_FACTORY_H*/ diff --git a/backends/factories/morphos/abox-fs-factory.cpp b/backends/factories/morphos/abox-fs-factory.cpp new file mode 100644 index 0000000000..5659baf6f9 --- /dev/null +++ b/backends/factories/morphos/abox-fs-factory.cpp @@ -0,0 +1,21 @@ +#include "backends/factories/morphos/abox-fs-factory.h" +#include "backends/fs/morphos/abox-fs.cpp" +#include "backends/file/base-file.h" + +DECLARE_SINGLETON(ABoxFilesystemFactory); + +AbstractFilesystemNode *ABoxFilesystemFactory::makeRootFileNode() const { + return new ABoxFilesystemNode(); +} + +AbstractFilesystemNode *ABoxFilesystemFactory::makeCurrentDirectoryFileNode() const { + return new ABoxFilesystemNode(); +} + +AbstractFilesystemNode *ABoxFilesystemFactory::makeFileNodePath(const String &path) const { + return new ABoxFilesystemNode(path); +} + +BaseFile *ABoxFilesystemFactory::makeBaseFile() const { + return new BaseFile(); +} diff --git a/backends/factories/morphos/abox-fs-factory.h b/backends/factories/morphos/abox-fs-factory.h new file mode 100644 index 0000000000..ff282b5bb9 --- /dev/null +++ b/backends/factories/morphos/abox-fs-factory.h @@ -0,0 +1,28 @@ +#ifndef ABOX_FILESYSTEM_FACTORY_H +#define ABOX_FILESYSTEM_FACTORY_H + +#include "common/singleton.h" +#include "backends/factories/abstract-fs-factory.h" + +/** + * Creates ABoxFilesystemNode objects. + * + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. + */ +class ABoxFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<ABoxFilesystemFactory> { +public: + typedef Common::String String; + + virtual AbstractFilesystemNode *makeRootFileNode() const; + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; + +protected: + ABoxFilesystemFactory() {}; + +private: + friend class Common::Singleton<SingletonBaseType>; +}; + +#endif /*ABOX_FILESYSTEM_FACTORY_H*/ diff --git a/backends/factories/palmos/palmos-fs-factory.cpp b/backends/factories/palmos/palmos-fs-factory.cpp new file mode 100644 index 0000000000..275118b518 --- /dev/null +++ b/backends/factories/palmos/palmos-fs-factory.cpp @@ -0,0 +1,21 @@ +#include "backends/factories/palmos/palmos-fs-factory.h" +#include "backends/fs/palmos/palmos-fs.cpp" +#include "backends/file/base-file.h" + +DECLARE_SINGLETON(PalmOSFilesystemFactory); + +AbstractFilesystemNode *PalmOSFilesystemFactory::makeRootFileNode() const { + return new PalmOSFilesystemNode(); +} + +AbstractFilesystemNode *PalmOSFilesystemFactory::makeCurrentDirectoryFileNode() const { + return new PalmOSFilesystemNode(); +} + +AbstractFilesystemNode *PalmOSFilesystemFactory::makeFileNodePath(const String &path) const { + return new PalmOSFilesystemNode(path); +} + +BaseFile *PalmOSFilesystemFactory::makeBaseFile() const { + return new BaseFile(); +} diff --git a/backends/factories/palmos/palmos-fs-factory.h b/backends/factories/palmos/palmos-fs-factory.h new file mode 100644 index 0000000000..65af4e2fe6 --- /dev/null +++ b/backends/factories/palmos/palmos-fs-factory.h @@ -0,0 +1,28 @@ +#ifndef PALMOS_FILESYSTEM_FACTORY_H +#define PALMOS_FILESYSTEM_FACTORY_H + +#include "common/singleton.h" +#include "backends/factories/abstract-fs-factory.h" + +/** + * Creates PalmOSFilesystemNode objects. + * + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. + */ +class PalmOSFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<PalmOSFilesystemFactory> { +public: + typedef Common::String String; + + virtual AbstractFilesystemNode *makeRootFileNode() const; + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; + +protected: + PalmOSFilesystemFactory() {}; + +private: + friend class Common::Singleton<SingletonBaseType>; +}; + +#endif /*PALMOS_FILESYSTEM_FACTORY_H*/ diff --git a/backends/factories/posix/posix-fs-factory.cpp b/backends/factories/posix/posix-fs-factory.cpp new file mode 100644 index 0000000000..9b77e31557 --- /dev/null +++ b/backends/factories/posix/posix-fs-factory.cpp @@ -0,0 +1,24 @@ +#include "backends/factories/posix/posix-fs-factory.h" +#include "backends/fs/posix/posix-fs.cpp" +#include "backends/file/posix/posix-file.cpp" +//#include "backends/file/base-file.cpp" + +DECLARE_SINGLETON(POSIXFilesystemFactory); + +AbstractFilesystemNode *POSIXFilesystemFactory::makeRootFileNode() const { + return new POSIXFilesystemNode(); +} + +AbstractFilesystemNode *POSIXFilesystemFactory::makeCurrentDirectoryFileNode() const { + char buf[MAXPATHLEN]; + getcwd(buf, MAXPATHLEN); + return new POSIXFilesystemNode(buf, true); +} + +AbstractFilesystemNode *POSIXFilesystemFactory::makeFileNodePath(const String &path) const { + return new POSIXFilesystemNode(path, true); +} + +BaseFile *POSIXFilesystemFactory::makeBaseFile() const { + return new POSIXFile(); +} diff --git a/backends/factories/posix/posix-fs-factory.h b/backends/factories/posix/posix-fs-factory.h new file mode 100644 index 0000000000..aef411c92b --- /dev/null +++ b/backends/factories/posix/posix-fs-factory.h @@ -0,0 +1,28 @@ +#ifndef POSIX_FILESYSTEM_FACTORY_H +#define POSIX_FILESYSTEM_FACTORY_H + +#include "common/singleton.h" +#include "backends/factories/abstract-fs-factory.h" + +/** + * Creates POSIXFilesystemNode objects. + * + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. + */ +class POSIXFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<POSIXFilesystemFactory> { +public: + typedef Common::String String; + + virtual AbstractFilesystemNode *makeRootFileNode() const; + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; + +protected: + POSIXFilesystemFactory() {}; + +private: + friend class Common::Singleton<SingletonBaseType>; +}; + +#endif /*POSIX_FILESYSTEM_FACTORY_H*/ diff --git a/backends/factories/ps2/ps2-fs-factory.cpp b/backends/factories/ps2/ps2-fs-factory.cpp new file mode 100644 index 0000000000..cd6f293794 --- /dev/null +++ b/backends/factories/ps2/ps2-fs-factory.cpp @@ -0,0 +1,21 @@ +#include "backends/factories/ps2/ps2-fs-factory.h" +#include "backends/fs/ps2/ps2-fs.cpp" +#include "backends/file/ps2/ps2-file.h" + +DECLARE_SINGLETON(Ps2FilesystemFactory); + +AbstractFilesystemNode *Ps2FilesystemFactory::makeRootFileNode() const { + return new Ps2FilesystemNode(); +} + +AbstractFilesystemNode *Ps2FilesystemFactory::makeCurrentDirectoryFileNode() const { + return new Ps2FilesystemNode(); +} + +AbstractFilesystemNode *Ps2FilesystemFactory::makeFileNodePath(const String &path) const { + return new Ps2FilesystemNode(path); +} + +BaseFile *Ps2FilesystemFactory::makeBaseFile() const { + return new Ps2File(); +} diff --git a/backends/factories/ps2/ps2-fs-factory.h b/backends/factories/ps2/ps2-fs-factory.h new file mode 100644 index 0000000000..e1ddee9677 --- /dev/null +++ b/backends/factories/ps2/ps2-fs-factory.h @@ -0,0 +1,28 @@ +#ifndef PS2_FILESYSTEM_FACTORY_H +#define PS2_FILESYSTEM_FACTORY_H + +#include "common/singleton.h" +#include "backends/factories/abstract-fs-factory.h" + +/** + * Creates PS2FilesystemNode objects. + * + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. + */ +class Ps2FilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<Ps2FilesystemFactory> { +public: + typedef Common::String String; + + virtual AbstractFilesystemNode *makeRootFileNode() const; + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; + +protected: + Ps2FilesystemFactory() {}; + +private: + friend class Common::Singleton<SingletonBaseType>; +}; + +#endif /*PS2_FILESYSTEM_FACTORY_H*/ diff --git a/backends/factories/psp/psp-fs-factory.cpp b/backends/factories/psp/psp-fs-factory.cpp new file mode 100644 index 0000000000..9c9bef21e7 --- /dev/null +++ b/backends/factories/psp/psp-fs-factory.cpp @@ -0,0 +1,21 @@ +#include "backends/factories/psp/psp-fs-factory.h" +#include "backends/fs/psp/psp_fs.cpp" +#include "backends/file/base-file.h" + +DECLARE_SINGLETON(PSPFilesystemFactory); + +AbstractFilesystemNode *PSPFilesystemFactory::makeRootFileNode() const { + return new PSPFilesystemNode(); +} + +AbstractFilesystemNode *PSPFilesystemFactory::makeCurrentDirectoryFileNode() const { + return new PSPFilesystemNode(); +} + +AbstractFilesystemNode *PSPFilesystemFactory::makeFileNodePath(const String &path) const { + return new PSPFilesystemNode(path, true); +} + +BaseFile *PSPFilesystemFactory::makeBaseFile() const { + return new BaseFile(); +} diff --git a/backends/factories/psp/psp-fs-factory.h b/backends/factories/psp/psp-fs-factory.h new file mode 100644 index 0000000000..0d30efd5ad --- /dev/null +++ b/backends/factories/psp/psp-fs-factory.h @@ -0,0 +1,28 @@ +#ifndef PSP_FILESYSTEM_FACTORY_H +#define PSP_FILESYSTEM_FACTORY_H + +#include "common/singleton.h" +#include "backends/factories/abstract-fs-factory.h" + +/** + * Creates PSPFilesystemNode objects. + * + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. + */ +class PSPFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<PSPFilesystemFactory> { +public: + typedef Common::String String; + + virtual AbstractFilesystemNode *makeRootFileNode() const; + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; + +protected: + PSPFilesystemFactory() {}; + +private: + friend class Common::Singleton<SingletonBaseType>; +}; + +#endif /*PSP_FILESYSTEM_FACTORY_H*/ diff --git a/backends/factories/symbian/symbian-fs-factory.cpp b/backends/factories/symbian/symbian-fs-factory.cpp new file mode 100644 index 0000000000..a21b40a095 --- /dev/null +++ b/backends/factories/symbian/symbian-fs-factory.cpp @@ -0,0 +1,23 @@ +#include "backends/factories/symbian/symbian-fs-factory.h" +#include "backends/fs/symbian/symbian-fs.cpp" +#include "backends/file/symbian/symbian-file.h" + +DECLARE_SINGLETON(SymbianFilesystemFactory); + +AbstractFilesystemNode *SymbianFilesystemFactory::makeRootFileNode() const { + return new SymbianFilesystemNode(true); +} + +AbstractFilesystemNode *SymbianFilesystemFactory::makeCurrentDirectoryFileNode() const { + char path[MAXPATHLEN]; + getcwd(path, MAXPATHLEN); + return new SymbianFilesystemNode(path); +} + +AbstractFilesystemNode *SymbianFilesystemFactory::makeFileNodePath(const String &path) const { + return new SymbianFilesystemNode(path); +} + +BaseFile *SymbianFilesystemFactory::makeBaseFile() const { + return new SymbianFile(); +} diff --git a/backends/factories/symbian/symbian-fs-factory.h b/backends/factories/symbian/symbian-fs-factory.h new file mode 100644 index 0000000000..49f92410ce --- /dev/null +++ b/backends/factories/symbian/symbian-fs-factory.h @@ -0,0 +1,28 @@ +#ifndef SYMBIAN_FILESYSTEM_FACTORY_H +#define SYMBIAN_FILESYSTEM_FACTORY_H + +#include "common/singleton.h" +#include "backends/factories/abstract-fs-factory.h" + +/** + * Creates SymbianFilesystemNode objects. + * + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. + */ +class SymbianFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<SymbianFilesystemFactory> { +public: + typedef Common::String String; + + virtual AbstractFilesystemNode *makeRootFileNode() const; + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; + +protected: + SymbianFilesystemFactory() {}; + +private: + friend class Common::Singleton<SingletonBaseType>; +}; + +#endif /*SYMBIAN_FILESYSTEM_FACTORY_H*/ diff --git a/backends/factories/windows/windows-fs-factory.cpp b/backends/factories/windows/windows-fs-factory.cpp new file mode 100644 index 0000000000..55c48c3b9c --- /dev/null +++ b/backends/factories/windows/windows-fs-factory.cpp @@ -0,0 +1,21 @@ +#include "backends/factories/windows/windows-fs-factory.h" +#include "backends/fs/windows/windows-fs.cpp" +#include "backends/file/base-file.h" + +DECLARE_SINGLETON(WindowsFilesystemFactory); + +AbstractFilesystemNode *WindowsFilesystemFactory::makeRootFileNode() const { + return new WindowsFilesystemNode(); +} + +AbstractFilesystemNode *WindowsFilesystemFactory::makeCurrentDirectoryFileNode() const { + return new WindowsFilesystemNode("", true); +} + +AbstractFilesystemNode *WindowsFilesystemFactory::makeFileNodePath(const String &path) const { + return new WindowsFilesystemNode(path, false); +} + +BaseFile *WindowsFilesystemFactory::makeBaseFile() const { + return new BaseFile(); +} diff --git a/backends/factories/windows/windows-fs-factory.h b/backends/factories/windows/windows-fs-factory.h new file mode 100644 index 0000000000..1f85d8f1c3 --- /dev/null +++ b/backends/factories/windows/windows-fs-factory.h @@ -0,0 +1,28 @@ +#ifndef WINDOWS_FILESYSTEM_FACTORY_H +#define WINDOWS_FILESYSTEM_FACTORY_H + +#include "common/singleton.h" +#include "backends/factories/abstract-fs-factory.h" + +/** + * Creates WindowsFilesystemNode objects. + * + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. + */ +class WindowsFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<WindowsFilesystemFactory> { +public: + typedef Common::String String; + + virtual AbstractFilesystemNode *makeRootFileNode() const; + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; + +protected: + WindowsFilesystemFactory() {}; + +private: + friend class Common::Singleton<SingletonBaseType>; +}; + +#endif /*WINDOWS_FILESYSTEM_FACTORY_H*/ |