[DEV] Comment of FSNode and add sonc capabilities
This commit is contained in:
parent
070a4a3f99
commit
516f0df12f
@ -24,6 +24,11 @@ etk::Char::operator const char *()
|
|||||||
return &m_data[0];
|
return &m_data[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
etk::Char::operator void *()
|
||||||
|
{
|
||||||
|
return &m_data[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void etk::Char::SetValue(const etk::Vector<char>& data)
|
void etk::Char::SetValue(const etk::Vector<char>& data)
|
||||||
{
|
{
|
||||||
|
@ -23,6 +23,7 @@ namespace etk
|
|||||||
Char(void);
|
Char(void);
|
||||||
~Char(void);
|
~Char(void);
|
||||||
operator const char *();
|
operator const char *();
|
||||||
|
operator void *();
|
||||||
void SetValue(const etk::Vector<char>& data);
|
void SetValue(const etk::Vector<char>& data);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -19,6 +19,7 @@ extern "C" {
|
|||||||
// file browsing ...
|
// file browsing ...
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <errno.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
@ -238,30 +239,59 @@ bool etk::FSNode::LoadDataZip(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef __class__
|
static int32_t FSNODE_LOCAL_mkdir(const char *path, mode_t mode)
|
||||||
#define __class__ "FSNode"
|
|
||||||
|
|
||||||
|
|
||||||
etk::FSNode::FSNode(void) :
|
|
||||||
m_userFileName(""),
|
|
||||||
m_type(etk::FSN_TYPE_UNKNOW),
|
|
||||||
m_typeNode(etk::FSN_UNKNOW),
|
|
||||||
m_PointerFile(NULL),
|
|
||||||
m_timeCreate(0),
|
|
||||||
m_timeModify(0),
|
|
||||||
m_timeAccess(0)
|
|
||||||
#ifdef __TARGET_OS__Android
|
|
||||||
, m_idZipFile(-1),
|
|
||||||
m_zipData(NULL),
|
|
||||||
m_zipDataSize(-1),
|
|
||||||
m_zipReadingOffset(-1)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
SetName("~");
|
struct stat st;
|
||||||
|
int32_t status = 0;
|
||||||
|
if (stat(path, &st) != 0) {
|
||||||
|
/* Directory does not exist. EEXIST for race condition */
|
||||||
|
if( 0!=mkdir(path, mode)
|
||||||
|
&& errno != EEXIST) {
|
||||||
|
status = -1;
|
||||||
|
}
|
||||||
|
} else if (!S_ISDIR(st.st_mode)) {
|
||||||
|
errno = ENOTDIR;
|
||||||
|
status = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t FSNODE_LOCAL_mkPath(const char *path, mode_t mode)
|
||||||
|
{
|
||||||
|
char *pp;
|
||||||
|
char *sp;
|
||||||
|
int status;
|
||||||
|
char *copypath = strdup(path);
|
||||||
|
if (NULL==copypath) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
status = 0;
|
||||||
|
pp = copypath;
|
||||||
|
while (status == 0 && (sp = strchr(pp, '/')) != 0) {
|
||||||
|
if (sp != pp) {
|
||||||
|
/* Neither root nor double slash in path */
|
||||||
|
*sp = '\0';
|
||||||
|
status = FSNODE_LOCAL_mkdir(copypath, mode);
|
||||||
|
*sp = '/';
|
||||||
|
}
|
||||||
|
pp = sp + 1;
|
||||||
|
}
|
||||||
|
if (status == 0) {
|
||||||
|
status = FSNODE_LOCAL_mkdir(path, mode);
|
||||||
|
}
|
||||||
|
free(copypath);
|
||||||
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::FSNode::FSNode(etk::UString nodeName) :
|
|
||||||
|
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "FSNode"
|
||||||
|
|
||||||
|
etk::FSNode::FSNode(const etk::UString& nodeName) :
|
||||||
m_userFileName(""),
|
m_userFileName(""),
|
||||||
m_type(etk::FSN_TYPE_UNKNOW),
|
m_type(etk::FSN_TYPE_UNKNOW),
|
||||||
m_typeNode(etk::FSN_UNKNOW),
|
m_typeNode(etk::FSN_UNKNOW),
|
||||||
@ -378,7 +408,7 @@ void etk::FSNode::SortElementList(etk::Vector<etk::FSNode *> &list)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::FSNode::PrivateSetName(etk::UString& newName)
|
void etk::FSNode::PrivateSetName(const etk::UString& newName)
|
||||||
{
|
{
|
||||||
if( NULL != m_PointerFile
|
if( NULL != m_PointerFile
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
@ -718,13 +748,10 @@ void etk::FSNode::UpdateFileSystemProperty(void)
|
|||||||
m_timeCreate = statProperty.st_ctime;
|
m_timeCreate = statProperty.st_ctime;
|
||||||
m_timeModify = statProperty.st_mtime;
|
m_timeModify = statProperty.st_mtime;
|
||||||
m_timeAccess = statProperty.st_atime;
|
m_timeAccess = statProperty.st_atime;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
All Right of the file
|
|
||||||
*/
|
|
||||||
bool etk::FSNode::SetRight(etk::FSNodeRight newRight)
|
bool etk::FSNode::SetRight(etk::FSNodeRight newRight)
|
||||||
{
|
{
|
||||||
// TODO : ...
|
// TODO : ...
|
||||||
@ -732,16 +759,11 @@ bool etk::FSNode::SetRight(etk::FSNodeRight newRight)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void etk::FSNode::SetName(const etk::UString& newName)
|
||||||
/*
|
|
||||||
Common API :
|
|
||||||
*/
|
|
||||||
void etk::FSNode::SetName(etk::UString newName)
|
|
||||||
{
|
{
|
||||||
PrivateSetName(newName);
|
PrivateSetName(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::UString etk::FSNode::GetNameFolder(void) const
|
etk::UString etk::FSNode::GetNameFolder(void) const
|
||||||
{
|
{
|
||||||
int32_t lastPos = m_systemFileName.FindBack('/');
|
int32_t lastPos = m_systemFileName.FindBack('/');
|
||||||
@ -751,7 +773,6 @@ etk::UString etk::FSNode::GetNameFolder(void) const
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::UString etk::FSNode::GetName(void) const
|
etk::UString etk::FSNode::GetName(void) const
|
||||||
{
|
{
|
||||||
etk::UString output;
|
etk::UString output;
|
||||||
@ -774,10 +795,10 @@ etk::UString etk::FSNode::GetName(void) const
|
|||||||
output = "DATA:";
|
output = "DATA:";
|
||||||
break;
|
break;
|
||||||
case etk::FSN_TYPE_USER_DATA:
|
case etk::FSN_TYPE_USER_DATA:
|
||||||
output = "USERDATA";
|
output = "USERDATA:";
|
||||||
break;
|
break;
|
||||||
case etk::FSN_TYPE_CACHE:
|
case etk::FSN_TYPE_CACHE:
|
||||||
output = "CACHE";
|
output = "CACHE:";
|
||||||
break;
|
break;
|
||||||
case etk::FSN_TYPE_THEME:
|
case etk::FSN_TYPE_THEME:
|
||||||
case etk::FSN_TYPE_THEME_DATA:
|
case etk::FSN_TYPE_THEME_DATA:
|
||||||
@ -842,10 +863,18 @@ etk::UString etk::FSNode::GetRelativeFolder(void) const
|
|||||||
|
|
||||||
bool etk::FSNode::Touch(void)
|
bool etk::FSNode::Touch(void)
|
||||||
{
|
{
|
||||||
|
//just open in write an close ==> this will update the time
|
||||||
|
if (false==FileOpenAppend()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bool ret = FileClose();
|
||||||
|
// update internal time and properties ...
|
||||||
|
UpdateFileSystemProperty();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
bool etk::FSNode::Remove(void)
|
bool etk::FSNode::Remove(void)
|
||||||
{
|
{
|
||||||
|
// TODO : ...
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint64_t etk::FSNode::TimeCreated(void) const
|
uint64_t etk::FSNode::TimeCreated(void) const
|
||||||
@ -856,7 +885,11 @@ uint64_t etk::FSNode::TimeCreated(void) const
|
|||||||
etk::UString etk::FSNode::TimeCreatedString(void) const
|
etk::UString etk::FSNode::TimeCreatedString(void) const
|
||||||
{
|
{
|
||||||
time_t tmpVal = (int32_t)m_timeCreate;
|
time_t tmpVal = (int32_t)m_timeCreate;
|
||||||
return ctime(&tmpVal);
|
etk::UString tmpTime = ctime(&tmpVal);
|
||||||
|
if (tmpTime[tmpTime.Size()-1] == '\n') {
|
||||||
|
tmpTime.Remove(tmpTime.Size()-1, 1);
|
||||||
|
}
|
||||||
|
return tmpTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t etk::FSNode::TimeModified(void) const
|
uint64_t etk::FSNode::TimeModified(void) const
|
||||||
@ -867,7 +900,11 @@ uint64_t etk::FSNode::TimeModified(void) const
|
|||||||
etk::UString etk::FSNode::TimeModifiedString(void) const
|
etk::UString etk::FSNode::TimeModifiedString(void) const
|
||||||
{
|
{
|
||||||
time_t tmpVal = (int32_t)m_timeModify;
|
time_t tmpVal = (int32_t)m_timeModify;
|
||||||
return ctime(&tmpVal);
|
etk::UString tmpTime = ctime(&tmpVal);
|
||||||
|
if (tmpTime[tmpTime.Size()-1] == '\n') {
|
||||||
|
tmpTime.Remove(tmpTime.Size()-1, 1);
|
||||||
|
}
|
||||||
|
return tmpTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t etk::FSNode::TimeAccessed(void) const
|
uint64_t etk::FSNode::TimeAccessed(void) const
|
||||||
@ -878,7 +915,11 @@ uint64_t etk::FSNode::TimeAccessed(void) const
|
|||||||
etk::UString etk::FSNode::TimeAccessedString(void) const
|
etk::UString etk::FSNode::TimeAccessedString(void) const
|
||||||
{
|
{
|
||||||
time_t tmpVal = (int32_t)m_timeAccess;
|
time_t tmpVal = (int32_t)m_timeAccess;
|
||||||
return ctime(&tmpVal);
|
etk::UString tmpTime = ctime(&tmpVal);
|
||||||
|
if (tmpTime[tmpTime.Size()-1] == '\n') {
|
||||||
|
tmpTime.Remove(tmpTime.Size()-1, 1);
|
||||||
|
}
|
||||||
|
return tmpTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1010,9 +1051,29 @@ etk::CCout& etk::operator <<(etk::CCout &os, const etk::typeNode_te &obj)
|
|||||||
/*
|
/*
|
||||||
Folder specific :
|
Folder specific :
|
||||||
*/
|
*/
|
||||||
int32_t etk::FSNode::FolderCount(void)
|
int64_t etk::FSNode::FolderCount(void)
|
||||||
{
|
{
|
||||||
return 0;
|
int64_t counter=0;
|
||||||
|
DIR *dir = NULL;
|
||||||
|
struct dirent *ent = NULL;
|
||||||
|
dir = opendir(m_systemFileName.c_str());
|
||||||
|
if (dir != NULL) {
|
||||||
|
// for each element in the drectory...
|
||||||
|
while ((ent = readdir(dir)) != NULL) {
|
||||||
|
etk::UString tmpName(ent->d_name);
|
||||||
|
if( tmpName=="."
|
||||||
|
|| tmpName==".." ) {
|
||||||
|
// do nothing ...
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// just increment counter :
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
} else {
|
||||||
|
TK_ERROR("could not open directory : \"" << *this << "\"");
|
||||||
|
}
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
@ -1238,6 +1299,27 @@ bool etk::FSNode::FileOpenWrite(void)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool etk::FSNode::FileOpenAppend(void)
|
||||||
|
{
|
||||||
|
#ifdef __TARGET_OS__Android
|
||||||
|
if( etk::FSN_TYPE_DATA == m_type
|
||||||
|
|| etk::FSN_TYPE_THEME_DATA == m_type) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (NULL != m_PointerFile) {
|
||||||
|
TK_CRITICAL("File Already open : " << *this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
FSNODE_LOCAL_mkPath(GetNameFolder().c_str() , 0777);
|
||||||
|
|
||||||
|
m_PointerFile=fopen(m_systemFileName.c_str(),"ab");
|
||||||
|
if(NULL == m_PointerFile) {
|
||||||
|
TK_ERROR("Can not find the file " << *this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
bool etk::FSNode::FileClose(void)
|
bool etk::FSNode::FileClose(void)
|
||||||
{
|
{
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
@ -1262,12 +1344,12 @@ bool etk::FSNode::FileClose(void)
|
|||||||
m_PointerFile = NULL;
|
m_PointerFile = NULL;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
char* etk::FSNode::FileGets(char * elementLine, int32_t maxData)
|
char* etk::FSNode::FileGets(char * elementLine, int64_t maxData)
|
||||||
{
|
{
|
||||||
memset(elementLine, 0, maxData);
|
memset(elementLine, 0, maxData);
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
char * element = elementLine;
|
char * element = elementLine;
|
||||||
int32_t outSize = 0;
|
int64_t outSize = 0;
|
||||||
if( etk::FSN_TYPE_DATA == m_type
|
if( etk::FSN_TYPE_DATA == m_type
|
||||||
|| etk::FSN_TYPE_THEME_DATA == m_type) {//char * tmpData = internalDataFiles[iii].data + m_readingOffset;
|
|| etk::FSN_TYPE_THEME_DATA == m_type) {//char * tmpData = internalDataFiles[iii].data + m_readingOffset;
|
||||||
if (NULL == m_zipData) {
|
if (NULL == m_zipData) {
|
||||||
@ -1312,7 +1394,7 @@ char* etk::FSNode::FileGets(char * elementLine, int32_t maxData)
|
|||||||
#endif
|
#endif
|
||||||
return fgets(elementLine, maxData, m_PointerFile);
|
return fgets(elementLine, maxData, m_PointerFile);
|
||||||
}
|
}
|
||||||
int32_t etk::FSNode::FileRead(void * data, int32_t blockSize, int32_t nbBlock)
|
int64_t etk::FSNode::FileRead(void * data, int64_t blockSize, int64_t nbBlock)
|
||||||
{
|
{
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
if( etk::FSN_TYPE_DATA == m_type
|
if( etk::FSN_TYPE_DATA == m_type
|
||||||
@ -1333,7 +1415,7 @@ int32_t etk::FSNode::FileRead(void * data, int32_t blockSize, int32_t nbBlock)
|
|||||||
#endif
|
#endif
|
||||||
return fread(data, blockSize, nbBlock, m_PointerFile);
|
return fread(data, blockSize, nbBlock, m_PointerFile);
|
||||||
}
|
}
|
||||||
int32_t etk::FSNode::FileWrite(void * data, int32_t blockSize, int32_t nbBlock)
|
int64_t etk::FSNode::FileWrite(void * data, int64_t blockSize, int64_t nbBlock)
|
||||||
{
|
{
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
if( etk::FSN_TYPE_DATA == m_type
|
if( etk::FSN_TYPE_DATA == m_type
|
||||||
@ -1344,7 +1426,7 @@ int32_t etk::FSNode::FileWrite(void * data, int32_t blockSize, int32_t nbBlock)
|
|||||||
#endif
|
#endif
|
||||||
return fwrite(data, blockSize, nbBlock, m_PointerFile);
|
return fwrite(data, blockSize, nbBlock, m_PointerFile);
|
||||||
}
|
}
|
||||||
bool etk::FSNode::FileSeek(long int offset, int origin)
|
bool etk::FSNode::FileSeek(long int offset, etk::seekNode_te origin)
|
||||||
{
|
{
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
if( etk::FSN_TYPE_DATA == m_type
|
if( etk::FSN_TYPE_DATA == m_type
|
||||||
@ -1354,10 +1436,10 @@ bool etk::FSNode::FileSeek(long int offset, int origin)
|
|||||||
}
|
}
|
||||||
int32_t positionEnd = 0;
|
int32_t positionEnd = 0;
|
||||||
switch(origin) {
|
switch(origin) {
|
||||||
case SEEK_END:
|
case etk::FSN_SEEK_END:
|
||||||
positionEnd = m_zipDataSize;
|
positionEnd = m_zipDataSize;
|
||||||
break;
|
break;
|
||||||
case SEEK_CUR:
|
case etk::FSN_SEEK_CURRENT:
|
||||||
positionEnd = m_zipReadingOffset;
|
positionEnd = m_zipReadingOffset;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1374,7 +1456,19 @@ bool etk::FSNode::FileSeek(long int offset, int origin)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
fseek(m_PointerFile, offset, origin);
|
int originFS = 0;
|
||||||
|
switch(origin) {
|
||||||
|
case etk::FSN_SEEK_END:
|
||||||
|
originFS = SEEK_END;
|
||||||
|
break;
|
||||||
|
case etk::FSN_SEEK_CURRENT:
|
||||||
|
originFS = SEEK_CUR;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
originFS = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fseek(m_PointerFile, offset, originFS);
|
||||||
if(ferror(m_PointerFile)) {
|
if(ferror(m_PointerFile)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@ -1455,4 +1549,121 @@ etk::Vector<etk::UString> etk::theme::List(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Simple direct wrapper on the FileSystem node access :
|
||||||
|
*
|
||||||
|
* -------------------------------------------------------------------------- */
|
||||||
|
bool etk::FSNodeRemove(const etk::UString& path)
|
||||||
|
{
|
||||||
|
etk::FSNode tmpNode(path);
|
||||||
|
if (false==tmpNode.Exist()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return tmpNode.Remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t etk::FSNodeGetCount(const etk::UString& 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)
|
||||||
|
{
|
||||||
|
// TODO :
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool etk::FSNodeExist(const etk::UString& path)
|
||||||
|
{
|
||||||
|
etk::FSNode tmpNode(path);
|
||||||
|
return tmpNode.Exist();
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::FSNodeRight etk::FSNodeGetRight(const etk::UString& path)
|
||||||
|
{
|
||||||
|
etk::FSNode tmpNode(path);
|
||||||
|
return tmpNode.GetRight();
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::typeNode_te etk::FSNodeGetType(const etk::UString& path)
|
||||||
|
{
|
||||||
|
etk::FSNode tmpNode(path);
|
||||||
|
return tmpNode.GetNodeType();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t etk::FSNodeGetTimeCreated(const etk::UString& path)
|
||||||
|
{
|
||||||
|
etk::FSNode tmpNode(path);
|
||||||
|
return tmpNode.TimeCreated();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t etk::FSNodeGetTimeModified(const etk::UString& path)
|
||||||
|
{
|
||||||
|
etk::FSNode tmpNode(path);
|
||||||
|
return tmpNode.TimeModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t etk::FSNodeGetTimeAccessed(const etk::UString& path)
|
||||||
|
{
|
||||||
|
etk::FSNode tmpNode(path);
|
||||||
|
return tmpNode.TimeAccessed();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t etk::FSNodeTouch(const etk::UString& path)
|
||||||
|
{
|
||||||
|
etk::FSNode tmpNode(path);
|
||||||
|
if (false==tmpNode.Exist()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return tmpNode.Touch();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool etk::FSNodeEcho(const etk::UString& path, const etk::UString& dataTowrite)
|
||||||
|
{
|
||||||
|
etk::FSNode tmpNode(path);
|
||||||
|
if (false==tmpNode.Exist()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (FSN_FOLDER==tmpNode.GetNodeType()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (false==tmpNode.FileOpenWrite()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// convert in UTF8 :
|
||||||
|
etk::Char tmpChar = dataTowrite.c_str();
|
||||||
|
int32_t nbChar = strlen(tmpChar);
|
||||||
|
if (nbChar != tmpNode.FileWrite(tmpChar, 1, nbChar)) {
|
||||||
|
tmpNode.FileClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return tmpNode.FileClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool etk::FSNodeEchoAdd(const etk::UString& path, const etk::UString& dataTowrite)
|
||||||
|
{
|
||||||
|
etk::FSNode tmpNode(path);
|
||||||
|
if (false==tmpNode.Exist()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (FSN_FOLDER==tmpNode.GetNodeType()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (false==tmpNode.FileOpenAppend()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// convert in UTF8 :
|
||||||
|
etk::Char tmpChar = dataTowrite.c_str();
|
||||||
|
int32_t nbChar = strlen(tmpChar);
|
||||||
|
if (nbChar != tmpNode.FileWrite(tmpChar, 1, nbChar)) {
|
||||||
|
tmpNode.FileClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return tmpNode.FileClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
441
etk/os/FSNode.h
441
etk/os/FSNode.h
@ -18,20 +18,28 @@
|
|||||||
|
|
||||||
namespace etk
|
namespace etk
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* List of Type that a node can have (this wrap some type that not exist on Windows)
|
||||||
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FSN_UNKNOW,
|
FSN_UNKNOW, //!< Type of the node is not known
|
||||||
FSN_BLOCK,
|
FSN_BLOCK, //!< The node is a block aceess device (Not availlable on Windows)
|
||||||
FSN_CHARACTER,
|
FSN_CHARACTER, //!< The node is a Char device type (Not availlable on Windows)
|
||||||
FSN_FOLDER,
|
FSN_FOLDER, //!< The node is a folder
|
||||||
FSN_FIFO,
|
FSN_FIFO, //!< The node is a Fifo (Not availlable on Windows)
|
||||||
FSN_LINK,
|
FSN_LINK, //!< The node is a Link
|
||||||
FSN_FILE,
|
FSN_FILE, //!< The node is a File
|
||||||
FSN_SOCKET,
|
FSN_SOCKET, //!< The node is a socket
|
||||||
} typeNode_te;
|
} 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,
|
||||||
|
FSN_SEEK_END,
|
||||||
|
FSN_SEEK_CURRENT,
|
||||||
|
} seekNode_te;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FSN_TYPE_UNKNOW,
|
FSN_TYPE_UNKNOW,
|
||||||
// user might done abstraction ==> acces of the sdcard when possible ...
|
// user might done abstraction ==> acces of the sdcard when possible ...
|
||||||
@ -104,6 +112,9 @@ namespace etk
|
|||||||
HOME:
|
HOME:
|
||||||
~
|
~
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* @brief FS node is for File system IO access This class is independent of the OS, If you acces to a file in windows, it might generate the right loke Linux (it is important to know that windows right is lighter than linux)
|
||||||
|
*/
|
||||||
class FSNode
|
class FSNode
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -113,120 +124,438 @@ namespace etk
|
|||||||
typeNode_te m_typeNode; //!< type of the current file/Folder/Link
|
typeNode_te m_typeNode; //!< type of the current file/Folder/Link
|
||||||
etk::FSNodeRight m_rights; //!< IO right of the current file
|
etk::FSNodeRight m_rights; //!< IO right of the current file
|
||||||
// specific when file Access :
|
// specific when file Access :
|
||||||
FILE * m_PointerFile;
|
FILE * m_PointerFile; //!< When reading file, this is the Real pointer access
|
||||||
uint64_t m_timeCreate;
|
uint64_t m_timeCreate; //!< Creating date of the file
|
||||||
uint64_t m_timeModify;
|
uint64_t m_timeModify; //!< Last modify time of the file
|
||||||
uint64_t m_timeAccess;
|
uint64_t m_timeAccess; //!< Last acces time of the file
|
||||||
uint32_t m_idOwner;
|
uint32_t m_idOwner; //!< Id of the owner of the Node
|
||||||
uint32_t m_idGroup;
|
uint32_t m_idGroup; //!< Id of the group of the Node
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Constructor
|
||||||
|
* @param[in] path Path of the curent file /folder ...
|
||||||
|
*/
|
||||||
|
FSNode(const etk::UString& path="~");
|
||||||
|
/**
|
||||||
|
* @brief Destructor
|
||||||
|
* @note you will have some warning if you did not close your files
|
||||||
|
*/
|
||||||
|
~FSNode(void);
|
||||||
private:
|
private:
|
||||||
etk::UString GetFileSystemName(void) const;
|
/**
|
||||||
etk::UString GetFileSystemNameTheme(void);
|
* @brief Internal methode that create the internal Real system name (transform DATA: HOME: DATA:GUI: in the real name of the files)
|
||||||
void PrivateSetName(etk::UString& newName);
|
*/
|
||||||
bool DirectExistFile(etk::UString tmpFileNameDirect, bool checkInAPKIfNeeded = false);
|
|
||||||
|
|
||||||
// Now we generate the real FS path:
|
|
||||||
void GenerateFileSystemPath(void);
|
void GenerateFileSystemPath(void);
|
||||||
// now we get all the right if the file existed:
|
/**
|
||||||
|
* @brief Update the internal data of the right type, and times
|
||||||
|
*/
|
||||||
void UpdateFileSystemProperty(void);
|
void UpdateFileSystemProperty(void);
|
||||||
|
/**
|
||||||
|
* @brief Get the Generate FileSystem name
|
||||||
|
* @return the requested filename
|
||||||
|
*/
|
||||||
|
etk::UString GetFileSystemName(void) const;
|
||||||
|
/**
|
||||||
|
* @brief Common set name of the Node (if the user decide to change the node selection
|
||||||
|
* @param[in] newName Name of the Node
|
||||||
|
*/
|
||||||
|
void PrivateSetName(const etk::UString& newName);
|
||||||
private:
|
private:
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
|
/**
|
||||||
|
* @brief Explocitly for Android that data are stored in the .apk that is a .zip not compressed
|
||||||
|
* @return true : Load is OK
|
||||||
|
* @return false : An error Occured
|
||||||
|
*/
|
||||||
bool LoadDataZip(void);
|
bool LoadDataZip(void);
|
||||||
int32_t m_idZipFile;
|
int32_t m_idZipFile;
|
||||||
char* m_zipData;
|
char* m_zipData;
|
||||||
int32_t m_zipDataSize;
|
int32_t m_zipDataSize;
|
||||||
int32_t m_zipReadingOffset;
|
int32_t m_zipReadingOffset;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FSNode(void);
|
/**
|
||||||
FSNode(etk::UString nodeName);
|
* @brief Check if the node exist.
|
||||||
~FSNode(void);
|
* @return true : The node existed.
|
||||||
/*
|
* @return false : The node does not exist.
|
||||||
All Right of the file
|
*/
|
||||||
|
bool Exist(void) const { return (m_typeNode!=etk::FSN_UNKNOW); };
|
||||||
|
/**
|
||||||
|
* @brief Get the node type
|
||||||
|
* @return the requested type, FSN_UNKNOW if it does not existed
|
||||||
|
*/
|
||||||
|
typeNode_te GetNodeType(void) const { return m_typeNode; };
|
||||||
|
/**
|
||||||
|
* @brief Get the node Right
|
||||||
|
* @return the requested right
|
||||||
|
*/
|
||||||
|
etk::FSNodeRight GetRight(void) const { return m_rights; };
|
||||||
|
/**
|
||||||
|
* @brief Set the specific right of the node
|
||||||
|
* @param[in] newRight new right to set
|
||||||
|
* @return true : action done
|
||||||
|
* @return false : action not done
|
||||||
*/
|
*/
|
||||||
bool Exist(void) { return (m_typeNode!=etk::FSN_UNKNOW); };
|
|
||||||
typeNode_te GetNodeType(void) { return m_typeNode; };
|
|
||||||
etk::FSNodeRight GetRight(void) { return m_rights; };
|
|
||||||
bool SetRight(etk::FSNodeRight newRight);
|
bool SetRight(etk::FSNodeRight newRight);
|
||||||
|
/**
|
||||||
/*
|
* @brief Change the Node seeing (not rename the node, for this @ref Move)
|
||||||
Common API :
|
* @param[in] newName New node name to show
|
||||||
|
* @return true : action done
|
||||||
|
* @return false : action not done
|
||||||
|
*/
|
||||||
|
void SetName(const etk::UString& newName);
|
||||||
|
/**
|
||||||
|
* @brief Get the current folder of the Node. (file system name)
|
||||||
|
* @return the common name define (like /xxxxx/xxxxx/ or c:/xxxxx/xxxxx/)
|
||||||
|
* @note Auto remove of ../../../ and //
|
||||||
*/
|
*/
|
||||||
void SetName(etk::UString newName);
|
|
||||||
etk::UString GetNameFolder(void) const;
|
etk::UString GetNameFolder(void) const;
|
||||||
|
/**
|
||||||
|
* @brief Get the current compleate node name (file system name)
|
||||||
|
* @return All the user name definition (like /xxxxx/xxxxx/myFile.kkk or c:/xxxxx/xxxxx/myFile.kkk)
|
||||||
|
* @note Auto remove of ../../../ and //
|
||||||
|
*/
|
||||||
etk::UString GetName(void) const;
|
etk::UString GetName(void) const;
|
||||||
|
/**
|
||||||
|
* @brief Get the file or current folder name (if it was a folder)
|
||||||
|
* @return the name of the node (like myFile.kkk)
|
||||||
|
*/
|
||||||
etk::UString GetNameFile(void) const;
|
etk::UString GetNameFile(void) const;
|
||||||
|
/**
|
||||||
|
* @brief Get the current folder of the Node.
|
||||||
|
* @return the common name define (like DATA:xxxxx/xxxxx/)
|
||||||
|
* @note Auto remove of ../../../ and //
|
||||||
|
*/
|
||||||
etk::UString GetRelativeFolder(void) const;
|
etk::UString GetRelativeFolder(void) const;
|
||||||
|
/**
|
||||||
|
* @brief update the Time of the file with the current time
|
||||||
|
* @return true : action done
|
||||||
|
* @return false : action not done
|
||||||
|
*/
|
||||||
bool Touch(void);
|
bool Touch(void);
|
||||||
FSNType_te GetTypeAccess(void) { return m_type; };
|
/**
|
||||||
|
* @brief Get the node type (DATA/DIRECT...)
|
||||||
|
* @return the requested type
|
||||||
|
*/
|
||||||
|
FSNType_te GetTypeAccess(void) const { return m_type; };
|
||||||
|
/**
|
||||||
|
* @brief Remove the current node ( if folder, this remove all subfolder but not the Link subfolder)
|
||||||
|
* @return true : action done
|
||||||
|
* @return false : action not done
|
||||||
|
*/
|
||||||
bool Remove(void);
|
bool Remove(void);
|
||||||
// File time properties
|
/**
|
||||||
|
* @brief Get the creating time of the File
|
||||||
|
* @return The time requested
|
||||||
|
*/
|
||||||
uint64_t TimeCreated(void) const;
|
uint64_t TimeCreated(void) const;
|
||||||
|
/**
|
||||||
|
* @brief Get the creating time of the File
|
||||||
|
* @return The time requested (in string)
|
||||||
|
*/
|
||||||
etk::UString TimeCreatedString(void) const;
|
etk::UString TimeCreatedString(void) const;
|
||||||
|
/**
|
||||||
|
* @brief Get the modifying time of the File
|
||||||
|
* @return The time requested
|
||||||
|
*/
|
||||||
uint64_t TimeModified(void) const;
|
uint64_t TimeModified(void) const;
|
||||||
|
/**
|
||||||
|
* @brief Get the modifying time of the File
|
||||||
|
* @return The time requested (in string)
|
||||||
|
*/
|
||||||
etk::UString TimeModifiedString(void) const;
|
etk::UString TimeModifiedString(void) const;
|
||||||
|
/**
|
||||||
|
* @brief Get the Accessed time of the File
|
||||||
|
* @return The time requested
|
||||||
|
*/
|
||||||
uint64_t TimeAccessed(void) const;
|
uint64_t TimeAccessed(void) const;
|
||||||
|
/**
|
||||||
|
* @brief Get the Accessed time of the File
|
||||||
|
* @return The time requested (in string)
|
||||||
|
*/
|
||||||
etk::UString TimeAccessedString(void) const;
|
etk::UString TimeAccessedString(void) const;
|
||||||
|
/**
|
||||||
/*
|
* @brief copy the other FSnode ==> for vector
|
||||||
Operator :
|
* @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
|
||||||
|
* @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
|
||||||
|
* @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
|
||||||
|
* @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);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Folder specific :
|
* @brief Count the number of subFolder in the curent Folder
|
||||||
|
* @return >=0 nb of subElement
|
||||||
|
* @return -1 an error occured ==> not a folder ???
|
||||||
|
*/
|
||||||
|
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 ~
|
||||||
|
* @return The requested list
|
||||||
*/
|
*/
|
||||||
int32_t FolderCount(void);
|
|
||||||
etk::Vector<etk::FSNode *> FolderGetSubList(bool showHidenFile=true,
|
etk::Vector<etk::FSNode *> FolderGetSubList(bool showHidenFile=true,
|
||||||
bool getFolderAndOther=true,
|
bool getFolderAndOther=true,
|
||||||
bool getFile=true,
|
bool getFile=true,
|
||||||
bool temporaryFile=true);
|
bool temporaryFile=true);
|
||||||
etk::FSNode FolderGetParent(void); // ordered by name ...
|
/**
|
||||||
|
* @brief Get the father node of this node
|
||||||
|
* @return The requested node
|
||||||
|
*/
|
||||||
|
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)
|
||||||
|
*/
|
||||||
void FolderGetRecursiveFiles(etk::Vector<etk::UString>& output);
|
void FolderGetRecursiveFiles(etk::Vector<etk::UString>& output);
|
||||||
/*
|
/**
|
||||||
File Specific :
|
* @brief Check if the file have an extention ( ***.ccc)
|
||||||
|
* @return true The file have an extention.
|
||||||
|
* @return false The file have NO extention.
|
||||||
*/
|
*/
|
||||||
bool FileHasExtention(void);
|
bool FileHasExtention(void);
|
||||||
|
/**
|
||||||
|
* @brief Get the extention of the Node
|
||||||
|
* @return the requested extention
|
||||||
|
*/
|
||||||
etk::UString FileGetExtention(void);
|
etk::UString FileGetExtention(void);
|
||||||
|
/**
|
||||||
|
* @brief Get the File size
|
||||||
|
* @return the requested size
|
||||||
|
*/
|
||||||
uint64_t FileSize(void);
|
uint64_t FileSize(void);
|
||||||
|
/**
|
||||||
|
* @brief Open the file in Read mode
|
||||||
|
* @return true : action done
|
||||||
|
* @return false : action not done
|
||||||
|
*/
|
||||||
bool FileOpenRead(void);
|
bool FileOpenRead(void);
|
||||||
|
/**
|
||||||
|
* @brief Open the file in write Mode
|
||||||
|
* @note You can not do it with the DATA: file ==> this is not allowed in some Board like Android)
|
||||||
|
* @return true : action done
|
||||||
|
* @return false : action not done
|
||||||
|
*/
|
||||||
bool FileOpenWrite(void);
|
bool FileOpenWrite(void);
|
||||||
|
/**
|
||||||
|
* @brief Open the file in write Append Mode
|
||||||
|
* @note You can not do it with the DATA: file ==> this is not allowed in some Board like Android)
|
||||||
|
* @return true : action done
|
||||||
|
* @return false : action not done
|
||||||
|
*/
|
||||||
|
bool FileOpenAppend(void);
|
||||||
|
/**
|
||||||
|
* @brief Close the cuurent file
|
||||||
|
* @return true : action done
|
||||||
|
* @return false : action not done
|
||||||
|
*/
|
||||||
bool FileClose(void);
|
bool FileClose(void);
|
||||||
char* FileGets(char * elementLine, int32_t maxData);
|
/**
|
||||||
// TODO : Set the return and the size of block in 64 bits
|
* @brief Get the pointer on the start line and the next line (or null)
|
||||||
int32_t FileRead(void * data, int32_t blockSize, int32_t nbBlock);
|
* @param[in,out] elementLine Pointer to an array of chars where the string read is copied.
|
||||||
int32_t FileWrite(void * data, int32_t blockSize, int32_t nbBlock);
|
* @param[in] maxData Maximum number of characters to be copied into str (including the terminating null-character).
|
||||||
bool FileSeek(long int offset, int origin);
|
* @return the pointer on the end of the cuurent line.
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
* @return Number of element read (in block number)
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
* @return Number of element written (in block number)
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
* @return true : action done
|
||||||
|
* @return false : action not done
|
||||||
|
*/
|
||||||
|
bool FileSeek(long int offset, etk::seekNode_te origin);
|
||||||
|
/**
|
||||||
|
* @brief Flush the current file
|
||||||
|
*/
|
||||||
void FileFlush(void);
|
void FileFlush(void);
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Order the list of subnode the folder first and the alphabetical 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
|
||||||
|
*/
|
||||||
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
|
||||||
|
*/
|
||||||
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
|
||||||
|
*/
|
||||||
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
|
||||||
|
*/
|
||||||
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/"
|
||||||
|
*/
|
||||||
etk::UString GetUserHomeFolder(void);
|
etk::UString GetUserHomeFolder(void);
|
||||||
|
/**
|
||||||
|
* @brief Get the folder of the Program is running
|
||||||
|
* @return the basic folder name (ex : run ./appl in the pwd=/home/machin/sousFolder ==> this return the pwd folder)
|
||||||
|
*/
|
||||||
etk::UString GetUserRunFolder(void);
|
etk::UString GetUserRunFolder(void);
|
||||||
|
|
||||||
namespace theme
|
namespace theme
|
||||||
{
|
{
|
||||||
// TODO : Add an INIT ...
|
// TODO : Add an INIT ...
|
||||||
// set the Folder of a subset of a theme ...
|
/**
|
||||||
|
* @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/")
|
||||||
|
*/
|
||||||
void SetName(etk::UString refName, etk::UString folderName);
|
void SetName(etk::UString refName, etk::UString folderName);
|
||||||
// get the folder from a Reference theme
|
/**
|
||||||
|
* @brief get the folder from a Reference theme
|
||||||
|
* @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);
|
||||||
// get the list of all the theme folder availlable in the user Home/appl
|
/**
|
||||||
|
* @brief Get the list of all the theme folder availlable in the user Home/appl
|
||||||
|
* @return The list of elements
|
||||||
|
*/
|
||||||
etk::Vector<etk::UString> List(void);
|
etk::Vector<etk::UString> List(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Simple access for : Remove folder and subFolder, files pipes ...
|
||||||
|
* @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);
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
* @return number of File inside
|
||||||
|
* @return -1 : An error occured
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
* @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);
|
||||||
|
/**
|
||||||
|
* @brief Simple access for : chexk the exestance of an element
|
||||||
|
* @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);
|
||||||
|
/**
|
||||||
|
* @brief Simple access for : Get right of the current 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);
|
||||||
|
/**
|
||||||
|
* @brief Simple access for : Get type of the current 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);
|
||||||
|
/**
|
||||||
|
* @brief Simple access for : Getting creation time of the current 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);
|
||||||
|
/**
|
||||||
|
* @brief Simple access for : Getting Modification time of the current 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);
|
||||||
|
/**
|
||||||
|
* @brief Simple access for : Getting Accessing time of the current 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);
|
||||||
|
/**
|
||||||
|
* @brief Simple access for : Update Modification time with the current time 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 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
|
||||||
|
* @return true : Action done corectly
|
||||||
|
* @return false : An error occured
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
* @return true : Action done corectly
|
||||||
|
* @return false : An error occured
|
||||||
|
*/
|
||||||
|
bool FSNodeEchoAdd(const etk::UString& path, const etk::UString& dataTowrite);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user