From f2edd2def61f19ec5db846a522fb056a9c7cee0c Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 24 Jul 2013 23:09:54 +0200 Subject: [PATCH] [DEV] correct element of the archive manager used --- etk/Hach.h | 10 +++++++ etk/archive/Zip.cpp | 72 ++++++++++++++++++++++++++++++--------------- etk/os/FSNode.cpp | 9 ++++-- 3 files changed, 65 insertions(+), 26 deletions(-) diff --git a/etk/Hach.h b/etk/Hach.h index 683ff07..47625e2 100644 --- a/etk/Hach.h +++ b/etk/Hach.h @@ -180,6 +180,16 @@ namespace etk #endif return m_data[_pos]->m_value; } + MY_TYPE& GetValue(esize_t _pos) + { + // NOTE :Do not change log level, this generate error only in debug mode + #if DEBUG_LEVEL > 2 + if(_pos>m_data.Size()){ + TK_CRITICAL("[CRITICAL] Access to an unexistant data in hach : " << _pos << "/ " << m_data.Size()); + } + #endif + return m_data[_pos]->m_value; + } }; }; diff --git a/etk/archive/Zip.cpp b/etk/archive/Zip.cpp index 775ef38..c8ce06b 100644 --- a/etk/archive/Zip.cpp +++ b/etk/archive/Zip.cpp @@ -37,31 +37,8 @@ etk::archive::Zip::Zip(const etk::UString& _fileName) : if(tmpFileName[strlen(tmpFileName) - 1] == '/' ) { // find directory ... } else { - // Entry is a file, so extract it. - if(unzOpenCurrentFile(m_ctx) != UNZ_OK) { - TK_ERROR("Could not open file '" << tmpFileName << "' into the zip file '" << m_fileName << "'"); - return; - } - int error = UNZ_OK; m_content.Add(tmpFileName, etk::Archive::Content(tmpFileInfo.uncompressed_size)); - // request the resize of the data : - m_content[tmpFileName].GetDataVector().ReSize(tmpFileInfo.uncompressed_size, 0); - void* data = m_content[tmpFileName].Data(); - if(NULL == data) { - TK_ERROR("Allocation error..."); - return; - } - /* read the file */ - do { - error = unzReadCurrentFile(m_ctx, data, tmpFileInfo.uncompressed_size); - if ( error < 0 ) { - TK_ERROR("Could not read file '" << tmpFileName << "' into the zip file '" << m_fileName << "': " << error); - unzCloseCurrentFile(m_ctx); - return; - } - } while ( error > 0 ); } - unzCloseCurrentFile(m_ctx); /* Go the the next entry listed in the zip file. */ if((iii+1) < m_info.number_entry) { if (unzGoToNextFile(m_ctx) != UNZ_OK) { @@ -82,5 +59,52 @@ etk::archive::Zip::~Zip(void) void etk::archive::Zip::LoadFile(int32_t _id) { - TK_WARNING("Load file Here ... : " << _id << " = '" << m_content.GetKey(_id) << "'"); + etk::UString fileNameRequested = m_content.GetKey(_id); + TK_WARNING("Load file Here ... : " << _id << " = '" << fileNameRequested << "'"); + + unzGoToFirstFile(m_ctx); + + // Store all the file in the standard structure + for(int32_t iii=0; iii 0 ); + } + unzCloseCurrentFile(m_ctx); + + /* Go the the next entry listed in the zip file. */ + if((iii+1) < m_info.number_entry) { + if (unzGoToNextFile(m_ctx) != UNZ_OK) { + TK_ERROR("Could not read next file from the zip file '" << m_fileName << "'"); + return; + } + } + } } diff --git a/etk/os/FSNode.cpp b/etk/os/FSNode.cpp index a7c09af..1032643 100644 --- a/etk/os/FSNode.cpp +++ b/etk/os/FSNode.cpp @@ -1334,7 +1334,7 @@ uint64_t etk::FSNode::FileSize(void) TK_ERROR("mlkmlkmlkmlkmlkmlk"); return 0; } - TK_INFO(" file size : " << (int64_t)statProperty.st_size << " bytes"); + TK_VERBOSE(" file size : " << (int64_t)statProperty.st_size << " bytes"); if ((uint64_t)statProperty.st_size<=0) { return 0; } @@ -1347,7 +1347,11 @@ bool etk::FSNode::FileOpenRead(void) #ifdef __TARGET_OS__Android if( etk::FSN_TYPE_DATA == m_type || etk::FSN_TYPE_THEME_DATA == m_type) { - return LoadDataZip(); + if (false==LoadDataZip()) { + return false; + } + s_APKArchive->Open(m_systemFileName); + return m_zipContent->GetTheoricSize() == m_zipContent->Size(); } #endif if (NULL != m_PointerFile) { @@ -1415,6 +1419,7 @@ bool etk::FSNode::FileClose(void) TK_CRITICAL("File Already closed : " << *this); return false; } + s_APKArchive->Close(m_systemFileName); m_zipContent = NULL; m_zipReadingOffset = 0; return true;