[DEV] correct the interface of acess of android zip file interface
This commit is contained in:
parent
e9583aa311
commit
d98a438428
@ -11,7 +11,7 @@
|
||||
#include <etk/archive/Zip.h>
|
||||
#include <etk/debug.h>
|
||||
|
||||
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;
|
||||
|
@ -15,9 +15,7 @@
|
||||
#include <map>
|
||||
|
||||
namespace etk {
|
||||
class Archive {
|
||||
public:
|
||||
class Content {
|
||||
class ArchiveContent {
|
||||
private:
|
||||
int32_t m_link; //!< number of element open on this file
|
||||
public:
|
||||
@ -39,7 +37,7 @@ namespace etk {
|
||||
private:
|
||||
std::vector<char> m_data;
|
||||
public:
|
||||
Content(int32_t _basicSize=0) :
|
||||
ArchiveContent(int32_t _basicSize=0) :
|
||||
m_link(-1),
|
||||
m_theoricSize(_basicSize) { };
|
||||
int32_t size() const {
|
||||
@ -52,6 +50,7 @@ namespace etk {
|
||||
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<std::string, Content> m_content;
|
||||
std::map<std::string, ArchiveContent> 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<std::string, Content>::iterator& it) { };
|
||||
virtual void loadFile(const std::map<std::string, ArchiveContent>::iterator& it) { };
|
||||
public:
|
||||
/**
|
||||
* @brief Load an Achive with a specific name.
|
||||
|
@ -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<std::string, etk::Archive::Content>(tmpFileName, etk::Archive::Content(tmpFileInfo.uncompressed_size)));
|
||||
m_content.insert(std::pair<std::string, etk::ArchiveContent>(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<std::string, Content>::iterator& it) {
|
||||
void etk::archive::Zip::loadFile(const std::map<std::string, ArchiveContent>::iterator& it) {
|
||||
TK_VERBOSE("Real load file : '" << it->first << "'");
|
||||
|
||||
unzGoToFirstFile(m_ctx);
|
||||
|
@ -24,7 +24,7 @@
|
||||
Zip(const std::string& _fileName);
|
||||
virtual ~Zip();
|
||||
protected: // herited functions :
|
||||
virtual void loadFile(const std::map<std::string, Content>::iterator& it);
|
||||
virtual void loadFile(const std::map<std::string, ArchiveContent>::iterator& it);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -25,6 +25,10 @@ extern "C" {
|
||||
#include <errno.h>
|
||||
}
|
||||
|
||||
#ifdef __TARGET_OS__Android
|
||||
# include <etk/archive/Archive.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __TARGET_OS__Windows
|
||||
// For ctime
|
||||
|
@ -13,14 +13,15 @@
|
||||
|
||||
#include <etk/os/FSNodeRight.h>
|
||||
|
||||
#ifdef __TARGET_OS__Android
|
||||
# include <etk/archive/Archive.h>
|
||||
#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:
|
||||
|
@ -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":
|
||||
|
Loading…
Reference in New Issue
Block a user