diff options
-rw-r--r-- | backends/factories/abstract-fs-factory.h (renamed from backends/fs/abstract-fs-factory.h) | 12 | ||||
-rw-r--r-- | backends/factories/amigaos4/amigaos4-fs-factory.cpp (renamed from backends/fs/amigaos4/amigaos4-fs-factory.cpp) | 7 | ||||
-rw-r--r-- | backends/factories/amigaos4/amigaos4-fs-factory.h (renamed from backends/fs/amigaos4/amigaos4-fs-factory.h) | 3 | ||||
-rw-r--r-- | backends/factories/dc/ronincd-fs-factory.cpp (renamed from backends/fs/dc/ronincd-fs-factory.cpp) | 7 | ||||
-rw-r--r-- | backends/factories/dc/ronincd-fs-factory.h (renamed from backends/fs/dc/ronincd-fs-factory.h) | 3 | ||||
-rw-r--r-- | backends/factories/ds/ds-fs-factory.cpp (renamed from backends/fs/ds/ds-fs-factory.cpp) | 7 | ||||
-rw-r--r-- | backends/factories/ds/ds-fs-factory.h (renamed from backends/fs/ds/ds-fs-factory.h) | 3 | ||||
-rw-r--r-- | backends/factories/fs-factory-maker.cpp (renamed from backends/fs/fs-factory-maker.cpp) | 28 | ||||
-rw-r--r-- | backends/factories/gp32/gp32-fs-factory.cpp (renamed from backends/fs/gp32/gp32-fs-factory.cpp) | 7 | ||||
-rw-r--r-- | backends/factories/gp32/gp32-fs-factory.h (renamed from backends/fs/gp32/gp32-fs-factory.h) | 3 | ||||
-rw-r--r-- | backends/factories/morphos/abox-fs-factory.cpp (renamed from backends/fs/morphos/abox-fs-factory.cpp) | 7 | ||||
-rw-r--r-- | backends/factories/morphos/abox-fs-factory.h (renamed from backends/fs/morphos/abox-fs-factory.h) | 3 | ||||
-rw-r--r-- | backends/factories/palmos/palmos-fs-factory.cpp (renamed from backends/fs/palmos/palmos-fs-factory.cpp) | 7 | ||||
-rw-r--r-- | backends/factories/palmos/palmos-fs-factory.h (renamed from backends/fs/palmos/palmos-fs-factory.h) | 3 | ||||
-rw-r--r-- | backends/factories/posix/posix-fs-factory.cpp (renamed from backends/fs/posix/posix-fs-factory.cpp) | 8 | ||||
-rw-r--r-- | backends/factories/posix/posix-fs-factory.h (renamed from backends/fs/posix/posix-fs-factory.h) | 3 | ||||
-rw-r--r-- | backends/factories/ps2/ps2-fs-factory.cpp (renamed from backends/fs/ps2/ps2-fs-factory.cpp) | 7 | ||||
-rw-r--r-- | backends/factories/ps2/ps2-fs-factory.h (renamed from backends/fs/ps2/ps2-fs-factory.h) | 3 | ||||
-rw-r--r-- | backends/factories/psp/psp-fs-factory.cpp (renamed from backends/fs/psp/psp-fs-factory.cpp) | 7 | ||||
-rw-r--r-- | backends/factories/psp/psp-fs-factory.h (renamed from backends/fs/psp/psp-fs-factory.h) | 3 | ||||
-rw-r--r-- | backends/factories/symbian/symbian-fs-factory.cpp (renamed from backends/fs/symbian/symbian-fs-factory.cpp) | 7 | ||||
-rw-r--r-- | backends/factories/symbian/symbian-fs-factory.h (renamed from backends/fs/symbian/symbian-fs-factory.h) | 3 | ||||
-rw-r--r-- | backends/factories/windows/windows-fs-factory.cpp (renamed from backends/fs/windows/windows-fs-factory.cpp) | 7 | ||||
-rw-r--r-- | backends/factories/windows/windows-fs-factory.h (renamed from backends/fs/windows/windows-fs-factory.h) | 3 | ||||
-rw-r--r-- | backends/file/base-file.cpp | 226 | ||||
-rw-r--r-- | backends/file/base-file.h | 180 | ||||
-rw-r--r-- | backends/file/ds/ds-file.cpp | 0 | ||||
-rw-r--r-- | backends/file/ds/ds-file.h | 46 | ||||
-rw-r--r-- | backends/file/posix/posix-file.cpp | 41 | ||||
-rw-r--r-- | backends/file/posix/posix-file.h | 50 | ||||
-rw-r--r-- | backends/file/ps2/ps2-file.cpp | 0 | ||||
-rw-r--r-- | backends/file/ps2/ps2-file.h | 24 | ||||
-rw-r--r-- | backends/file/symbian/symbian-file.cpp | 0 | ||||
-rw-r--r-- | backends/file/symbian/symbian-file.h | 29 | ||||
-rw-r--r-- | backends/fs/abstract-fs.h | 4 | ||||
-rw-r--r-- | common/file.h | 7 | ||||
-rw-r--r-- | common/fs.cpp | 2 |
37 files changed, 718 insertions, 42 deletions
diff --git a/backends/fs/abstract-fs-factory.h b/backends/factories/abstract-fs-factory.h index 41bfaaa34b..b06ad63228 100644 --- a/backends/fs/abstract-fs-factory.h +++ b/backends/factories/abstract-fs-factory.h @@ -2,6 +2,8 @@ #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. @@ -9,11 +11,11 @@ class AbstractFilesystemFactory { public: typedef Common::String String; - + /** * Destructor. */ - virtual ~AbstractFilesystemFactory() {}; + virtual ~AbstractFilesystemFactory() {} /** * Returns a node representing the "current directory". @@ -43,6 +45,12 @@ public: * 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/fs/amigaos4/amigaos4-fs-factory.cpp b/backends/factories/amigaos4/amigaos4-fs-factory.cpp index becbd49003..2d73c4dbdc 100644 --- a/backends/fs/amigaos4/amigaos4-fs-factory.cpp +++ b/backends/factories/amigaos4/amigaos4-fs-factory.cpp @@ -1,5 +1,6 @@ -#include "backends/fs/amigaos4/amigaos4-fs-factory.h" +#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); @@ -14,3 +15,7 @@ AbstractFilesystemNode *AmigaOSFilesystemFactory::makeCurrentDirectoryFileNode() AbstractFilesystemNode *AmigaOSFilesystemFactory::makeFileNodePath(const String &path) const { return new AmigaOSFilesystemNode(path); } + +BaseFile *AmigaOSFilesystemFactory::makeBaseFile() const { + return new AmigaOSFile(); +} diff --git a/backends/fs/amigaos4/amigaos4-fs-factory.h b/backends/factories/amigaos4/amigaos4-fs-factory.h index ed8af24648..86f77ca6fa 100644 --- a/backends/fs/amigaos4/amigaos4-fs-factory.h +++ b/backends/factories/amigaos4/amigaos4-fs-factory.h @@ -2,7 +2,7 @@ #define AMIGAOS_FILESYSTEM_FACTORY_H #include "common/singleton.h" -#include "backends/fs/abstract-fs-factory.h" +#include "backends/factories/abstract-fs-factory.h" /** * Creates AmigaOSFilesystemNode objects. @@ -16,6 +16,7 @@ public: virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; protected: AmigaOSFilesystemFactory() {}; diff --git a/backends/fs/dc/ronincd-fs-factory.cpp b/backends/factories/dc/ronincd-fs-factory.cpp index 0229a44c45..c28d735aec 100644 --- a/backends/fs/dc/ronincd-fs-factory.cpp +++ b/backends/factories/dc/ronincd-fs-factory.cpp @@ -1,5 +1,6 @@ -#include "backends/fs/dc/ronincd-fs-factory.h" +#include "backends/factories/dc/ronincd-fs-factory.h" #include "backends/fs/dc/dc-fs.cpp" +#include "backends/file/base-file.h" DECLARE_SINGLETON(RoninCDFilesystemFactory); @@ -14,3 +15,7 @@ AbstractFilesystemNode *RoninCDFilesystemFactory::makeCurrentDirectoryFileNode() AbstractFilesystemNode *RoninCDFilesystemFactory::makeFileNodePath(const String &path) const { return new RoninCDFilesystemNode(path, true); } + +BaseFile *RoninCDFilesystemFactory::makeBaseFile() const { + return new BaseFile(); +} diff --git a/backends/fs/dc/ronincd-fs-factory.h b/backends/factories/dc/ronincd-fs-factory.h index 426ef7ef2c..5aa6f7a91f 100644 --- a/backends/fs/dc/ronincd-fs-factory.h +++ b/backends/factories/dc/ronincd-fs-factory.h @@ -2,7 +2,7 @@ #define RONINCD_FILESYSTEM_FACTORY_H #include "common/singleton.h" -#include "backends/fs/abstract-fs-factory.h" +#include "backends/factories/abstract-fs-factory.h" /** * Creates RoninCDFilesystemNode objects. @@ -16,6 +16,7 @@ public: virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; protected: RoninCDFilesystemFactory() {}; diff --git a/backends/fs/ds/ds-fs-factory.cpp b/backends/factories/ds/ds-fs-factory.cpp index 7e64b37411..94bf8e75d0 100644 --- a/backends/fs/ds/ds-fs-factory.cpp +++ b/backends/factories/ds/ds-fs-factory.cpp @@ -1,5 +1,6 @@ -#include "backends/fs/ds/ds-fs-factory.h" +#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); @@ -27,3 +28,7 @@ AbstractFilesystemNode *DSFilesystemFactory::makeFileNodePath(const String &path return new DS::DSFileSystemNode(path); } } + +BaseFile *DSFilesystemFactory::makeBaseFile() const { + return new DSFile(); +} diff --git a/backends/fs/ds/ds-fs-factory.h b/backends/factories/ds/ds-fs-factory.h index a2e96aa548..eecd406682 100644 --- a/backends/fs/ds/ds-fs-factory.h +++ b/backends/factories/ds/ds-fs-factory.h @@ -2,7 +2,7 @@ #define DS_FILESYSTEM_FACTORY_H #include "common/singleton.h" -#include "backends/fs/abstract-fs-factory.h" +#include "backends/factories/abstract-fs-factory.h" /** * Creates DSFilesystemNode objects. @@ -16,6 +16,7 @@ public: virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; protected: DSFilesystemFactory() {}; diff --git a/backends/fs/fs-factory-maker.cpp b/backends/factories/fs-factory-maker.cpp index bae3d1a30a..8bef982f37 100644 --- a/backends/fs/fs-factory-maker.cpp +++ b/backends/factories/fs-factory-maker.cpp @@ -1,4 +1,4 @@ -#include "backends/fs/abstract-fs-factory.h" +#include "backends/factories/abstract-fs-factory.h" /* * All the following includes choose, at compile time, which specific backend will be used @@ -8,57 +8,57 @@ * all build environments. Additionally, this results in smaller binaries. */ #if defined(__amigaos4__) - #include "backends/fs/amigaos4/amigaos4-fs-factory.cpp" + #include "backends/factories/amigaos4/amigaos4-fs-factory.cpp" #endif #if defined(__DC__) - #include "backends/fs/dc/ronincd-fs-factory.cpp" + #include "backends/factories/dc/ronincd-fs-factory.cpp" #endif #if defined(__DS__) - #include "backends/fs/ds/ds-fs-factory.cpp" + #include "backends/factories/ds/ds-fs-factory.cpp" #endif #if defined(__GP32__) - #include "backends/fs/gp32/gp32-fs-factory.cpp" + #include "backends/factories/gp32/gp32-fs-factory.cpp" #endif #if defined(__MORPHOS__) - #include "backends/fs/morphos/abox-fs-factory.cpp" + #include "backends/factories/morphos/abox-fs-factory.cpp" #endif #if defined(PALMOS_MODE) - #include "backends/fs/palmos/palmos-fs-factory.cpp" + #include "backends/factories/palmos/palmos-fs-factory.cpp" #endif #if defined(__PLAYSTATION2__) - #include "backends/fs/ps2/ps2-fs-factory.cpp" + #include "backends/factories/ps2/ps2-fs-factory.cpp" #endif #if defined(__PSP__) - #include "backends/fs/psp/psp-fs-factory.cpp" + #include "backends/factories/psp/psp-fs-factory.cpp" #endif #if defined(__SYMBIAN32__) - #include "backends/fs/symbian/symbian-fs-factory.cpp" + #include "backends/factories/symbian/symbian-fs-factory.cpp" #endif #if defined(UNIX) - #include "backends/fs/posix/posix-fs-factory.cpp" + #include "backends/factories/posix/posix-fs-factory.cpp" #endif #if defined(WIN32) - #include "backends/fs/windows/windows-fs-factory.cpp" + #include "backends/factories/windows/windows-fs-factory.cpp" #endif /** - * Creates concrete FilesystemFactory objects depending on the current architecture. + * Creates concrete FilesystemFactory and FileFactory objects depending on the current architecture. */ class FilesystemFactoryMaker { public: /** - * Returns the correct concrete factory depending on the current build architecture. + * Returns the correct concrete filesystem factory depending on the current build architecture. */ static AbstractFilesystemFactory *makeFactory(); diff --git a/backends/fs/gp32/gp32-fs-factory.cpp b/backends/factories/gp32/gp32-fs-factory.cpp index 6328836c0e..bffbffa21d 100644 --- a/backends/fs/gp32/gp32-fs-factory.cpp +++ b/backends/factories/gp32/gp32-fs-factory.cpp @@ -1,5 +1,6 @@ -#include "backends/fs/gp32/gp32-fs-factory.h" +#include "backends/factories/gp32/gp32-fs-factory.h" #include "backends/fs/gp32/gp32-fs.cpp" +#include "backends/file/base-file.h" DECLARE_SINGLETON(GP32FilesystemFactory); @@ -14,3 +15,7 @@ AbstractFilesystemNode *GP32FilesystemFactory::makeCurrentDirectoryFileNode() co AbstractFilesystemNode *GP32FilesystemFactory::makeFileNodePath(const String &path) const { return new GP32FilesystemNode(path); } + +BaseFile *GP32FilesystemFactory::makeBaseFile() const { + return new BaseFile(); +} diff --git a/backends/fs/gp32/gp32-fs-factory.h b/backends/factories/gp32/gp32-fs-factory.h index fc15b52bc6..b5e5df3b6b 100644 --- a/backends/fs/gp32/gp32-fs-factory.h +++ b/backends/factories/gp32/gp32-fs-factory.h @@ -2,7 +2,7 @@ #define GP32_FILESYSTEM_FACTORY_H #include "common/singleton.h" -#include "backends/fs/abstract-fs-factory.h" +#include "backends/factories/abstract-fs-factory.h" /** * Creates GP32FilesystemNode objects. @@ -16,6 +16,7 @@ public: virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; protected: GP32FilesystemFactory() {}; diff --git a/backends/fs/morphos/abox-fs-factory.cpp b/backends/factories/morphos/abox-fs-factory.cpp index 9de810c361..5659baf6f9 100644 --- a/backends/fs/morphos/abox-fs-factory.cpp +++ b/backends/factories/morphos/abox-fs-factory.cpp @@ -1,5 +1,6 @@ -#include "backends/fs/morphos/abox-fs-factory.h" +#include "backends/factories/morphos/abox-fs-factory.h" #include "backends/fs/morphos/abox-fs.cpp" +#include "backends/file/base-file.h" DECLARE_SINGLETON(ABoxFilesystemFactory); @@ -14,3 +15,7 @@ AbstractFilesystemNode *ABoxFilesystemFactory::makeCurrentDirectoryFileNode() co AbstractFilesystemNode *ABoxFilesystemFactory::makeFileNodePath(const String &path) const { return new ABoxFilesystemNode(path); } + +BaseFile *ABoxFilesystemFactory::makeBaseFile() const { + return new BaseFile(); +} diff --git a/backends/fs/morphos/abox-fs-factory.h b/backends/factories/morphos/abox-fs-factory.h index 35f4472b8b..ff282b5bb9 100644 --- a/backends/fs/morphos/abox-fs-factory.h +++ b/backends/factories/morphos/abox-fs-factory.h @@ -2,7 +2,7 @@ #define ABOX_FILESYSTEM_FACTORY_H #include "common/singleton.h" -#include "backends/fs/abstract-fs-factory.h" +#include "backends/factories/abstract-fs-factory.h" /** * Creates ABoxFilesystemNode objects. @@ -16,6 +16,7 @@ public: virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; protected: ABoxFilesystemFactory() {}; diff --git a/backends/fs/palmos/palmos-fs-factory.cpp b/backends/factories/palmos/palmos-fs-factory.cpp index 1b0db0f042..275118b518 100644 --- a/backends/fs/palmos/palmos-fs-factory.cpp +++ b/backends/factories/palmos/palmos-fs-factory.cpp @@ -1,5 +1,6 @@ -#include "backends/fs/palmos/palmos-fs-factory.h" +#include "backends/factories/palmos/palmos-fs-factory.h" #include "backends/fs/palmos/palmos-fs.cpp" +#include "backends/file/base-file.h" DECLARE_SINGLETON(PalmOSFilesystemFactory); @@ -14,3 +15,7 @@ AbstractFilesystemNode *PalmOSFilesystemFactory::makeCurrentDirectoryFileNode() AbstractFilesystemNode *PalmOSFilesystemFactory::makeFileNodePath(const String &path) const { return new PalmOSFilesystemNode(path); } + +BaseFile *PalmOSFilesystemFactory::makeBaseFile() const { + return new BaseFile(); +} diff --git a/backends/fs/palmos/palmos-fs-factory.h b/backends/factories/palmos/palmos-fs-factory.h index cfe246e806..65af4e2fe6 100644 --- a/backends/fs/palmos/palmos-fs-factory.h +++ b/backends/factories/palmos/palmos-fs-factory.h @@ -2,7 +2,7 @@ #define PALMOS_FILESYSTEM_FACTORY_H #include "common/singleton.h" -#include "backends/fs/abstract-fs-factory.h" +#include "backends/factories/abstract-fs-factory.h" /** * Creates PalmOSFilesystemNode objects. @@ -16,6 +16,7 @@ public: virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; protected: PalmOSFilesystemFactory() {}; diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/factories/posix/posix-fs-factory.cpp index bed3dc5f8f..9b77e31557 100644 --- a/backends/fs/posix/posix-fs-factory.cpp +++ b/backends/factories/posix/posix-fs-factory.cpp @@ -1,5 +1,7 @@ -#include "backends/fs/posix/posix-fs-factory.h" +#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); @@ -16,3 +18,7 @@ AbstractFilesystemNode *POSIXFilesystemFactory::makeCurrentDirectoryFileNode() c AbstractFilesystemNode *POSIXFilesystemFactory::makeFileNodePath(const String &path) const { return new POSIXFilesystemNode(path, true); } + +BaseFile *POSIXFilesystemFactory::makeBaseFile() const { + return new POSIXFile(); +} diff --git a/backends/fs/posix/posix-fs-factory.h b/backends/factories/posix/posix-fs-factory.h index 93f0ac115b..aef411c92b 100644 --- a/backends/fs/posix/posix-fs-factory.h +++ b/backends/factories/posix/posix-fs-factory.h @@ -2,7 +2,7 @@ #define POSIX_FILESYSTEM_FACTORY_H #include "common/singleton.h" -#include "backends/fs/abstract-fs-factory.h" +#include "backends/factories/abstract-fs-factory.h" /** * Creates POSIXFilesystemNode objects. @@ -16,6 +16,7 @@ public: virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; protected: POSIXFilesystemFactory() {}; diff --git a/backends/fs/ps2/ps2-fs-factory.cpp b/backends/factories/ps2/ps2-fs-factory.cpp index 5f10974501..cd6f293794 100644 --- a/backends/fs/ps2/ps2-fs-factory.cpp +++ b/backends/factories/ps2/ps2-fs-factory.cpp @@ -1,5 +1,6 @@ -#include "backends/fs/ps2/ps2-fs-factory.h" +#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); @@ -14,3 +15,7 @@ AbstractFilesystemNode *Ps2FilesystemFactory::makeCurrentDirectoryFileNode() con AbstractFilesystemNode *Ps2FilesystemFactory::makeFileNodePath(const String &path) const { return new Ps2FilesystemNode(path); } + +BaseFile *Ps2FilesystemFactory::makeBaseFile() const { + return new Ps2File(); +} diff --git a/backends/fs/ps2/ps2-fs-factory.h b/backends/factories/ps2/ps2-fs-factory.h index 6f0da114c5..e1ddee9677 100644 --- a/backends/fs/ps2/ps2-fs-factory.h +++ b/backends/factories/ps2/ps2-fs-factory.h @@ -2,7 +2,7 @@ #define PS2_FILESYSTEM_FACTORY_H #include "common/singleton.h" -#include "backends/fs/abstract-fs-factory.h" +#include "backends/factories/abstract-fs-factory.h" /** * Creates PS2FilesystemNode objects. @@ -16,6 +16,7 @@ public: virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; protected: Ps2FilesystemFactory() {}; diff --git a/backends/fs/psp/psp-fs-factory.cpp b/backends/factories/psp/psp-fs-factory.cpp index 6fc829baf1..9c9bef21e7 100644 --- a/backends/fs/psp/psp-fs-factory.cpp +++ b/backends/factories/psp/psp-fs-factory.cpp @@ -1,5 +1,6 @@ -#include "backends/fs/psp/psp-fs-factory.h" +#include "backends/factories/psp/psp-fs-factory.h" #include "backends/fs/psp/psp_fs.cpp" +#include "backends/file/base-file.h" DECLARE_SINGLETON(PSPFilesystemFactory); @@ -14,3 +15,7 @@ AbstractFilesystemNode *PSPFilesystemFactory::makeCurrentDirectoryFileNode() con AbstractFilesystemNode *PSPFilesystemFactory::makeFileNodePath(const String &path) const { return new PSPFilesystemNode(path, true); } + +BaseFile *PSPFilesystemFactory::makeBaseFile() const { + return new BaseFile(); +} diff --git a/backends/fs/psp/psp-fs-factory.h b/backends/factories/psp/psp-fs-factory.h index b1a44b90c4..0d30efd5ad 100644 --- a/backends/fs/psp/psp-fs-factory.h +++ b/backends/factories/psp/psp-fs-factory.h @@ -2,7 +2,7 @@ #define PSP_FILESYSTEM_FACTORY_H #include "common/singleton.h" -#include "backends/fs/abstract-fs-factory.h" +#include "backends/factories/abstract-fs-factory.h" /** * Creates PSPFilesystemNode objects. @@ -16,6 +16,7 @@ public: virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; protected: PSPFilesystemFactory() {}; diff --git a/backends/fs/symbian/symbian-fs-factory.cpp b/backends/factories/symbian/symbian-fs-factory.cpp index 87b1f0f05d..a21b40a095 100644 --- a/backends/fs/symbian/symbian-fs-factory.cpp +++ b/backends/factories/symbian/symbian-fs-factory.cpp @@ -1,5 +1,6 @@ -#include "backends/fs/symbian/symbian-fs-factory.h" +#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); @@ -16,3 +17,7 @@ AbstractFilesystemNode *SymbianFilesystemFactory::makeCurrentDirectoryFileNode() AbstractFilesystemNode *SymbianFilesystemFactory::makeFileNodePath(const String &path) const { return new SymbianFilesystemNode(path); } + +BaseFile *SymbianFilesystemFactory::makeBaseFile() const { + return new SymbianFile(); +} diff --git a/backends/fs/symbian/symbian-fs-factory.h b/backends/factories/symbian/symbian-fs-factory.h index 69749cbd7e..49f92410ce 100644 --- a/backends/fs/symbian/symbian-fs-factory.h +++ b/backends/factories/symbian/symbian-fs-factory.h @@ -2,7 +2,7 @@ #define SYMBIAN_FILESYSTEM_FACTORY_H #include "common/singleton.h" -#include "backends/fs/abstract-fs-factory.h" +#include "backends/factories/abstract-fs-factory.h" /** * Creates SymbianFilesystemNode objects. @@ -16,6 +16,7 @@ public: virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; protected: SymbianFilesystemFactory() {}; diff --git a/backends/fs/windows/windows-fs-factory.cpp b/backends/factories/windows/windows-fs-factory.cpp index 3d7a3cc672..55c48c3b9c 100644 --- a/backends/fs/windows/windows-fs-factory.cpp +++ b/backends/factories/windows/windows-fs-factory.cpp @@ -1,5 +1,6 @@ -#include "backends/fs/windows/windows-fs-factory.h" +#include "backends/factories/windows/windows-fs-factory.h" #include "backends/fs/windows/windows-fs.cpp" +#include "backends/file/base-file.h" DECLARE_SINGLETON(WindowsFilesystemFactory); @@ -14,3 +15,7 @@ AbstractFilesystemNode *WindowsFilesystemFactory::makeCurrentDirectoryFileNode() AbstractFilesystemNode *WindowsFilesystemFactory::makeFileNodePath(const String &path) const { return new WindowsFilesystemNode(path, false); } + +BaseFile *WindowsFilesystemFactory::makeBaseFile() const { + return new BaseFile(); +} diff --git a/backends/fs/windows/windows-fs-factory.h b/backends/factories/windows/windows-fs-factory.h index 7d17802b52..1f85d8f1c3 100644 --- a/backends/fs/windows/windows-fs-factory.h +++ b/backends/factories/windows/windows-fs-factory.h @@ -2,7 +2,7 @@ #define WINDOWS_FILESYSTEM_FACTORY_H #include "common/singleton.h" -#include "backends/fs/abstract-fs-factory.h" +#include "backends/factories/abstract-fs-factory.h" /** * Creates WindowsFilesystemNode objects. @@ -16,6 +16,7 @@ public: virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; + virtual BaseFile *makeBaseFile() const; protected: WindowsFilesystemFactory() {}; diff --git a/backends/file/base-file.cpp b/backends/file/base-file.cpp new file mode 100644 index 0000000000..3174f5828c --- /dev/null +++ b/backends/file/base-file.cpp @@ -0,0 +1,226 @@ +/* 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: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/gsoc2007-fsnode/common/file.cpp $ + * $Id: file.cpp 28150 2007-07-20 19:42:38Z david_corrales $ + * + */ + +#include "backends/file/base-file.h" +#include "common/fs.h" +#include "common/hashmap.h" +#include "common/util.h" +#include "common/hash-str.h" + +#if defined(UNIX) || defined(__SYMBIAN32__) +#include <errno.h> +#endif + +#ifdef MACOSX +#include "CoreFoundation/CoreFoundation.h" +#endif + +BaseFile::BaseFile() { + _handle = 0; + _ioFailed = false; +} + +//#define DEBUG_FILE_REFCOUNT + +BaseFile::~BaseFile() { +#ifdef DEBUG_FILE_REFCOUNT + warning("File::~File on file '%s'", _name.c_str()); +#endif + close(); +} + +bool BaseFile::open(const String &filename, AccessMode mode) { + assert(mode == kFileReadMode || mode == kFileWriteMode); + + if (filename.empty()) { + error("File::open: No filename was specified"); + } + + if (_handle) { + error("File::open: This file object already is opened (%s), won't open '%s'", _name.c_str(), filename.c_str()); + } + + _name.clear(); + clearIOFailed(); + + const char *modeStr = (mode == kFileReadMode) ? "rb" : "wb"; + _handle = _fopen(filename.c_str(), modeStr); + + if (_handle == NULL) { + if (mode == kFileReadMode) + debug(2, "File %s not found", filename.c_str()); + else + debug(2, "File %s not opened", filename.c_str()); + return false; + } + + _name = filename; + +#ifdef DEBUG_FILE_REFCOUNT + warning("File::open on file '%s'", _name.c_str()); +#endif + + return true; +} + +bool BaseFile::remove(const String &filename){ + if (remove(filename.c_str()) != 0) { + if(errno == EACCES) + ;//TODO: read-only file + if(errno == ENOENT) + ;//TODO: non-existent file + + return false; + } else { + return true; + } +} + +void BaseFile::close() { + if (_handle) + _fclose((FILE *)_handle); + _handle = NULL; +} + +bool BaseFile::isOpen() const { + return _handle != NULL; +} + +bool BaseFile::ioFailed() const { + return _ioFailed != 0; +} + +void BaseFile::clearIOFailed() { + _ioFailed = false; +} + +bool BaseFile::eof() const { + if (_handle == NULL) { + error("File::eof: File is not open!"); + return false; + } + + return _feof((FILE *)_handle) != 0; +} + +uint32 BaseFile::pos() const { + if (_handle == NULL) { + error("File::pos: File is not open!"); + return 0; + } + + return _ftell((FILE *)_handle); +} + +uint32 BaseFile::size() const { + if (_handle == NULL) { + error("File::size: File is not open!"); + return 0; + } + + uint32 oldPos = _ftell((FILE *)_handle); + _fseek((FILE *)_handle, 0, SEEK_END); + uint32 length = _ftell((FILE *)_handle); + _fseek((FILE *)_handle, oldPos, SEEK_SET); + + return length; +} + +void BaseFile::seek(int32 offs, int whence) { + if (_handle == NULL) { + error("File::seek: File is not open!"); + return; + } + + if (_fseek((FILE *)_handle, offs, whence) != 0) + _clearerr((FILE *)_handle); +} + +uint32 BaseFile::read(void *ptr, uint32 len) { + byte *ptr2 = (byte *)ptr; + uint32 real_len; + + if (_handle == NULL) { + error("File::read: File is not open!"); + return 0; + } + + if (len == 0) + return 0; + + real_len = _fread(ptr2, 1, len, (FILE *)_handle); + if (real_len < len) { + _ioFailed = true; + } + + return real_len; +} + +/*uint32 File::write(const void *ptr, uint32 len) { + if (_handle == NULL) { + error("File::write: File is not open!"); + return 0; + } + + if (len == 0) + return 0; + + if ((uint32)_fwrite(ptr, 1, len, (FILE *)_handle) != len) { + _ioFailed = true; + } + + return len; +}*/ + +void BaseFile::_clearerr(FILE *stream) { + clearerr(stream); +} + +int BaseFile::_fclose(FILE *stream) { + return fclose(stream); +} + +int BaseFile::_feof(FILE *stream) const { + return feof(stream); +} +FILE *BaseFile::_fopen(const char * filename, const char * mode) { + return fopen(filename, mode); +} + +int BaseFile::_fread(void *buffer, size_t obj_size, size_t num, FILE *stream) { + return fread(buffer, obj_size, num, stream); +} + +int BaseFile::_fseek(FILE * stream, long int offset, int origin) const { + return fseek(stream, offset, origin); +} + +long BaseFile::_ftell(FILE *stream) const { + return ftell(stream); +} + +int BaseFile::_fwrite(const void * ptr, size_t obj_size, size_t count, FILE * stream) { + return fwrite(ptr, obj_size, count, stream); +} diff --git a/backends/file/base-file.h b/backends/file/base-file.h new file mode 100644 index 0000000000..f383a1a453 --- /dev/null +++ b/backends/file/base-file.h @@ -0,0 +1,180 @@ +/* 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 BACKENDS_BASE_FILE_H +#define BACKENDS_BASE_FILE_H + +#include "common/stdafx.h" +#include "common/scummsys.h" +#include "common/str.h" +#include "common/stream.h" + +using namespace Common; + +/** + * Implements several file related functions used by the Common::File wrapper. + */ +class BaseFile : public Common::SeekableReadStream { +protected: + /** File handle to the actual file; 0 if no file is open. */ + void *_handle; + + /** Status flag which tells about recent I/O failures. */ + bool _ioFailed; + + /** The name of this file, for debugging. */ + String _name; + + /** + * The following functions are meant to be redefined by subclasses if needed. E.g. ps2-file.h or ds-file.h + * They behave as the C++ standard I/O methods so refer to the standard documentation for usage. + * + * This design was inspired on the Template pattern. + */ + void _clearerr(FILE *stream); + int _fclose(FILE *stream); + int _feof(FILE *stream) const; + FILE *_fopen(const char * filename, const char * mode); + int _fread(void *buffer, size_t obj_size, size_t num, FILE *stream); + int _fseek(FILE * stream, long int offset, int origin) const; + long _ftell(FILE *stream) const; + int _fwrite(const void * ptr, size_t obj_size, size_t count, FILE * stream); + +private: + // Disallow copying BaseFile objects. There is not strict reason for this, + // except that so far we never had real need for such a feature, and + // code that accidentally copied File objects tended to break in strange + // ways. + BaseFile(const BaseFile &f); + BaseFile &operator =(const BaseFile &f); + +public: + enum AccessMode { + kFileReadMode = 1, + kFileWriteMode = 2 + }; + + BaseFile(); + virtual ~BaseFile(); + + /** + * Clears the flag for the last ocurred IO failure. + */ + void clearIOFailed(); + + /** + * Closes the file handle. + */ + virtual void close(); + + /** + * Checks for end of file. + * + * @return: true if the end of file is reached, false otherwise. + */ + bool eof() const; + + /** + * Checks for the end of the stream. In this case it's equivalent to eof(). + * + * @return: true if the end of the stream is reached, false otherwise. + */ + bool eos() const { return eof(); } + + /** + * Checks whether the last IO operation failed. + * + * @return: true if the last IO operation failed, false otherwise. + */ + bool ioFailed() const; + + /** + * Obtain the filename of the opened file. + * + * @return: the filename of the opened file. + */ + const char *name() const { return _name.c_str(); } + + /** + * Checks if the object opened a file successfully. + * + * @return: true if any file is opened, false otherwise. + */ + bool isOpen() const; + + /** + * Opens a given file. + * + * @param filename Path of the file to be opened. + * @param mode Mode to open to file. Read or write. + */ + virtual bool open(const String &filename, AccessMode mode = kFileReadMode); + + /** + * Obtain the position of the seek pointer. + * + * @return The position of the seek pointer within the file. + */ + uint32 pos() const; + + /** + * Read a chunk of data from the file. + * + * @param dataPtr Buffer to the place the read contents. + * @param dataSize Amount of bytes to read from the file. + * @return Amount of read bytes. + */ + uint32 read(void *dataPtr, uint32 dataSize); + + /** + * Remove a given file from the filesystem. + * + * @param filename Path to the file to be removed. + * @return true if the file was removed succesfully, false otherwise. + */ + virtual bool remove(const String &filename); + + /** + * Move the seek pointer within the file. + * + * @param offs Amount of bytes to move the pointer within the file. + * @param whence Starting point of the seek cursor. + */ + void seek(int32 offs, int whence = SEEK_SET); + + /** + * Obtain the size of the file. + * + * @return The size of the file in bytes. + */ + uint32 size() const; + + //TODO: Remove the write functions? Also remove the enum then + /** + * Write a chunk of data to the file. + */ + //uint32 write(const void *dataPtr, uint32 dataSize); +}; + +#endif //BACKENDS_BASE_FILE_H diff --git a/backends/file/ds/ds-file.cpp b/backends/file/ds/ds-file.cpp new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/backends/file/ds/ds-file.cpp diff --git a/backends/file/ds/ds-file.h b/backends/file/ds/ds-file.h new file mode 100644 index 0000000000..e133def548 --- /dev/null +++ b/backends/file/ds/ds-file.h @@ -0,0 +1,46 @@ +#ifdef __DS__ + + // These functions replease the standard library functions of the same name. + // As this header is included after the standard one, I have the chance to #define + // all of these to my own code. + // + // A #define is the only way, as redefinig the functions would cause linker errors. + + // These functions need to be #undef'ed, as their original definition + // in devkitarm is done with #includes (ugh!) + #undef feof + #undef clearerr + //#undef getc + //#undef ferror + + + //void std_fprintf(FILE* handle, const char* fmt, ...); // used in common/util.cpp + //void std_fflush(FILE* handle); // used in common/util.cpp + + //char* std_fgets(char* str, int size, FILE* file); // not used + //int std_getc(FILE* handle); // not used + //char* std_getcwd(char* dir, int dunno); // not used + //void std_cwd(char* dir); // not used + //int std_ferror(FILE* handle); // not used + + // Only functions used in the ScummVM source have been defined here! + #define fopen(name, mode) DS::std_fopen(name, mode) + #define fclose(handle) DS::std_fclose(handle) + #define fread(ptr, size, items, file) DS::std_fread(ptr, size, items, file) + #define fwrite(ptr, size, items, file) DS::std_fwrite(ptr, size, items, file) + #define feof(handle) DS::std_feof(handle) + #define ftell(handle) DS::std_ftell(handle) + #define fseek(handle, offset, whence) DS::std_fseek(handle, offset, whence) + #define clearerr(handle) DS::std_clearerr(handle) + + //#define printf(fmt, ...) consolePrintf(fmt, ##__VA_ARGS__) + + //#define fprintf(file, fmt, ...) { char str[128]; sprintf(str, fmt, ##__VA_ARGS__); DS::std_fwrite(str, strlen(str), 1, file); } + //#define fflush(file) DS::std_fflush(file) // used in common/util.cpp + + //#define fgets(str, size, file) DS::std_fgets(str, size, file) // not used + //#define getc(handle) DS::std_getc(handle) // not used + //#define getcwd(dir, dunno) DS::std_getcwd(dir, dunno) // not used + //#define ferror(handle) DS::std_ferror(handle) // not used + +#endif
\ No newline at end of file diff --git a/backends/file/posix/posix-file.cpp b/backends/file/posix/posix-file.cpp new file mode 100644 index 0000000000..84c82fa5c5 --- /dev/null +++ b/backends/file/posix/posix-file.cpp @@ -0,0 +1,41 @@ +#include "backends/file/posix/posix-file.h" + +POSIXFile::POSIXFile() : BaseFile() { + // +} + +POSIXFile::~POSIXFile() { + close(); +} + +void POSIXFile::_clearerr(FILE *stream) { + clearerr(stream); +} + +int POSIXFile::_fclose(FILE *stream) { + return fclose(stream); +} + +int POSIXFile::_feof(FILE *stream) const { + return feof(stream); +} +FILE *POSIXFile::_fopen(const char * filename, const char * mode) { + printf("Opened a file!\n"); + return fopen(filename, mode); +} + +int POSIXFile::_fread(void *buffer, size_t obj_size, size_t num, FILE *stream) { + return fread(buffer, obj_size, num, stream); +} + +int POSIXFile::_fseek(FILE * stream, long int offset, int origin) const { + return fseek(stream, offset, origin); +} + +long POSIXFile::_ftell(FILE *stream) const { + return ftell(stream); +} + +int POSIXFile::_fwrite(const void * ptr, size_t obj_size, size_t count, FILE * stream) { + return fwrite(ptr, obj_size, count, stream); +} diff --git a/backends/file/posix/posix-file.h b/backends/file/posix/posix-file.h new file mode 100644 index 0000000000..00ce307df5 --- /dev/null +++ b/backends/file/posix/posix-file.h @@ -0,0 +1,50 @@ +/* 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 BACKENDS_POSIX_FILE_H +#define BACKENDS_POSIX_FILE_H + +#include "backends/file/base-file.cpp" + +/** + * Implements several POSIX specific file related functions used by the Common::File wrapper. + * + * Parts of this class are documented in the base file class, BaseFile. + */ +class POSIXFile : public BaseFile { +public: + POSIXFile(); + ~POSIXFile(); +protected: + void _clearerr(FILE *stream); + int _fclose(FILE *stream); + int _feof(FILE *stream) const; + FILE *_fopen(const char * filename, const char * mode); + int _fread(void *buffer, size_t obj_size, size_t num, FILE *stream); + int _fseek(FILE * stream, long int offset, int origin) const; + long _ftell(FILE *stream) const; + int _fwrite(const void * ptr, size_t obj_size, size_t count, FILE * stream); +}; + +#endif //BACKENDS_POSIX_FILE_H diff --git a/backends/file/ps2/ps2-file.cpp b/backends/file/ps2/ps2-file.cpp new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/backends/file/ps2/ps2-file.cpp diff --git a/backends/file/ps2/ps2-file.h b/backends/file/ps2/ps2-file.h new file mode 100644 index 0000000000..e7acfd801f --- /dev/null +++ b/backends/file/ps2/ps2-file.h @@ -0,0 +1,24 @@ +#ifdef __PLAYSTATION2__ + // for those replaced fopen/fread/etc functions + typedef unsigned long uint64; + typedef signed long int64; + #include "backends/platform/ps2/fileio.h" + + #define fopen(a, b) ps2_fopen(a, b) + #define fclose(a) ps2_fclose(a) + #define fseek(a, b, c) ps2_fseek(a, b, c) + #define ftell(a) ps2_ftell(a) + #define feof(a) ps2_feof(a) + #define fread(a, b, c, d) ps2_fread(a, b, c, d) + #define fwrite(a, b, c, d) ps2_fwrite(a, b, c, d) + + //#define fprintf ps2_fprintf // used in common/util.cpp + //#define fflush(a) ps2_fflush(a) // used in common/util.cpp + + //#define fgetc(a) ps2_fgetc(a) // not used + //#define fgets(a, b, c) ps2_fgets(a, b, c) // not used + //#define fputc(a, b) ps2_fputc(a, b) // not used + //#define fputs(a, b) ps2_fputs(a, b) // not used + + //#define fsize(a) ps2_fsize(a) // not used -- and it is not a standard function either +#endif
\ No newline at end of file diff --git a/backends/file/symbian/symbian-file.cpp b/backends/file/symbian/symbian-file.cpp new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/backends/file/symbian/symbian-file.cpp diff --git a/backends/file/symbian/symbian-file.h b/backends/file/symbian/symbian-file.h new file mode 100644 index 0000000000..7807a9355a --- /dev/null +++ b/backends/file/symbian/symbian-file.h @@ -0,0 +1,29 @@ +#ifdef __SYMBIAN32__ + #undef feof + #undef clearerr + + #define FILE void + + FILE* symbian_fopen(const char* name, const char* mode); + void symbian_fclose(FILE* handle); + size_t symbian_fread(const void* ptr, size_t size, size_t numItems, FILE* handle); + size_t symbian_fwrite(const void* ptr, size_t size, size_t numItems, FILE* handle); + bool symbian_feof(FILE* handle); + long int symbian_ftell(FILE* handle); + int symbian_fseek(FILE* handle, long int offset, int whence); + void symbian_clearerr(FILE* handle); + + // Only functions used in the ScummVM source have been defined here! + #define fopen(name, mode) symbian_fopen(name, mode) + #define fclose(handle) symbian_fclose(handle) + #define fread(ptr, size, items, file) symbian_fread(ptr, size, items, file) + #define fwrite(ptr, size, items, file) symbian_fwrite(ptr, size, items, file) + #define feof(handle) symbian_feof(handle) + #define ftell(handle) symbian_ftell(handle) + #define fseek(handle, offset, whence) symbian_fseek(handle, offset, whence) + #define clearerr(handle) symbian_clearerr(handle) +#endif + +#if defined(UNIX) || defined(__SYMBIAN32__) +#include <errno.h> +#endif
\ No newline at end of file diff --git a/backends/fs/abstract-fs.h b/backends/fs/abstract-fs.h index 371c38a495..85fcbcdebb 100644 --- a/backends/fs/abstract-fs.h +++ b/backends/fs/abstract-fs.h @@ -46,7 +46,7 @@ protected: friend class FilesystemNode; typedef Common::String String; typedef FilesystemNode::ListMode ListMode; - + /** * Returns the child node with the given name. If no child with this name * exists, returns 0. When called on a non-directory node, it should @@ -77,7 +77,7 @@ public: * Destructor. */ virtual ~AbstractFilesystemNode() {} - + /* * Indicates whether the object refered by this path exists in the filesystem or not. */ diff --git a/common/file.h b/common/file.h index 4d519be475..d2eae1f28c 100644 --- a/common/file.h +++ b/common/file.h @@ -30,6 +30,8 @@ #include "common/scummsys.h" #include "common/str.h" #include "common/stream.h" +#include "backends/file/base-file.h" +//#include "backends/factories/fs-factory-maker.cpp" class FilesystemNode; @@ -38,6 +40,9 @@ namespace Common { class File : public SeekableReadStream, public WriteStream { protected: /** File handle to the actual file; 0 if no file is open. */ + //BaseFile *_test; + + /** File handle to the actual file; 0 if no file is open. */ void *_handle; /** Status flag which tells about recent I/O failures. */ @@ -52,7 +57,7 @@ private: // code that accidentally copied File objects tended to break in strange // ways. File(const File &f); - File &operator =(const File &f); + File &operator =(const File &f); public: enum AccessMode { diff --git a/common/fs.cpp b/common/fs.cpp index 28f3e11f0b..40d9e4de14 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -25,7 +25,7 @@ #include "common/stdafx.h" #include "common/util.h" #include "backends/fs/abstract-fs.h" -#include "backends/fs/fs-factory-maker.cpp" +#include "backends/factories/fs-factory-maker.cpp" /* * Simple DOS-style pattern matching function (understands * and ? like used in DOS). |