From d98a43842833085c5bf96b29b9b3189bb83a09f6 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 21 Apr 2015 22:58:06 +0200 Subject: [PATCH] [DEV] correct the interface of acess of android zip file interface --- etk/archive/Archive.cpp | 6 ++-- etk/archive/Archive.h | 77 ++++++++++++++++++++--------------------- etk/archive/Zip.cpp | 4 +-- etk/archive/Zip.h | 2 +- etk/os/FSNode.cpp | 4 +++ etk/os/FSNode.h | 11 +++--- lutin_etk.py | 3 +- 7 files changed, 56 insertions(+), 51 deletions(-) diff --git a/etk/archive/Archive.cpp b/etk/archive/Archive.cpp index 182e141..c3f82eb 100644 --- a/etk/archive/Archive.cpp +++ b/etk/archive/Archive.cpp @@ -11,7 +11,7 @@ #include #include -static const etk::Archive::Content g_error; +static const etk::ArchiveContent g_error; const std::string& etk::Archive::getName(size_t _id) const { @@ -26,7 +26,7 @@ const std::string& etk::Archive::getName(size_t _id) const { return error; } -const etk::Archive::Content& etk::Archive::getContent(size_t _id) const { +const etk::ArchiveContent& etk::Archive::getContent(size_t _id) const { size_t id = 0; for (auto &it : m_content) { if (id == _id) { @@ -37,7 +37,7 @@ const etk::Archive::Content& etk::Archive::getContent(size_t _id) const { return g_error; } -const etk::Archive::Content& etk::Archive::getContent(const std::string& _key) const { +const etk::ArchiveContent& etk::Archive::getContent(const std::string& _key) const { auto it = m_content.find(_key); if (it == m_content.end()) { return g_error; diff --git a/etk/archive/Archive.h b/etk/archive/Archive.h index dd30da7..527e256 100644 --- a/etk/archive/Archive.h +++ b/etk/archive/Archive.h @@ -15,43 +15,42 @@ #include namespace etk { - class Archive { + class ArchiveContent { + private: + int32_t m_link; //!< number of element open on this file public: - class Content { - private: - int32_t m_link; //!< number of element open on this file - public: - void increaseRef() { - m_link++; - }; - void decreaseRef() { - m_link--; - }; - int32_t getNumberOfRef() const { - return m_link; - }; - private: - int32_t m_theoricSize; //!< number of element open on this file - public: - int32_t getTheoricSize() const { - return m_theoricSize; - }; - private: - std::vector m_data; - public: - Content(int32_t _basicSize=0) : - m_link(-1), - m_theoricSize(_basicSize) { }; - int32_t size() const { - return m_data.size(); - }; - void* data() const { - return (void*)&m_data[0]; - }; - std::vector& getDataVector() { - return m_data; - }; + void increaseRef() { + m_link++; }; + void decreaseRef() { + m_link--; + }; + int32_t getNumberOfRef() const { + return m_link; + }; + private: + int32_t m_theoricSize; //!< number of element open on this file + public: + int32_t getTheoricSize() const { + return m_theoricSize; + }; + private: + std::vector m_data; + public: + ArchiveContent(int32_t _basicSize=0) : + m_link(-1), + m_theoricSize(_basicSize) { }; + int32_t size() const { + return m_data.size(); + }; + void* data() const { + return (void*)&m_data[0]; + }; + std::vector& getDataVector() { + return m_data; + }; + }; + class Archive { public: Archive(const std::string& _fileName) : m_fileName(_fileName) { @@ -69,7 +68,7 @@ namespace etk { return m_fileName; }; protected: - std::map m_content; + std::map m_content; public: /** * @brief Get the number of elements @@ -89,13 +88,13 @@ namespace etk { * @param[in] _id id of the element (must be < Size()) * @return the archive content */ - const Content& getContent(size_t _id) const; + const ArchiveContent& getContent(size_t _id) const; /** * @brief Get the File name of the ID * @param[in] _key name of the file * @return FileName of the requested id */ - const Content& getContent(const std::string& _key) const; + const ArchiveContent& getContent(const std::string& _key) const; /** * @brief Check if a file exist * @param[in] _key Name of the file @@ -121,7 +120,7 @@ namespace etk { * @brief Request the load in memory of the concerned file. * @param[in] _id Id of the file to load. */ - virtual void loadFile(const std::map::iterator& it) { }; + virtual void loadFile(const std::map::iterator& it) { }; public: /** * @brief Load an Achive with a specific name. diff --git a/etk/archive/Zip.cpp b/etk/archive/Zip.cpp index a2e54b0..87cb9e9 100644 --- a/etk/archive/Zip.cpp +++ b/etk/archive/Zip.cpp @@ -38,7 +38,7 @@ etk::archive::Zip::Zip(const std::string& _fileName) : if(tmpFileName[strlen(tmpFileName) - 1] == '/' ) { // find directory ... } else { - m_content.insert(std::pair(tmpFileName, etk::Archive::Content(tmpFileInfo.uncompressed_size))); + m_content.insert(std::pair(tmpFileName, etk::ArchiveContent(tmpFileInfo.uncompressed_size))); } /* Go the the next entry listed in the zip file. */ if((iii+1) < m_info.number_entry) { @@ -57,7 +57,7 @@ etk::archive::Zip::~Zip() { }; } -void etk::archive::Zip::loadFile(const std::map::iterator& it) { +void etk::archive::Zip::loadFile(const std::map::iterator& it) { TK_VERBOSE("Real load file : '" << it->first << "'"); unzGoToFirstFile(m_ctx); diff --git a/etk/archive/Zip.h b/etk/archive/Zip.h index b24559c..7df53c1 100644 --- a/etk/archive/Zip.h +++ b/etk/archive/Zip.h @@ -24,7 +24,7 @@ Zip(const std::string& _fileName); virtual ~Zip(); protected: // herited functions : - virtual void loadFile(const std::map::iterator& it); + virtual void loadFile(const std::map::iterator& it); }; }; }; diff --git a/etk/os/FSNode.cpp b/etk/os/FSNode.cpp index a7a23ed..71b078a 100644 --- a/etk/os/FSNode.cpp +++ b/etk/os/FSNode.cpp @@ -25,6 +25,10 @@ extern "C" { #include } +#ifdef __TARGET_OS__Android +# include +#endif + #ifdef __TARGET_OS__Windows // For ctime diff --git a/etk/os/FSNode.h b/etk/os/FSNode.h index 9921731..35e680a 100644 --- a/etk/os/FSNode.h +++ b/etk/os/FSNode.h @@ -13,14 +13,15 @@ #include -#ifdef __TARGET_OS__Android -# include -#endif - #define MAX_FILE_NAME (10240) //http://developer.android.com/guide/topics/data/data-storage.html +#ifdef __TARGET_OS__Android +namespace etk { + class ArchiveContent; +} +#endif namespace etk { void setArgZero(const std::string& _val); std::string simplifyPath(std::string _input); @@ -174,7 +175,7 @@ namespace etk { * @return false : An error Occured */ bool loadDataZip(); - const etk::Archive::Content* m_zipContent; + const etk::ArchiveContent* m_zipContent; int32_t m_zipReadingOffset; #endif public: diff --git a/lutin_etk.py b/lutin_etk.py index 8160d90..6883d77 100644 --- a/lutin_etk.py +++ b/lutin_etk.py @@ -45,6 +45,7 @@ def create(target): if target.name != "Windows": myModule.add_export_flag_LD("-ldl -rdynamic") + # for ald C++ compatibility (old GCC) just link with boost ... if target.config["compilator"] == "gcc" \ and target.xx_version < 4007000: # note : this framework depend on C++ 11, but a simple port of Boost for old compatibility has been done ... @@ -54,8 +55,8 @@ def create(target): else: myModule.compile_version_XX(2011) # name of the dependency - myModule.add_optionnal_module_depend('linearmath', "ETK_BUILD_LINEARMATH", export=True) myModule.add_optionnal_module_depend('minizip', "ETK_BUILD_MINIZIP") + myModule.add_optionnal_module_depend('linearmath', "ETK_BUILD_LINEARMATH", export=True) myModule.add_export_path(tools.get_current_path(__file__) + "/binding_X11") if target.name=="Windows":