[DEV] correct element of the archive manager used
This commit is contained in:
parent
fd6dc6e6cc
commit
f2edd2def6
10
etk/Hach.h
10
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;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -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<m_info.number_entry; iii++) {
|
||||
char tmpFileName[FILENAME_MAX];
|
||||
unz_file_info tmpFileInfo;
|
||||
/* Get info about current file. */
|
||||
if(unzGetCurrentFileInfo(m_ctx, &tmpFileInfo, tmpFileName, FILENAME_MAX, NULL, 0, NULL, 0) != UNZ_OK) {
|
||||
TK_ERROR("Could not read file info from the zip file '" << m_fileName << "'");
|
||||
return;
|
||||
}
|
||||
if (fileNameRequested == tmpFileName ) {
|
||||
// Entry is a file, so extract it.
|
||||
if(unzOpenCurrentFile(m_ctx) != UNZ_OK) {
|
||||
TK_ERROR("Could not open file '" << fileNameRequested << "' into the zip file '" << m_fileName << "'");
|
||||
return;
|
||||
}
|
||||
int error = UNZ_OK;
|
||||
// request the resize of the data :
|
||||
m_content.GetValue(_id).GetDataVector().ReSize(m_content.GetValue(_id).GetTheoricSize(), 0);
|
||||
void* data = m_content.GetValue(_id).Data();
|
||||
if(NULL == data) {
|
||||
TK_ERROR("Allocation error...");
|
||||
return;
|
||||
}
|
||||
/* read the file */
|
||||
do {
|
||||
error = unzReadCurrentFile(m_ctx, data, m_content.GetValue(_id).GetTheoricSize());
|
||||
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) {
|
||||
TK_ERROR("Could not read next file from the zip file '" << m_fileName << "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user