[DEV] some file acces corection when apk file loading

This commit is contained in:
Edouard DUPIN 2013-07-25 21:50:53 +02:00
parent f2edd2def6
commit b9a79c1dfc
10 changed files with 415 additions and 400 deletions

View File

@ -15,21 +15,21 @@
#define FUNCTION_NAME_SIZE (70)
void TOOLS_DisplayFuncName(int32_t ligne, const char* className, const char* funcName, const char* libName)
void TOOLS_DisplayFuncName(int32_t _ligne, const char* _className, const char* _funcName, const char* _libName)
{
char tmpName[FUNCTION_NAME_SIZE] = "";
if (NULL == className) {
if (NULL == libName) {
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "???????? | (l=%5d) %s ",ligne, funcName);
if (NULL == _className) {
if (NULL == _libName) {
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "???????? | (l=%5d) %s ",_ligne, _funcName);
} else {
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "%s | (l=%5d) %s ",libName, ligne, funcName);
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "%s | (l=%5d) %s ",_libName, _ligne, _funcName);
}
} else {
if (NULL == libName) {
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "???????? | (l=%5d) %s::%s ",ligne, className, funcName);
if (NULL == _libName) {
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "???????? | (l=%5d) %s::%s ",_ligne, _className, _funcName);
} else {
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "%s | (l=%5d) %s::%s ", libName, ligne, className, funcName);
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "%s | (l=%5d) %s::%s ", _libName, _ligne, _className, _funcName);
}
}
tmpName[FUNCTION_NAME_SIZE-4] = ' ';
@ -45,13 +45,13 @@ void TOOLS_DisplayTime(void)
#ifdef __TARGET_OS__Android
struct timeval now;
gettimeofday(&now, NULL);
sprintf(tmpdata, " %2dh %2dmin %2ds | ", (int32_t)(now.tv_sec/3600)%24, (int32_t)(now.tv_sec/60)%60, (int32_t)(now.tv_sec%60));
sprintf(tmpdata, " %2dh%2d'%2d | ", (int32_t)(now.tv_sec/3600)%24, (int32_t)(now.tv_sec/60)%60, (int32_t)(now.tv_sec%60));
#else
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
sprintf(tmpdata, " %2dh %2dmin %2ds | ", (timeinfo->tm_hour)%24, timeinfo->tm_min, timeinfo->tm_sec);
sprintf(tmpdata, " %2dh%2d'%2d | ", (timeinfo->tm_hour)%24, timeinfo->tm_min, timeinfo->tm_sec);
#endif
etk::cout << tmpdata ;
}
@ -62,7 +62,7 @@ etk::logLevel_te g_requestedLevel = etk::LOG_LEVEL_VERBOSE;
#else
etk::logLevel_te g_requestedLevel = etk::LOG_LEVEL_ERROR;
#endif
void GeneralDebugSetLevel(etk::logLevel_te ccc) {
g_requestedLevel = ccc;
void GeneralDebugSetLevel(etk::logLevel_te _ccc) {
g_requestedLevel = _ccc;
}

View File

@ -13,7 +13,7 @@
#include <etk/Stream.h>
// Log Message System For EDN
void TOOLS_DisplayFuncName(int32_t ligne, const char* className, const char* funcName, const char* libName);
void TOOLS_DisplayFuncName(int32_t _ligne, const char* _className, const char* _funcName, const char* _libName);
void TOOLS_DisplayTime(void);
@ -21,7 +21,7 @@ void TOOLS_DisplayTime(void);
#define __class__ (NULL)
extern etk::logLevel_te g_requestedLevel;
void GeneralDebugSetLevel(etk::logLevel_te ccc);
void GeneralDebugSetLevel(etk::logLevel_te _ccc);
#define ETK_DBG_COMMON(libName, info, data) do { \
if (info <= g_requestedLevel) { \

View File

@ -59,69 +59,77 @@ etk::CStart etk::cstart;
# include <android/log.h>
#endif
etk::CCout& etk::operator <<(etk::CCout &os, const etk::logLevel_te obj)
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::logLevel_te _obj)
{
switch (obj)
switch (_obj)
{
case LOG_LEVEL_CRITICAL:
#if !defined(__TARGET_OS__Windows)
os << ETK_BASH_COLOR_BOLD_RED;
_os << ETK_BASH_COLOR_BOLD_RED;
#endif
#if defined(__TARGET_OS__Android)
os.m_levelAndroid = ANDROID_LOG_FATAL;
_os.m_levelAndroid = ANDROID_LOG_FATAL;
#else
_os << "[C]";
#endif
os << "[C]";
break;
case LOG_LEVEL_ERROR:
#if !defined(__TARGET_OS__Windows)
os << ETK_BASH_COLOR_RED;
_os << ETK_BASH_COLOR_RED;
#endif
#if defined(__TARGET_OS__Android)
os.m_levelAndroid = ANDROID_LOG_ERROR;
_os.m_levelAndroid = ANDROID_LOG_ERROR;
#else
_os << "[E]";
#endif
os << "[E]";
break;
case LOG_LEVEL_WARNING:
#if !defined(__TARGET_OS__Windows)
os << ETK_BASH_COLOR_MAGENTA;
_os << ETK_BASH_COLOR_MAGENTA;
#endif
#if defined(__TARGET_OS__Android)
os.m_levelAndroid = ANDROID_LOG_WARN;
_os.m_levelAndroid = ANDROID_LOG_WARN;
#else
_os << "[W]";
#endif
os << "[W]";
break;
case LOG_LEVEL_INFO:
#if !defined(__TARGET_OS__Windows)
os << ETK_BASH_COLOR_CYAN;
_os << ETK_BASH_COLOR_CYAN;
#endif
#if defined(__TARGET_OS__Android)
os.m_levelAndroid = ANDROID_LOG_INFO;
_os.m_levelAndroid = ANDROID_LOG_INFO;
#else
_os << "[I]";
#endif
os << "[I]";
break;
case LOG_LEVEL_DEBUG:
#if !defined(__TARGET_OS__Windows)
os << ETK_BASH_COLOR_YELLOW;
_os << ETK_BASH_COLOR_YELLOW;
#endif
#if defined(__TARGET_OS__Android)
os.m_levelAndroid = ANDROID_LOG_DEBUG;
_os.m_levelAndroid = ANDROID_LOG_DEBUG;
#else
_os << "[D]";
#endif
os << "[D]";
break;
case LOG_LEVEL_VERBOSE:
#if !defined(__TARGET_OS__Windows)
os << ETK_BASH_COLOR_WHITE;
_os << ETK_BASH_COLOR_WHITE;
#endif
#if defined(__TARGET_OS__Android)
os.m_levelAndroid = ANDROID_LOG_VERBOSE;
_os.m_levelAndroid = ANDROID_LOG_VERBOSE;
#else
_os << "[V]";
#endif
os << "[V]";
break;
default:
os << "[?]";
#if !defined(__TARGET_OS__Android)
_os << "[?]";
#endif
break;
}
return os;
return _os;
}
@ -141,117 +149,117 @@ etk::CCout::~CCout()
};
etk::CCout& etk::CCout::operator << (const etk::UniChar& t)
etk::CCout& etk::CCout::operator << (const etk::UniChar& _t)
{
char output[5];
t.GetUtf8(output);
_t.GetUtf8(output);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", output);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (int8_t t)
etk::CCout& etk::CCout::operator << (int8_t _t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", _t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (int16_t t)
etk::CCout& etk::CCout::operator << (int16_t _t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", _t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (int32_t t)
etk::CCout& etk::CCout::operator << (int32_t _t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", _t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (int64_t t)
etk::CCout& etk::CCout::operator << (int64_t _t)
{
#if __WORDSIZE == 64
snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", _t);
#else
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", _t);
#endif
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (uint8_t t)
etk::CCout& etk::CCout::operator << (uint8_t _t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", _t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (uint16_t t)
etk::CCout& etk::CCout::operator << (uint16_t _t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", _t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (uint32_t t)
etk::CCout& etk::CCout::operator << (uint32_t _t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", _t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (uint64_t t)
etk::CCout& etk::CCout::operator << (uint64_t _t)
{
#if __WORDSIZE == 64
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lu", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lu", _t);
#else
snprintf(tmp, MAX_LOG_SIZE_TMP, "%llu", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%llu", _t);
#endif
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (double t)
etk::CCout& etk::CCout::operator << (double _t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", _t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (float t)
etk::CCout& etk::CCout::operator << (float _t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", _t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (char * t)
etk::CCout& etk::CCout::operator << (char * _t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", _t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (const char * t)
etk::CCout& etk::CCout::operator << (const char * _t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", _t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (char t)
etk::CCout& etk::CCout::operator << (char _t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", _t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (bool t)
etk::CCout& etk::CCout::operator << (bool _t)
{
if (t) {
if (_t) {
strncat(m_tmpChar, "true", MAX_LOG_SIZE);
} else {
strncat(m_tmpChar, "false", MAX_LOG_SIZE);
@ -260,14 +268,14 @@ etk::CCout& etk::CCout::operator << (bool t)
}
etk::CCout& etk::CCout::operator << (CStart ccc)
etk::CCout& etk::CCout::operator << (CStart _ccc)
{
m_mutex.Lock();
return *this;
}
etk::CCout& etk::CCout::operator << (etk::CEndl t)
etk::CCout& etk::CCout::operator << (etk::CEndl _t)
{
#if !defined(__TARGET_OS__Windows)
strncat(m_tmpChar, ETK_BASH_COLOR_NORMAL, MAX_LOG_SIZE);

View File

@ -32,23 +32,23 @@ namespace etk
public:
CCout(void);
~CCout(void);
CCout& operator << (const etk::UniChar& t);;
CCout& operator << (int8_t t);
CCout& operator << (int16_t t);
CCout& operator << (int32_t t);
CCout& operator << (int64_t t);
CCout& operator << (uint8_t t);
CCout& operator << (uint16_t t);
CCout& operator << (uint32_t t);
CCout& operator << (uint64_t t);
CCout& operator << (double t);
CCout& operator << (float t);
CCout& operator << (char * t);
CCout& operator << (const char * t);
CCout& operator << (char t);
CCout& operator << (bool t);
CCout& operator << (CStart ccc);
CCout& operator << (etk::CEndl t);
CCout& operator << (const etk::UniChar& _t);;
CCout& operator << (int8_t _t);
CCout& operator << (int16_t _t);
CCout& operator << (int32_t _t);
CCout& operator << (int64_t _t);
CCout& operator << (uint8_t _t);
CCout& operator << (uint16_t _t);
CCout& operator << (uint32_t _t);
CCout& operator << (uint64_t _t);
CCout& operator << (double _t);
CCout& operator << (float _t);
CCout& operator << (char * _t);
CCout& operator << (const char * _t);
CCout& operator << (char _t);
CCout& operator << (bool _t);
CCout& operator << (CStart _ccc);
CCout& operator << (etk::CEndl _t);
};
extern etk::CCout cout;
extern etk::CEndl endl;
@ -67,7 +67,7 @@ namespace etk
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
etk::CCout& operator <<(etk::CCout &os, const etk::logLevel_te obj);
etk::CCout& operator <<(etk::CCout &_os, const etk::logLevel_te _obj);
void DisplayBacktrace(void);
};

View File

@ -23,8 +23,9 @@ const etk::Archive::Content& etk::Archive::GetContent(const etk::UString& _key)
void etk::Archive::Display(void)
{
for (esize_t iii=0; iii<m_content.Size(); iii++) {
esize_t size = m_content.GetValue(iii).Size();
TK_INFO(" element : " << m_content.GetKey(iii) << " size=" << size);
esize_t size = m_content.GetValue(iii).GetTheoricSize();
esize_t sizeR = m_content.GetValue(iii).Size();
TK_INFO(" element : " << m_content.GetKey(iii) << " size=" << size << " allocated=" << sizeR);
}
}

View File

@ -60,7 +60,7 @@ etk::archive::Zip::~Zip(void)
void etk::archive::Zip::LoadFile(int32_t _id)
{
etk::UString fileNameRequested = m_content.GetKey(_id);
TK_WARNING("Load file Here ... : " << _id << " = '" << fileNameRequested << "'");
TK_VERBOSE("Real load file : " << _id << " = '" << fileNameRequested << "'");
unzGoToFirstFile(m_ctx);
@ -96,6 +96,10 @@ void etk::archive::Zip::LoadFile(int32_t _id)
return;
}
} while ( error > 0 );
//((char*)data)[m_content.GetValue(_id).GetTheoricSize()] = '\0';
// stop searching here
unzCloseCurrentFile(m_ctx);
return;
}
unzCloseCurrentFile(m_ctx);

View File

@ -36,46 +36,46 @@ extern "C" {
static etk::UString SimplifyPathAbstractPath(etk::UString input)
static etk::UString SimplifyPathAbstractPath(etk::UString _input)
{
int32_t findStartPos = input.FindForward('/') + 1;
int32_t findPos = input.FindForward('/', findStartPos);
int32_t findStartPos = _input.FindForward('/') + 1;
int32_t findPos = _input.FindForward('/', findStartPos);
//TK_DEBUG("Siplify : \"" << input << "\"");
int32_t preventBadCode = 0;
while (findPos!=-1)
{
//TK_DEBUG(" string=\"" << input << "\"");
//TK_DEBUG(" '/' @" << findPos);
if (input.Size()<findPos+1) {
if (_input.Size()<findPos+1) {
// no more element ...
break;
}
if( input[findPos+1] == '/'
|| ( input[findPos+1] == '.'
&& input.Size()==findPos+2 )) {
if( _input[findPos+1] == '/'
|| ( _input[findPos+1] == '.'
&& _input.Size()==findPos+2 )) {
// cleane the element path
input.Remove(findPos+1, 1);
_input.Remove(findPos+1, 1);
//TK_DEBUG(" Remove // string=\"" << input << "\"");
} else {
if (input.Size()<findPos+2) {
if (_input.Size()<findPos+2) {
// no more element ...
break;
}
if( input[findPos+1] == '.'
&& input[findPos+2] == '.') {
if( _input[findPos+1] == '.'
&& _input[findPos+2] == '.') {
// cleane the element path
input.Remove(findStartPos, findPos+3 - findStartPos );
_input.Remove(findStartPos, findPos+3 - findStartPos );
//TK_DEBUG(" Remove xxx/.. string=\"" << input << "\"");
} else if( input[findPos+1] == '.'
&& input[findPos+2] == '/') {
} else if( _input[findPos+1] == '.'
&& _input[findPos+2] == '/') {
// cleane the element path
input.Remove(findPos+1, 2);
_input.Remove(findPos+1, 2);
//TK_DEBUG(" Remove ./ string=\"" << input << "\"");
} else {
findStartPos = findPos+1;
}
}
findPos = input.FindForward('/', findStartPos);
findPos = _input.FindForward('/', findStartPos);
preventBadCode++;
if (preventBadCode>5000) {
TK_CRITICAL("ERROR when getting the small path ... this is loop prevention...");
@ -97,7 +97,7 @@ static etk::UString SimplifyPathAbstractPath(etk::UString input)
#endif
*/
//TK_DEBUG(" ==> \"" << input << "\"");
return input;
return _input;
}
@ -126,50 +126,50 @@ static etk::UString baseRunPath = "/";
#ifdef __TARGET_OS__Android
static etk::Archive* s_APKArchive = NULL;
static void loadAPK(etk::UString& apkPath)
static void loadAPK(etk::UString& _apkPath)
{
TK_DEBUG("Loading APK \"" << apkPath << "\"");
s_APKArchive = etk::Archive::Load(apkPath);
TK_ASSERT(s_APKArchive != NULL, "Error loading APK ... \"" << apkPath << "\"");
TK_DEBUG("Loading APK \"" << _apkPath << "\"");
s_APKArchive = etk::Archive::Load(_apkPath);
TK_ASSERT(s_APKArchive != NULL, "Error loading APK ... \"" << _apkPath << "\"");
//Just for debug, print APK contents
s_APKArchive->Display();
}
#endif
// for specific device contraint :
void etk::SetBaseFolderData(const char * folder)
void etk::SetBaseFolderData(const char* _folder)
{
#ifdef __TARGET_OS__Android
baseFolderData = "assets/";
s_fileAPK = folder;
s_fileAPK = _folder;
loadAPK(s_fileAPK);
#else
TK_WARNING("Not Availlable Outside Android");
#endif
}
void etk::SetBaseFolderDataUser(const char * folder)
void etk::SetBaseFolderDataUser(const char* _folder)
{
#ifdef __TARGET_OS__Android
baseFolderDataUser = folder;
baseFolderDataUser = _folder;
#else
TK_WARNING("Not Availlable Outside Android");
#endif
}
void etk::SetBaseFolderCache(const char * folder)
void etk::SetBaseFolderCache(const char* _folder)
{
#ifdef __TARGET_OS__Android
baseFolderCache = folder;
baseFolderCache = _folder;
#else
TK_WARNING("Not Availlable Outside Android");
#endif
}
etk::UString l_argZero="";
void etk::SetArgZero(const etk::UString& val)
void etk::SetArgZero(const etk::UString& _val)
{
l_argZero = val;
l_argZero = _val;
}
/*
On Unixes with /proc really straight and realiable way is to:
@ -246,19 +246,19 @@ etk::UString GetApplicationPath(void)
return SimplifyPathAbstractPath(binaryName);
}
}
char * basicPathPATH = getenv("PATH");
if (NULL != basicPathPWD) {
//char * basicPathPATH = getenv("PATH");
//if (NULL != basicPathPWD) {
// TODO : bad case ...
}
//}
// and now we will really in a bad mood ...
#endif
TK_INFO("Binary name : " << binaryName);
return binaryName;
}
void etk::InitDefaultFolder(const char * applName)
void etk::InitDefaultFolder(const char* _applName)
{
baseApplName = applName;
baseApplName = _applName;
char cCurrentPath[FILENAME_MAX];
char * basicPath = getenv("HOME");
@ -266,6 +266,8 @@ void etk::InitDefaultFolder(const char * applName)
TK_ERROR("ERROR while trying to get the path of the home folder");
#if defined(__TARGET_OS__Windows)
baseFolderHome = "c:/";
#elif defined(__TARGET_OS__Android)
baseFolderHome = "/sdcard";
#else
baseFolderHome = "~";
#endif
@ -368,16 +370,16 @@ bool etk::FSNode::LoadDataZip(void)
static int32_t FSNODE_LOCAL_mkdir(const char *path, mode_t mode)
static int32_t FSNODE_LOCAL_mkdir(const char* _path, mode_t _mode)
{
struct stat st;
int32_t status = 0;
if (stat(path, &st) != 0) {
if (stat(_path, &st) != 0) {
/* Directory does not exist. EEXIST for race condition */
#ifdef __TARGET_OS__Windows
if(0!=mkdir(path)
if(0!=mkdir(_path)
#else
if(0!=mkdir(path, mode)
if(0!=mkdir(_path, _mode)
#endif
&& errno != EEXIST) {
status = -1;
@ -390,12 +392,12 @@ static int32_t FSNODE_LOCAL_mkdir(const char *path, mode_t mode)
return(status);
}
static int32_t FSNODE_LOCAL_mkPath(const char *path, mode_t mode)
static int32_t FSNODE_LOCAL_mkPath(const char* _path, mode_t _mode)
{
char *pp;
char *sp;
int status;
char *copypath = strdup(path);
char *copypath = strdup(_path);
if (NULL==copypath) {
return -1;
}
@ -405,13 +407,13 @@ static int32_t FSNODE_LOCAL_mkPath(const char *path, mode_t mode)
if (sp != pp) {
/* Neither root nor double slash in path */
*sp = '\0';
status = FSNODE_LOCAL_mkdir(copypath, mode);
status = FSNODE_LOCAL_mkdir(copypath, _mode);
*sp = '/';
}
pp = sp + 1;
}
if (status == 0) {
status = FSNODE_LOCAL_mkdir(path, mode);
status = FSNODE_LOCAL_mkdir(_path, _mode);
}
free(copypath);
return (status);
@ -424,7 +426,7 @@ static int32_t FSNODE_LOCAL_mkPath(const char *path, mode_t mode)
#undef __class__
#define __class__ "FSNode"
etk::FSNode::FSNode(const etk::UString& nodeName) :
etk::FSNode::FSNode(const etk::UString& _nodeName) :
m_userFileName(""),
m_type(etk::FSN_TYPE_UNKNOW),
m_typeNode(etk::FSN_UNKNOW),
@ -437,7 +439,7 @@ etk::FSNode::FSNode(const etk::UString& nodeName) :
m_zipReadingOffset(-1)
#endif
{
PrivateSetName(nodeName);
PrivateSetName(_nodeName);
}
@ -454,28 +456,28 @@ etk::FSNode::~FSNode(void)
}
void etk::FSNode::SortElementList(etk::Vector<etk::FSNode *> &list)
void etk::FSNode::SortElementList(etk::Vector<etk::FSNode *>& _list)
{
etk::Vector<etk::FSNode *> tmpList = list;
list.Clear();
etk::Vector<etk::FSNode *> tmpList = _list;
_list.Clear();
for(int32_t iii=0; iii<tmpList.Size(); iii++) {
if (NULL != tmpList[iii]) {
int32_t findPos = 0;
for(int32_t jjj=0; jjj<list.Size(); jjj++) {
for(int32_t jjj=0; jjj<_list.Size(); jjj++) {
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
if (list[jjj]!=NULL) {
if (tmpList[iii]->GetNameFile() > list[jjj]->GetNameFile()) {
if (_list[jjj]!=NULL) {
if (tmpList[iii]->GetNameFile() > _list[jjj]->GetNameFile()) {
findPos = jjj+1;
}
}
}
//EWOL_DEBUG("position="<<findPos);
list.Insert(findPos, tmpList[iii]);
_list.Insert(findPos, tmpList[iii]);
}
}
}
void etk::FSNode::PrivateSetName(const etk::UString& newName)
void etk::FSNode::PrivateSetName(const etk::UString& _newName)
{
if( NULL != m_PointerFile
#ifdef __TARGET_OS__Android
@ -495,15 +497,15 @@ void etk::FSNode::PrivateSetName(const etk::UString& newName)
// Reset ALL DATA :
m_userFileName = "";
m_type = etk::FSN_TYPE_UNKNOW;
TK_DBG_MODE("1 : Set Name : \"" << newName << "\"");
TK_DBG_MODE("1 : Set Name : \"" << _newName << "\"");
// generate destination name in case of the input error
etk::UString destFilename;
if (newName.Size() == 0) {
if (_newName.Size() == 0) {
// if no name ==> go to the root Folder
destFilename = "ROOT:";
} else {
destFilename = newName;
destFilename = _newName;
}
bool isRootFolder = false;
@ -617,12 +619,12 @@ void etk::FSNode::PrivateSetName(const etk::UString& newName)
}
bool DirectCheckFile(etk::UString tmpFileNameDirect, bool checkInAPKIfNeeded=false)
bool DirectCheckFile(etk::UString _tmpFileNameDirect, bool _checkInAPKIfNeeded=false)
{
#ifdef __TARGET_OS__Android
if (true == checkInAPKIfNeeded) {
if (true == _checkInAPKIfNeeded) {
if( NULL != s_APKArchive
&& true == s_APKArchive->Exist(tmpFileNameDirect) ) {
&& true == s_APKArchive->Exist(_tmpFileNameDirect) ) {
return true;
}
return false;
@ -630,7 +632,7 @@ bool DirectCheckFile(etk::UString tmpFileNameDirect, bool checkInAPKIfNeeded=fal
#endif
// tmpStat Buffer :
struct stat statProperty;
if (-1 == stat(tmpFileNameDirect.c_str(), &statProperty)) {
if (-1 == stat(_tmpFileNameDirect.c_str(), &statProperty)) {
return false;
}
return true;
@ -794,16 +796,16 @@ void etk::FSNode::UpdateFileSystemProperty(void)
return;
}
bool etk::FSNode::SetRight(etk::FSNodeRight newRight)
bool etk::FSNode::SetRight(etk::FSNodeRight _newRight)
{
// TODO : ...
TK_ERROR("Can not set the new rights ...");
return false;
}
void etk::FSNode::SetName(const etk::UString& newName)
void etk::FSNode::SetName(const etk::UString& _newName)
{
PrivateSetName(newName);
PrivateSetName(_newName);
}
etk::UString etk::FSNode::GetNameFolder(void) const
@ -920,9 +922,9 @@ bool etk::FSNode::Touch(void)
return ret;
}
bool etk::FSNode::Move(const etk::UString& path)
bool etk::FSNode::Move(const etk::UString& _path)
{
etk::FSNode tmpDst(path);
etk::FSNode tmpDst(_path);
if (tmpDst.Exist()==true) {
tmpDst.Remove();
}
@ -1003,9 +1005,9 @@ etk::UString etk::FSNode::TimeAccessedString(void) const
/*
Operator :
*/
const etk::FSNode& etk::FSNode::operator= (const etk::FSNode &obj )
const etk::FSNode& etk::FSNode::operator= (const etk::FSNode &_obj )
{
if( this != &obj ) // avoid copy to itself
if( this != &_obj ) // avoid copy to itself
{
if( NULL != m_PointerFile
#ifdef __TARGET_OS__Android
@ -1020,17 +1022,17 @@ const etk::FSNode& etk::FSNode::operator= (const etk::FSNode &obj )
m_zipContent = NULL;
m_zipReadingOffset = 0;
#endif
etk::UString tmppp = obj.GetName();
etk::UString tmppp = _obj.GetName();
PrivateSetName(tmppp);
}
return *this;
}
bool etk::FSNode::operator== (const etk::FSNode &obj ) const
bool etk::FSNode::operator== (const etk::FSNode& _obj ) const
{
if( this != &obj ) {
if( obj.m_userFileName == m_userFileName
&& obj.m_systemFileName == m_systemFileName
&& obj.m_type == m_type ) {
if( this != &_obj ) {
if( _obj.m_userFileName == m_userFileName
&& _obj.m_systemFileName == m_systemFileName
&& _obj.m_type == m_type ) {
return true;
} else {
return false;
@ -1040,88 +1042,88 @@ bool etk::FSNode::operator== (const etk::FSNode &obj ) const
return true;
}
bool etk::FSNode::operator!= (const etk::FSNode &obj ) const
bool etk::FSNode::operator!= (const etk::FSNode& _obj ) const
{
return !(*this == obj);
return !(*this == _obj);
}
etk::CCout& etk::operator <<(etk::CCout &os, const etk::FSNode &obj)
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::FSNode &_obj)
{
os << "[" << obj.m_type << "]->\"" << obj.m_userFileName << "\"";
return os;
_os << "[" << _obj.m_type << "]->\"" << _obj.m_userFileName << "\"";
return _os;
}
etk::CCout& etk::operator <<(etk::CCout &os, const etk::FSNType_te &obj)
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::FSNType_te &_obj)
{
switch (obj)
switch (_obj)
{
case etk::FSN_TYPE_UNKNOW:
os << "FSN_TYPE_UNKNOW";
_os << "FSN_TYPE_UNKNOW";
break;
case etk::FSN_TYPE_DIRECT:
os << "FSN_TYPE_DIRECT";
_os << "FSN_TYPE_DIRECT";
break;
case etk::FSN_TYPE_RELATIF:
os << "FSN_TYPE_RELATIF";
_os << "FSN_TYPE_RELATIF";
break;
case etk::FSN_TYPE_HOME:
os << "FSN_TYPE_HOME";
_os << "FSN_TYPE_HOME";
break;
case etk::FSN_TYPE_DATA:
os << "FSN_TYPE_DATA";
_os << "FSN_TYPE_DATA";
break;
case etk::FSN_TYPE_USER_DATA:
os << "FSN_TYPE_USER_DATA";
_os << "FSN_TYPE_USER_DATA";
break;
case etk::FSN_TYPE_CACHE:
os << "FSN_TYPE_CACHE";
_os << "FSN_TYPE_CACHE";
break;
case etk::FSN_TYPE_THEME:
os << "FSN_TYPE_THEME";
_os << "FSN_TYPE_THEME";
break;
case etk::FSN_TYPE_THEME_DATA:
os << "FSN_TYPE_THEME(DATA)";
_os << "FSN_TYPE_THEME(DATA)";
break;
default:
os << "FSN_TYPE_????";
_os << "FSN_TYPE_????";
break;
}
return os;
return _os;
}
etk::CCout& etk::operator <<(etk::CCout &os, const etk::typeNode_te &obj)
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::typeNode_te &_obj)
{
switch (obj)
switch (_obj)
{
case etk::FSN_UNKNOW:
os << "FSN_UNKNOW";
_os << "FSN_UNKNOW";
break;
case etk::FSN_BLOCK:
os << "FSN_BLOCK";
_os << "FSN_BLOCK";
break;
case etk::FSN_CHARACTER:
os << "FSN_CHARACTER";
_os << "FSN_CHARACTER";
break;
case etk::FSN_FOLDER:
os << "FSN_FOLDER";
_os << "FSN_FOLDER";
break;
case etk::FSN_FIFO:
os << "FSN_FIFO";
_os << "FSN_FIFO";
break;
case etk::FSN_LINK:
os << "FSN_LINK";
_os << "FSN_LINK";
break;
case etk::FSN_FILE:
os << "FSN_FILE";
_os << "FSN_FILE";
break;
case etk::FSN_SOCKET:
os << "FSN_SOCKET";
_os << "FSN_SOCKET";
break;
default:
os << "FSN_????";
_os << "FSN_????";
break;
}
return os;
return _os;
}
/*
@ -1151,7 +1153,7 @@ int64_t etk::FSNode::FolderCount(void)
}
return counter;
}
etk::Vector<etk::FSNode *> etk::FSNode::FolderGetSubList(bool showHidenFile, bool getFolderAndOther, bool getFile, bool temporaryFile)
etk::Vector<etk::FSNode *> etk::FSNode::FolderGetSubList(bool _showHidenFile, bool _getFolderAndOther, bool _getFile, bool _temporaryFile)
{
etk::Vector<etk::FSNode*> tmpp;
if (m_typeNode != etk::FSN_FOLDER ) {
@ -1174,20 +1176,20 @@ etk::Vector<etk::FSNode *> etk::FSNode::FolderGetSubList(bool showHidenFile, boo
continue;
}
if( false == tmpName.StartWith(".")
|| true == showHidenFile) {
|| true == _showHidenFile) {
tmpEmement = new etk::FSNode(GetRelativeFolder()+tmpName);
if (NULL == tmpEmement) {
TK_ERROR("allocation error ... of ewol::FSNode");
continue;
}
if(tmpEmement->GetNodeType() == etk::FSN_FILE) {
if (true == getFile) {
if (true == _getFile) {
tmpp.PushBack(tmpEmement);
} else {
delete(tmpEmement);
tmpEmement = NULL;
}
} else if (getFolderAndOther) {
} else if (_getFolderAndOther) {
tmpp.PushBack(tmpEmement);
} else {
delete(tmpEmement);
@ -1211,7 +1213,7 @@ etk::FSNode etk::FSNode::FolderGetParent(void)
return tmpp;
}
void etk::FSNode::FolderGetRecursiveFiles(etk::Vector<etk::UString>& output, bool recursiveEnable)
void etk::FSNode::FolderGetRecursiveFiles(etk::Vector<etk::UString>& _output, bool _recursiveEnable)
{
#ifdef __TARGET_OS__Android
if( m_type == etk::FSN_TYPE_DATA
@ -1234,7 +1236,7 @@ void etk::FSNode::FolderGetRecursiveFiles(etk::Vector<etk::UString>& output, boo
filename.Remove(0,assetsName.Size());
}
tmpString += filename;
output.PushBack(tmpString);
_output.PushBack(tmpString);
}
}
return;
@ -1260,11 +1262,11 @@ void etk::FSNode::FolderGetRecursiveFiles(etk::Vector<etk::UString>& output, boo
if (NULL != tmpEmement) {
if(tmpEmement->GetNodeType() == etk::FSN_FILE) {
etk::UString tmpVal = tmpEmement->GetName();
output.PushBack(tmpVal);
_output.PushBack(tmpVal);
}
if(tmpEmement->GetNodeType() == etk::FSN_FOLDER) {
if (true==recursiveEnable) {
tmpEmement->FolderGetRecursiveFiles(output);
if (true==_recursiveEnable) {
tmpEmement->FolderGetRecursiveFiles(_output, _recursiveEnable);
}
}
delete(tmpEmement);
@ -1433,11 +1435,11 @@ bool etk::FSNode::FileClose(void)
m_PointerFile = NULL;
return true;
}
char* etk::FSNode::FileGets(char * elementLine, int64_t maxData)
char* etk::FSNode::FileGets(char * _elementLine, int64_t _maxData)
{
memset(elementLine, 0, maxData);
memset(_elementLine, 0, _maxData);
#ifdef __TARGET_OS__Android
char * element = elementLine;
char * element = _elementLine;
int64_t outSize = 0;
if( etk::FSN_TYPE_DATA == m_type
|| etk::FSN_TYPE_THEME_DATA == m_type) {//char * tmpData = internalDataFiles[iii].data + m_readingOffset;
@ -1445,7 +1447,7 @@ char* etk::FSNode::FileGets(char * elementLine, int64_t maxData)
element[0] = '\0';
return NULL;
}
if (m_zipReadingOffset>m_zipContent->Size()) {
if (m_zipReadingOffset>=m_zipContent->Size()) {
element[0] = '\0';
return NULL;
}
@ -1457,19 +1459,19 @@ char* etk::FSNode::FileGets(char * elementLine, int64_t maxData)
element++;
m_zipReadingOffset++;
*element = '\0';
return elementLine;
return _elementLine;
}
*element = ((char*)m_zipContent->Data())[m_zipReadingOffset];
element++;
m_zipReadingOffset++;
if (m_zipReadingOffset>m_zipContent->Size()) {
if (m_zipReadingOffset>=m_zipContent->Size()) {
*element = '\0';
return elementLine;
return _elementLine;
}
// check maxData Size ...
if (outSize>=maxData-1) {
if (outSize>=_maxData-1) {
*element = '\0';
return elementLine;
return _elementLine;
}
outSize++;
}
@ -1477,34 +1479,34 @@ char* etk::FSNode::FileGets(char * elementLine, int64_t maxData)
return NULL;
} else {
// send last line
return elementLine;
return _elementLine;
}
}
#endif
return fgets(elementLine, maxData, m_PointerFile);
return fgets(_elementLine, _maxData, m_PointerFile);
}
int64_t etk::FSNode::FileRead(void * data, int64_t blockSize, int64_t nbBlock)
int64_t etk::FSNode::FileRead(void* _data, int64_t _blockSize, int64_t _nbBlock)
{
#ifdef __TARGET_OS__Android
if( etk::FSN_TYPE_DATA == m_type
|| etk::FSN_TYPE_THEME_DATA == m_type) {
if (NULL == m_zipContent) {
((char*)data)[0] = '\0';
((char*)_data)[0] = '\0';
return 0;
}
int32_t dataToRead = blockSize * nbBlock;
int32_t dataToRead = _blockSize * _nbBlock;
if (dataToRead + m_zipReadingOffset > m_zipContent->Size()) {
nbBlock = ((m_zipContent->Size() - m_zipReadingOffset) / blockSize);
dataToRead = blockSize * nbBlock;
_nbBlock = ((m_zipContent->Size() - m_zipReadingOffset) / _blockSize);
dataToRead = _blockSize * _nbBlock;
}
memcpy(data, &((char*)m_zipContent->Data())[m_zipReadingOffset], dataToRead);
memcpy(_data, &((char*)m_zipContent->Data())[m_zipReadingOffset], dataToRead);
m_zipReadingOffset += dataToRead;
return nbBlock;
return _nbBlock;
}
#endif
return fread(data, blockSize, nbBlock, m_PointerFile);
return fread(_data, _blockSize, _nbBlock, m_PointerFile);
}
int64_t etk::FSNode::FileWrite(void * data, int64_t blockSize, int64_t nbBlock)
int64_t etk::FSNode::FileWrite(void * _data, int64_t _blockSize, int64_t _nbBlock)
{
#ifdef __TARGET_OS__Android
if( etk::FSN_TYPE_DATA == m_type
@ -1513,9 +1515,9 @@ int64_t etk::FSNode::FileWrite(void * data, int64_t blockSize, int64_t nbBlock)
return 0;
}
#endif
return fwrite(data, blockSize, nbBlock, m_PointerFile);
return fwrite(_data, _blockSize, _nbBlock, m_PointerFile);
}
bool etk::FSNode::FileSeek(long int offset, etk::seekNode_te origin)
bool etk::FSNode::FileSeek(long int _offset, etk::seekNode_te _origin)
{
#ifdef __TARGET_OS__Android
if( etk::FSN_TYPE_DATA == m_type
@ -1524,7 +1526,7 @@ bool etk::FSNode::FileSeek(long int offset, etk::seekNode_te origin)
return false;
}
int32_t positionEnd = 0;
switch(origin) {
switch(_origin) {
case etk::FSN_SEEK_END:
positionEnd = m_zipContent->Size();
break;
@ -1535,7 +1537,7 @@ bool etk::FSNode::FileSeek(long int offset, etk::seekNode_te origin)
positionEnd = 0;
break;
}
positionEnd += offset;
positionEnd += _offset;
if (positionEnd < 0) {
positionEnd = 0;
} else if (positionEnd > m_zipContent->Size()) {
@ -1546,7 +1548,7 @@ bool etk::FSNode::FileSeek(long int offset, etk::seekNode_te origin)
}
#endif
int originFS = 0;
switch(origin) {
switch(_origin) {
case etk::FSN_SEEK_END:
originFS = SEEK_END;
break;
@ -1557,7 +1559,7 @@ bool etk::FSNode::FileSeek(long int offset, etk::seekNode_te origin)
originFS = 0;
break;
}
fseek(m_PointerFile, offset, originFS);
fseek(m_PointerFile, _offset, originFS);
if(ferror(m_PointerFile)) {
return false;
} else {
@ -1593,12 +1595,12 @@ class tmpThemeElement
static etk::Vector<tmpThemeElement*> g_listTheme;
// set the Folder of a subset of a theme ...
void etk::theme::SetName(etk::UString refName, etk::UString folderName)
void etk::theme::SetName(etk::UString _refName, etk::UString _folderName)
{
for(int32_t iii=0; iii<g_listTheme.Size(); iii++) {
if (NULL != g_listTheme[iii]) {
if (g_listTheme[iii]->refName==refName) {
g_listTheme[iii]->folderName = folderName;
if (g_listTheme[iii]->refName==_refName) {
g_listTheme[iii]->folderName = _folderName;
// action done
return;
}
@ -1610,23 +1612,23 @@ void etk::theme::SetName(etk::UString refName, etk::UString folderName)
TK_ERROR("pb to add a reference theme");
return;
}
tmpp->refName = refName;
tmpp->folderName = folderName;
tmpp->refName = _refName;
tmpp->folderName = _folderName;
g_listTheme.PushBack(tmpp);
}
// get the folder from a Reference theme
etk::UString etk::theme::GetName(etk::UString refName)
etk::UString etk::theme::GetName(etk::UString _refName)
{
for(int32_t iii=0; iii<g_listTheme.Size(); iii++) {
if (NULL != g_listTheme[iii]) {
if (g_listTheme[iii]->refName==refName) {
if (g_listTheme[iii]->refName==_refName) {
return g_listTheme[iii]->folderName;
}
}
}
// We did not find the theme
return refName;
return _refName;
}
// get the list of all the theme folder availlable in the user Home/appl
@ -1643,88 +1645,88 @@ etk::Vector<etk::UString> etk::theme::List(void)
* Simple direct wrapper on the FileSystem node access :
*
* -------------------------------------------------------------------------- */
bool etk::FSNodeRemove(const etk::UString& path)
bool etk::FSNodeRemove(const etk::UString& _path)
{
etk::FSNode tmpNode(path);
etk::FSNode tmpNode(_path);
if (false==tmpNode.Exist()) {
return false;
}
return tmpNode.Remove();
}
int64_t etk::FSNodeGetCount(const etk::UString& path)
int64_t etk::FSNodeGetCount(const etk::UString& _path)
{
etk::FSNode tmpNode(path);
etk::FSNode tmpNode(_path);
if (false==tmpNode.Exist()) {
return -1;
}
return tmpNode.FolderCount();
}
bool etk::FSNodeCreate(const etk::UString& path, etk::FSNodeRight right, etk::typeNode_te type)
bool etk::FSNodeCreate(const etk::UString& _path, etk::FSNodeRight _right, etk::typeNode_te _type)
{
// TODO :
return false;
}
bool etk::FSNodeExist(const etk::UString& path)
bool etk::FSNodeExist(const etk::UString& _path)
{
etk::FSNode tmpNode(path);
etk::FSNode tmpNode(_path);
return tmpNode.Exist();
}
bool etk::FSNodeMove(const etk::UString& path1, const etk::UString& path2)
bool etk::FSNodeMove(const etk::UString& _path1, const etk::UString& _path2)
{
etk::FSNode tmpNode(path1);
etk::FSNode tmpNode(_path1);
if (false==tmpNode.Exist()) {
TK_DEBUG("try to move un existant file \"" << path1 << "\"");
TK_DEBUG("try to move un existant file \"" << _path1 << "\"");
return false;
}
// no check error in every case
(void)etk::FSNodeRemove(path2);
(void)etk::FSNodeRemove(_path2);
//move the node
return tmpNode.Move(path2);
return tmpNode.Move(_path2);
}
etk::FSNodeRight etk::FSNodeGetRight(const etk::UString& path)
etk::FSNodeRight etk::FSNodeGetRight(const etk::UString& _path)
{
etk::FSNode tmpNode(path);
etk::FSNode tmpNode(_path);
return tmpNode.GetRight();
}
etk::typeNode_te etk::FSNodeGetType(const etk::UString& path)
etk::typeNode_te etk::FSNodeGetType(const etk::UString& _path)
{
etk::FSNode tmpNode(path);
etk::FSNode tmpNode(_path);
return tmpNode.GetNodeType();
}
uint64_t etk::FSNodeGetTimeCreated(const etk::UString& path)
uint64_t etk::FSNodeGetTimeCreated(const etk::UString& _path)
{
etk::FSNode tmpNode(path);
etk::FSNode tmpNode(_path);
return tmpNode.TimeCreated();
}
uint64_t etk::FSNodeGetTimeModified(const etk::UString& path)
uint64_t etk::FSNodeGetTimeModified(const etk::UString& _path)
{
etk::FSNode tmpNode(path);
etk::FSNode tmpNode(_path);
return tmpNode.TimeModified();
}
uint64_t etk::FSNodeGetTimeAccessed(const etk::UString& path)
uint64_t etk::FSNodeGetTimeAccessed(const etk::UString& _path)
{
etk::FSNode tmpNode(path);
etk::FSNode tmpNode(_path);
return tmpNode.TimeAccessed();
}
bool etk::FSNodeTouch(const etk::UString& path)
bool etk::FSNodeTouch(const etk::UString& _path)
{
etk::FSNode tmpNode(path);
etk::FSNode tmpNode(_path);
return tmpNode.Touch();
}
bool etk::FSNodeEcho(const etk::UString& path, const etk::UString& dataTowrite)
bool etk::FSNodeEcho(const etk::UString& _path, const etk::UString& _dataTowrite)
{
etk::FSNode tmpNode(path);
etk::FSNode tmpNode(_path);
if (false==tmpNode.Exist()) {
return false;
}
@ -1735,7 +1737,7 @@ bool etk::FSNodeEcho(const etk::UString& path, const etk::UString& dataTowrite)
return false;
}
// convert in UTF8 :
etk::Char tmpChar = dataTowrite.c_str();
etk::Char tmpChar = _dataTowrite.c_str();
int32_t nbChar = strlen(tmpChar);
if (nbChar != tmpNode.FileWrite(tmpChar, 1, nbChar)) {
tmpNode.FileClose();
@ -1744,9 +1746,9 @@ bool etk::FSNodeEcho(const etk::UString& path, const etk::UString& dataTowrite)
return tmpNode.FileClose();
}
bool etk::FSNodeEchoAdd(const etk::UString& path, const etk::UString& dataTowrite)
bool etk::FSNodeEchoAdd(const etk::UString& _path, const etk::UString& _dataTowrite)
{
etk::FSNode tmpNode(path);
etk::FSNode tmpNode(_path);
if (false==tmpNode.Exist()) {
return false;
}
@ -1757,7 +1759,7 @@ bool etk::FSNodeEchoAdd(const etk::UString& path, const etk::UString& dataTowrit
return false;
}
// convert in UTF8 :
etk::Char tmpChar = dataTowrite.c_str();
etk::Char tmpChar = _dataTowrite.c_str();
int32_t nbChar = strlen(tmpChar);
if (nbChar != tmpNode.FileWrite(tmpChar, 1, nbChar)) {
tmpNode.FileClose();

View File

@ -22,7 +22,7 @@
namespace etk
{
void SetArgZero(const etk::UString& val);
void SetArgZero(const etk::UString& _val);
/**
* List of Type that a node can have (this wrap some type that not exist on Windows)
*/
@ -37,7 +37,7 @@ namespace etk
FSN_SOCKET, //!< The node is a socket
} typeNode_te;
etk::CCout& operator <<(etk::CCout &os, const etk::typeNode_te &obj);
etk::CCout& operator <<(etk::CCout &_os, const etk::typeNode_te &_obj);
typedef enum {
FSN_SEEK_START,
@ -87,7 +87,7 @@ namespace etk
FSN_TYPE_THEME_DATA
} FSNType_te;
etk::CCout& operator <<(etk::CCout &os, const etk::FSNType_te &obj);
etk::CCout& operator <<(etk::CCout &_os, const etk::FSNType_te &_obj);
/*
note : The filename can be
@ -138,9 +138,9 @@ namespace etk
public:
/**
* @brief Constructor
* @param[in] path Path of the curent file /folder ...
* @param[in] _path Path of the curent file /folder ...
*/
FSNode(const etk::UString& path="~");
FSNode(const etk::UString& _path="~");
/**
* @brief Destructor
* @note you will have some warning if you did not close your files
@ -157,9 +157,9 @@ namespace etk
void UpdateFileSystemProperty(void);
/**
* @brief Common set name of the Node (if the user decide to change the node selection
* @param[in] newName Name of the Node
* @param[in] _newName Name of the Node
*/
void PrivateSetName(const etk::UString& newName);
void PrivateSetName(const etk::UString& _newName);
private:
#ifdef __TARGET_OS__Android
/**
@ -190,18 +190,18 @@ namespace etk
etk::FSNodeRight GetRight(void) const { return m_rights; };
/**
* @brief Set the specific right of the node
* @param[in] newRight new right to set
* @param[in] _newRight new right to set
* @return true : action done
* @return false : action not done
*/
bool SetRight(etk::FSNodeRight newRight);
bool SetRight(etk::FSNodeRight _newRight);
/**
* @brief Change the Node seeing (not rename the node, for this @ref Move)
* @param[in] newName New node name to show
* @param[in] _newName New node name to show
* @return true : action done
* @return false : action not done
*/
void SetName(const etk::UString& newName);
void SetName(const etk::UString& _newName);
/**
* @brief Get the Generate FileSystem name
* @return the requested filename
@ -238,11 +238,11 @@ namespace etk
bool Touch(void);
/**
* @brief Move the Node at a new path
* @param[in] path The new path
* @param[in] _path The new path
* @return true : action done
* @return false : action not done
*/
bool Move(const etk::UString& path);
bool Move(const etk::UString& _path);
/**
* @brief Get the node type (DATA/DIRECT...)
* @return the requested type
@ -286,29 +286,29 @@ namespace etk
etk::UString TimeAccessedString(void) const;
/**
* @brief copy the other FSnode ==> for vector
* @param[in] obj input node
* @param[in] _obj input node
* @return the current modify node
*/
const etk::FSNode& operator= (const etk::FSNode &obj );
const etk::FSNode& operator= (const etk::FSNode &_obj );
/**
* @brief Check if the 2 node are link with the same file
* @param[in] obj input node
* @param[in] _obj input node
* @return true : same node, false otherwise
*/
bool operator== (const etk::FSNode &obj ) const;
bool operator== (const etk::FSNode &_obj ) const;
/**
* @brief Check if the 2 node are NOT link with the same file
* @param[in] obj input node
* @param[in] _obj input node
* @return false : same node, true otherwise
*/
bool operator!= (const etk::FSNode &obj ) const;
bool operator!= (const etk::FSNode &_obj ) const;
/**
* @brief Write in the statard debug IO the current node
* @param[in] os std debug IO
* @param[in] obj Node to display
* @param[in] _os std debug IO
* @param[in] _obj Node to display
* @return std debug IO
*/
friend etk::CCout& operator <<( etk::CCout &os,const etk::FSNode &obj);
friend etk::CCout& operator <<( etk::CCout &_os,const etk::FSNode &_obj);
/**
* @brief Count the number of subFolder in the curent Folder
@ -318,16 +318,16 @@ namespace etk
int64_t FolderCount(void);
/**
* @brief Get the List of all node inside a node (folder only)
* @param[in] showHidenFile Add hidden file/folder/...
* @param[in] getFolderAndOther get folder
* @param[in] getFile Get files
* @param[in] temporaryFile add Tmp file like .bck or ~
* @param[in] _showHidenFile Add hidden file/folder/...
* @param[in] _getFolderAndOther get folder
* @param[in] _getFile Get files
* @param[in] _temporaryFile add Tmp file like .bck or ~
* @return The requested list
*/
etk::Vector<etk::FSNode *> FolderGetSubList(bool showHidenFile=true,
bool getFolderAndOther=true,
bool getFile=true,
bool temporaryFile=true);
etk::Vector<etk::FSNode *> FolderGetSubList(bool _showHidenFile=true,
bool _getFolderAndOther=true,
bool _getFile=true,
bool _temporaryFile=true);
/**
* @brief Get the father node of this node
* @return The requested node
@ -335,10 +335,10 @@ namespace etk
etk::FSNode FolderGetParent(void);
/**
* @brief Get all the File inside a Folder (done recursively)
* @param[out] output List of all the File names (You must clear it before set it in)
* @param[in] recursiveEnable Activate the recursive mode (enable by default)
* @param[out] _output List of all the File names (You must clear it before set it in)
* @param[in] _recursiveEnable Activate the recursive mode (enable by default)
*/
void FolderGetRecursiveFiles(etk::Vector<etk::UString>& output, bool recursiveEnable=true);
void FolderGetRecursiveFiles(etk::Vector<etk::UString>& _output, bool _recursiveEnable=true);
/**
* @brief Check if the file have an extention ( ***.ccc)
* @return true The file have an extention.
@ -383,35 +383,35 @@ namespace etk
bool FileClose(void);
/**
* @brief Get the pointer on the start line and the next line (or null)
* @param[in,out] elementLine Pointer to an array of chars where the string read is copied.
* @param[in] maxData Maximum number of characters to be copied into str (including the terminating null-character).
* @param[in,out] _elementLine Pointer to an array of chars where the string read is copied.
* @param[in] _maxData Maximum number of characters to be copied into str (including the terminating null-character).
* @return the pointer on the end of the cuurent line.
*/
char* FileGets(char * elementLine, int64_t maxData);
char* FileGets(char* _elementLine, int64_t _maxData);
/**
* @brief Read data from the file
* @param[in,out] data Pointer on the buffer that might be set the data
* @param[in] blockSize Size of one block of data
* @param[in] nbBlock Number of block needed
* @param[in,out] _data Pointer on the buffer that might be set the data
* @param[in] _blockSize Size of one block of data
* @param[in] _nbBlock Number of block needed
* @return Number of element read (in block number)
*/
int64_t FileRead(void * data, int64_t blockSize, int64_t nbBlock);
int64_t FileRead(void* _data, int64_t _blockSize, int64_t _nbBlock);
/**
* @brief Write data on the file
* @param[in] data Pointer on the buffer that might be set on the file
* @param[in] blockSize Size of one block of data
* @param[in] nbBlock Number of block needed
* @param[in] _data Pointer on the buffer that might be set on the file
* @param[in] _blockSize Size of one block of data
* @param[in] _nbBlock Number of block needed
* @return Number of element written (in block number)
*/
int64_t FileWrite(void * data, int64_t blockSize, int64_t nbBlock);
int64_t FileWrite(void* _data, int64_t _blockSize, int64_t _nbBlock);
/**
* @brief Move in the file Position
* @param[in] offset Offset to apply at the file
* @param[in] origin Origin of the position
* @param[in] _offset Offset to apply at the file
* @param[in] _origin Origin of the position
* @return true : action done
* @return false : action not done
*/
bool FileSeek(long int offset, etk::seekNode_te origin);
bool FileSeek(long int _offset, etk::seekNode_te _origin);
/**
* @brief Flush the current file
*/
@ -419,33 +419,33 @@ namespace etk
private:
/**
* @brief Order the list of subnode the folder first and the alphabetical order
* @param[in,out] list The list to order
* @param[in,out] _list The list to order
*/
void SortElementList(etk::Vector<etk::FSNode *> &list);
void SortElementList(etk::Vector<etk::FSNode *>& _list);
};
etk::CCout& operator <<(etk::CCout &os, const etk::FSNode &obj);
etk::CCout& operator <<(etk::CCout &_os, const etk::FSNode &_obj);
/**
* @brief Set manualy the folder of the Data.(like /usr/shared/applName/ for linux)
* @param[in] folder folder path of the cathegorie
* @param[in] _folder folder path of the cathegorie
*/
void SetBaseFolderData(const char * folder);
void SetBaseFolderData(const char* _folder);
/**
* @brief Set the user data folder (like /home/machin/.local/applName/ for linux)
* @param[in] folder folder path of the cathegorie
* @param[in] _folder folder path of the cathegorie
*/
void SetBaseFolderDataUser(const char * folder);
void SetBaseFolderDataUser(const char* _folder);
/**
* @brief Set the Cach folder for the application (like /tmp)
* @param[in] folder folder path of the cathegorie
* @param[in] _folder folder path of the cathegorie
*/
void SetBaseFolderCache(const char * folder);
void SetBaseFolderCache(const char* _folder);
/**
* @brief Initialyse all the subFolder usable by the user like DATA/HOME/CACHE/USERDATA
* @param[in] applName the name of the application
* @param[in] _applName the name of the application
*/
void InitDefaultFolder(const char * applName);
void InitDefaultFolder(const char* _applName);
/**
* @brief Get the home folder of the user
* @return the home folder : like : "/home/machin/"
@ -462,16 +462,16 @@ namespace etk
// TODO : Add an INIT ...
/**
* @brief Set the Folder of a subset of a theme ...
* @param[in] refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
* @param[in] folderName The associated folder of the Theme (like "myTheme/folder/folder2/")
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
* @param[in] _folderName The associated folder of the Theme (like "myTheme/folder/folder2/")
*/
void SetName(etk::UString refName, etk::UString folderName);
void SetName(etk::UString _refName, etk::UString _folderName);
/**
* @brief get the folder from a Reference theme
* @param[in] refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
* @return the path of the theme
*/
etk::UString GetName(etk::UString refName);
etk::UString GetName(etk::UString _refName);
/**
* @brief Get the list of all the theme folder availlable in the user Home/appl
* @return The list of elements
@ -481,100 +481,100 @@ namespace etk
/**
* @brief Simple access for : Remove folder and subFolder, files pipes ...
* @param[in] path Folder/File/Pipe path of the node
* @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeRemove(const etk::UString& path);
bool FSNodeRemove(const etk::UString& _path);
/**
* @brief Simple access for : count the number of element in a path (if it is not a path ==> return -1)
* @param[in] path Folder/File/Pipe path of the node
* @param[in] _path Folder/File/Pipe path of the node
* @return number of File inside
* @return -1 : An error occured
*/
int64_t FSNodeGetCount(const etk::UString& path);
int64_t FSNodeGetCount(const etk::UString& _path);
/**
* @brief Simple access for : Create a file or a folder depending of the request
* @param[in] path Folder/File/Pipe path of the node
* @param[in] right Right of the creation
* @param[in] type Type of the element that might be created
* @param[in] _path Folder/File/Pipe path of the node
* @param[in] _right Right of the creation
* @param[in] _type Type of the element that might be created
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeCreate(const etk::UString& path, etk::FSNodeRight right, etk::typeNode_te type=etk::FSN_FOLDER);
bool FSNodeCreate(const etk::UString& _path, etk::FSNodeRight _right, etk::typeNode_te _type=etk::FSN_FOLDER);
/**
* @brief Simple access for : chexk the exestance of an element
* @param[in] path Folder/File/Pipe path of the node
* @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeExist(const etk::UString& path);
bool FSNodeExist(const etk::UString& _path);
/**
* @brief Simple access for : chexk the exestance of an element
* @param[in] path Folder/File/Pipe path of the node sources
* @param[in] path Folder/File/Pipe path of the node destination
* @param[in] _path1 Folder/File/Pipe path of the node sources
* @param[in] _path2 Folder/File/Pipe path of the node destination
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeMove(const etk::UString& path1, const etk::UString& path2);
bool FSNodeMove(const etk::UString& _path1, const etk::UString& _path2);
/**
* @brief Simple access for : Get right of the current Node
* @param[in] path Folder/File/Pipe path of the node
* @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly
* @return false : An error occured
*/
etk::FSNodeRight FSNodeGetRight(const etk::UString& path);
etk::FSNodeRight FSNodeGetRight(const etk::UString& _path);
/**
* @brief Simple access for : Get type of the current node
* @param[in] path Folder/File/Pipe path of the node
* @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly
* @return false : An error occured
*/
etk::typeNode_te FSNodeGetType(const etk::UString& path);
etk::typeNode_te FSNodeGetType(const etk::UString& _path);
/**
* @brief Simple access for : Getting creation time of the current node
* @param[in] path Folder/File/Pipe path of the node
* @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly
* @return false : An error occured
*/
uint64_t FSNodeGetTimeCreated(const etk::UString& path);
uint64_t FSNodeGetTimeCreated(const etk::UString& _path);
/**
* @brief Simple access for : Getting Modification time of the current node
* @param[in] path Folder/File/Pipe path of the node
* @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly
* @return false : An error occured
*/
uint64_t FSNodeGetTimeModified(const etk::UString& path);
uint64_t FSNodeGetTimeModified(const etk::UString& _path);
/**
* @brief Simple access for : Getting Accessing time of the current node
* @param[in] path Folder/File/Pipe path of the node
* @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly
* @return false : An error occured
*/
uint64_t FSNodeGetTimeAccessed(const etk::UString& path);
uint64_t FSNodeGetTimeAccessed(const etk::UString& _path);
/**
* @brief Simple access for : Update Modification time with the current time of the node (>)
* @param[in] path Folder/File/Pipe path of the node
* @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeTouch(const etk::UString& path);
bool FSNodeTouch(const etk::UString& _path);
/**
* @brief Simple access for : Basic write on the node (like console echo)
* @param[in] path Folder/File/Pipe path of the node
* @param[in] dataTowrite write data in the Node
* @param[in] _path Folder/File/Pipe path of the node
* @param[in] _dataTowrite write data in the Node
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeEcho(const etk::UString& path, const etk::UString& dataTowrite);
bool FSNodeEcho(const etk::UString& _path, const etk::UString& _dataTowrite);
/**
* @brief Simple access for : Basic write on the node (like console echo) in adding mode (>>)
* @param[in] path Folder/File/Pipe path of the node
* @param[in] dataTowrite write data in the Node
* @param[in] _path Folder/File/Pipe path of the node
* @param[in] _dataTowrite write data in the Node
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeEchoAdd(const etk::UString& path, const etk::UString& dataTowrite);
bool FSNodeEchoAdd(const etk::UString& _path, const etk::UString& _dataTowrite);
/**
* @brief move file to generate an history of the current file
* @param[in] _path Folder/File/Pipe path of the node

View File

@ -29,22 +29,22 @@ etk::FSNodeRight::FSNodeRight(void) :
{
}
etk::FSNodeRight::FSNodeRight(int16_t newRight) :
m_rights(newRight&0x01FF)
etk::FSNodeRight::FSNodeRight(int16_t _newRight) :
m_rights(_newRight&0x01FF)
{
}
// copy operator :
const etk::FSNodeRight& etk::FSNodeRight::operator= (const etk::FSNodeRight &obj )
const etk::FSNodeRight& etk::FSNodeRight::operator= (const etk::FSNodeRight &_obj )
{
m_rights = obj.m_rights;
m_rights = _obj.m_rights;
return *this;
}
// set right :
const etk::FSNodeRight& etk::FSNodeRight::operator= (const int32_t newVal )
const etk::FSNodeRight& etk::FSNodeRight::operator= (const int32_t _newVal )
{
m_rights = newVal&0x01FF;
m_rights = _newVal&0x01FF;
return *this;
}
@ -64,29 +64,29 @@ bool etk::FSNodeRight::IsUserRunable(void) const
return ((m_rights&RIGHT_USER_EXECUTE)!=0)?true:false;
}
void etk::FSNodeRight::SetUserReadable(bool newStatus)
void etk::FSNodeRight::SetUserReadable(bool _newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_USER_READ);
if (true == newStatus) {
if (true == _newStatus) {
m_rights |= RIGHT_USER_READ;
}
}
void etk::FSNodeRight::SetUserWritable(bool newStatus)
void etk::FSNodeRight::SetUserWritable(bool _newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_USER_WRITE);
if (true == newStatus) {
if (true == _newStatus) {
m_rights |= RIGHT_USER_WRITE;
}
}
void etk::FSNodeRight::SetUserRunable(bool newStatus)
void etk::FSNodeRight::SetUserRunable(bool _newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_USER_EXECUTE);
if (true == newStatus) {
if (true == _newStatus) {
m_rights |= RIGHT_USER_EXECUTE;
}
}
@ -107,29 +107,29 @@ bool etk::FSNodeRight::IsGroupRunable(void) const
return ((m_rights&RIGHT_GROUP_EXECUTE)!=0)?true:false;
}
void etk::FSNodeRight::SetGroupReadable(bool newStatus)
void etk::FSNodeRight::SetGroupReadable(bool _newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_READ);
if (true == newStatus) {
if (true == _newStatus) {
m_rights |= RIGHT_GROUP_READ;
}
}
void etk::FSNodeRight::SetGroupWritable(bool newStatus)
void etk::FSNodeRight::SetGroupWritable(bool _newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_WRITE);
if (true == newStatus) {
if (true == _newStatus) {
m_rights |= RIGHT_GROUP_WRITE;
}
}
void etk::FSNodeRight::SetGroupRunable(bool newStatus)
void etk::FSNodeRight::SetGroupRunable(bool _newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_EXECUTE);
if (true == newStatus) {
if (true == _newStatus) {
m_rights |= RIGHT_GROUP_EXECUTE;
}
}
@ -150,29 +150,29 @@ bool etk::FSNodeRight::IsOtherRunable(void) const
return ((m_rights&RIGHT_OTHER_EXECUTE)!=0)?true:false;
}
void etk::FSNodeRight::SetOtherReadable(bool newStatus)
void etk::FSNodeRight::SetOtherReadable(bool _newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_READ);
if (true == newStatus) {
if (true == _newStatus) {
m_rights |= RIGHT_OTHER_READ;
}
}
void etk::FSNodeRight::SetOtherWritable(bool newStatus)
void etk::FSNodeRight::SetOtherWritable(bool _newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_WRITE);
if (true == newStatus) {
if (true == _newStatus) {
m_rights |= RIGHT_OTHER_WRITE;
}
}
void etk::FSNodeRight::SetOtherRunable(bool newStatus)
void etk::FSNodeRight::SetOtherRunable(bool _newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_EXECUTE);
if (true == newStatus) {
if (true == _newStatus) {
m_rights |= RIGHT_OTHER_EXECUTE;
}
}
@ -228,9 +228,9 @@ etk::UString etk::FSNodeRight::GetRight(void) const
}
etk::CCout& etk::operator <<(etk::CCout &os, const etk::FSNodeRight &obj)
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::FSNodeRight &_obj)
{
os << obj.GetRight();
return os;
_os << _obj.GetRight();
return _os;
};

View File

@ -19,39 +19,39 @@ namespace etk
uint16_t m_rights;
public:
FSNodeRight(void);
FSNodeRight(int16_t newRight);
FSNodeRight(int16_t _newRight);
~FSNodeRight(void) { };
// copy operator :
const etk::FSNodeRight& operator= (const etk::FSNodeRight &obj );
const etk::FSNodeRight& operator= (const etk::FSNodeRight &_obj );
// set right :
const etk::FSNodeRight& operator= (const int32_t newVal );
const etk::FSNodeRight& operator= (const int32_t _newVal );
void Clear(void) { m_rights = 0; };
// User
bool IsUserReadable(void) const;
bool IsUserWritable(void) const;
bool IsUserRunable(void) const;
void SetUserReadable(bool newStatus);
void SetUserWritable(bool newStatus);
void SetUserRunable(bool newStatus);
void SetUserReadable(bool _newStatus);
void SetUserWritable(bool _newStatus);
void SetUserRunable(bool _newStatus);
// group
bool IsGroupReadable(void) const;
bool IsGroupWritable(void) const;
bool IsGroupRunable(void) const;
void SetGroupReadable(bool newStatus);
void SetGroupWritable(bool newStatus);
void SetGroupRunable(bool newStatus);
void SetGroupReadable(bool _newStatus);
void SetGroupWritable(bool _newStatus);
void SetGroupRunable(bool _newStatus);
// other
bool IsOtherReadable(void) const;
bool IsOtherWritable(void) const;
bool IsOtherRunable(void) const;
void SetOtherReadable(bool newStatus);
void SetOtherWritable(bool newStatus);
void SetOtherRunable(bool newStatus);
void SetOtherReadable(bool _newStatus);
void SetOtherWritable(bool _newStatus);
void SetOtherRunable(bool _newStatus);
etk::UString GetRight(void) const;
};
etk::CCout& operator <<(etk::CCout &os, const etk::FSNodeRight &obj);
etk::CCout& operator <<(etk::CCout &_os, const etk::FSNodeRight &_obj);
};
#endif