From 37ecf6bc0a516809e954545307c8a2015bdb8296 Mon Sep 17 00:00:00 2001 From: Chris Apers Date: Tue, 11 Apr 2006 18:25:04 +0000 Subject: Bad hack to make the file class work agaain with PalmOS ARM version - read the comment for more details svn-id: r21806 --- common/file.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'common') diff --git a/common/file.cpp b/common/file.cpp index a2a9e5b3c1..30ed40935e 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -37,9 +37,20 @@ typedef HashMap StringIntMap; // The following two objects could be turned into static members of class // File. However, then we would be forced to #include hashmap in file.h // which seems to be a high price just for a simple beautification... +#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG)) static StringIntMap _defaultDirectories; static FilesMap _filesMap; +#else +// This is a very bad hack to make these global objects work with PalmOS ARM version. +// In fact global objects are correctly allocated but constructors/destructors are not called +// and so, the object is not correctly initialized. See also the 2 functions at end of file. +// This is related to how ARM apps are handled in PalmOS, there is no problem with 68k version. +static StringIntMap *__defaultDirectories; +static FilesMap *__filesMap; +#define _defaultDirectories (*__defaultDirectories) +#define _filesMap (*__filesMap) +#endif static FILE *fopenNoCase(const char *filename, const char *directory, const char *mode) { FILE *file; @@ -359,3 +370,14 @@ uint32 File::write(const void *ptr, uint32 len) { } } // End of namespace Common + +#if defined(PALMOS_ARM) || defined(PALMOS_DEBUG) +void initGlobalHashes() { + Common::__defaultDirectories = new Common::StringIntMap; + Common::__filesMap = new Common::FilesMap; +} +void freeGlobalHashes() { + delete Common::__defaultDirectories; + delete Common::__filesMap; +} +#endif -- cgit v1.2.3