[DEV] update to Web build mode

This commit is contained in:
Edouard DUPIN 2016-11-04 22:54:25 +01:00
parent 8b16d5b1e0
commit 5bba60d195
4 changed files with 26 additions and 6 deletions

View File

@ -65,10 +65,10 @@ etk::Archive* etk::Archive::load(const std::string& _fileName) {
etk::Archive* output=nullptr;
std::string tmpName = etk::tolower(_fileName);
// select the corect Loader :
if( true == end_with(tmpName, ".zip")
|| true == end_with(tmpName, ".apk") ) {
if( end_with(tmpName, ".zip") == true
|| end_with(tmpName, ".apk") == true ) {
output = new etk::archive::Zip(_fileName);
if (nullptr==output) {
if (output == nullptr) {
TK_ERROR("An error occured when load archive : " << _fileName);
}
} else {

View File

@ -16,7 +16,7 @@ etk::archive::Zip::Zip(const std::string& _fileName, uint64_t _offset) :
/* Open the zip file */
m_ctx = unzOpenOffset(m_fileName.c_str(), _offset);
if(!m_ctx) {
TK_ERROR("Unable to open the zip file '" << m_fileName << "'");
TK_ERROR("Unable to open the zip file '" << m_fileName << "' offset=" << _offset);
return;
}
/* Get info about the zip file */
@ -30,13 +30,14 @@ etk::archive::Zip::Zip(const std::string& _fileName, uint64_t _offset) :
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) {
if(unzGetCurrentFileInfo(m_ctx, &tmpFileInfo, tmpFileName, FILENAME_MAX, nullptr, 0, nullptr, 0) != UNZ_OK) {
TK_ERROR("Could not read file info from the zip file '" << m_fileName << "'");
return;
}
if(tmpFileName[strlen(tmpFileName) - 1] == '/' ) {
// find directory ...
} else {
TK_INFO("find file : " << tmpFileName);
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. */

View File

@ -324,6 +324,14 @@ std::string etk::FSNodeGetApplicationName() {
TK_INFO("Loading Intarnal data '" << _apkPath << "'");
//s_APKArchive = etk::Archive::loadPackage(_apkPath);
s_APKArchive = etk::Archive::load(_apkPath);
/*
FILE* tmp = fopen(_apkPath.c_str(), "r");
if (tmp == nullptr) {
TK_ERROR("File does not exist ...");
} else {
TK_ERROR("File open OK ...");
}
*/
TK_ASSERT(s_APKArchive != nullptr, "Error loading PKG ... '" << _apkPath << "'");
#endif
#ifdef DEBUG
@ -389,7 +397,9 @@ void etk::setArgZero(const std::string& _val) {
l_argZero = _val;
// set defaiult application name ...
std::vector<std::string> elems = etk::split(_val, '/');
TK_WARNING("ppppppp" << elems);
etk::initDefaultFolder(elems[elems.size()-1].c_str());
TK_WARNING("ppppppp 222");
}
/*
On Unixes with /proc really straight and realiable way is to:
@ -513,7 +523,12 @@ void etk::initDefaultFolder(const char* _applName) {
}
}
TK_DBG_MODE("Find Basic running PATH : '" << baseRunPath << "'");
#ifndef __TARGET_OS__Android
#if defined(__TARGET_OS__Web)
loadAPK("data.zip");
baseFolderData = "zz_generic_zz";
#endif
#if !defined(__TARGET_OS__Android) \
&& !defined(__TARGET_OS__Web)
std::string binaryPath = getApplicationPath();
binaryPath = etk::replace(binaryPath, '\\', '/');
size_t pos = binaryPath.rfind('/');

View File

@ -25,6 +25,10 @@
#define HAVE_ZIP_DATA
#endif
#ifdef __TARGET_OS__Web
#define HAVE_ZIP_DATA
#endif
#ifdef HAVE_ZIP_DATA
namespace etk {