[DEV] Add capacity to the etk::FSNode ==> all is not good, but it is a good start
This commit is contained in:
parent
40dc60eb8a
commit
575ef0de03
File diff suppressed because it is too large
Load Diff
@ -26,6 +26,7 @@
|
||||
#define __ETK_FILE_SYSTEM_NODE_H__
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <etk/os/FSNodeRight.h>
|
||||
|
||||
#define MAX_FILE_NAME (10240)
|
||||
|
||||
@ -33,27 +34,20 @@
|
||||
|
||||
namespace etk
|
||||
{
|
||||
// Right Flags :
|
||||
enum {
|
||||
RIGHT_OTHER_EXECUTE = 1 << 0,
|
||||
RIGHT_OTHER_WRITE = 1 << 1,
|
||||
RIGHT_OTHER_READ = 1 << 2,
|
||||
RIGHT_GROUP_EXECUTE = 1 << 3,
|
||||
RIGHT_GROUP_WRITE = 1 << 4,
|
||||
RIGHT_GROUP_READ = 1 << 5,
|
||||
RIGHT_USER_EXECUTE = 1 << 6,
|
||||
RIGHT_USER_WRITE = 1 << 7,
|
||||
RIGHT_USER_READ = 1 << 8,
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
FSN_UNKNOW,
|
||||
FSN_BLOCK,
|
||||
FSN_CHARACTER,
|
||||
FSN_FOLDER,
|
||||
FSN_FILE,
|
||||
FSN_FIFO,
|
||||
FSN_LINK,
|
||||
FSN_FILE,
|
||||
FSN_SOCKET,
|
||||
} typeNode_te;
|
||||
|
||||
|
||||
etk::CCout& operator <<(etk::CCout &os, const etk::typeNode_te &obj);
|
||||
|
||||
typedef enum {
|
||||
FSN_TYPE_UNKNOW,
|
||||
// user might done abstraction ==> acces of the sdcard when possible ...
|
||||
@ -93,10 +87,7 @@ namespace etk
|
||||
// - try on FSN_TYPE_DATA/theme/default/xxx
|
||||
// - try on FSN_TYPE_EWOL_DATA/theme/default/xxx ==> later when the lib will be accessible in packages
|
||||
FSN_TYPE_THEME,
|
||||
FSN_TYPE_THEME__USER_THEME,
|
||||
FSN_TYPE_THEME__USER_DEFAULT,
|
||||
FSN_TYPE_THEME__APPL_THEME,
|
||||
FSN_TYPE_THEME__APPL_DEFAULT,
|
||||
FSN_TYPE_THEME_DATA
|
||||
} FSNType_te;
|
||||
|
||||
etk::CCout& operator <<(etk::CCout &os, const etk::FSNType_te &obj);
|
||||
@ -133,17 +124,28 @@ namespace etk
|
||||
{
|
||||
private:
|
||||
etk::UString m_userFileName; //!< the name requested by the User
|
||||
etk::UString m_systemFileName; //!< the compleate filename for the system
|
||||
FSNType_te m_type; //!< the Type of data requested by the User
|
||||
typeNode_te m_typeNode; //!< type of the current file/Folder/Link
|
||||
//etk::UString m_realFileSystemName; //!< the real FS name
|
||||
uint32_t m_rights; //!< IO right of the current file
|
||||
etk::FSNodeRight m_rights; //!< IO right of the current file
|
||||
// specific when file Access :
|
||||
FILE * m_PointerFile;
|
||||
uint64_t m_timeCreate;
|
||||
uint64_t m_timeModify;
|
||||
uint64_t m_timeAccess;
|
||||
uint32_t m_idOwner;
|
||||
uint32_t m_idGroup;
|
||||
private:
|
||||
etk::UString GetFileSystemName(void) const;
|
||||
etk::UString GetFileSystemNameTheme(void);
|
||||
void PrivateSetName(etk::UString& newName);
|
||||
bool DirectExistFile(etk::UString tmpFileNameDirect, bool checkInAPKIfNeeded = false);
|
||||
|
||||
// Now we generate the real FS path:
|
||||
void GenerateFileSystemPath(void);
|
||||
// now we get all the right if the file existed:
|
||||
void UpdateFileSystemProperty(void);
|
||||
|
||||
private:
|
||||
#ifdef __TARGET_OS__Android
|
||||
bool LoadDataZip(void);
|
||||
@ -160,32 +162,10 @@ namespace etk
|
||||
/*
|
||||
All Right of the file
|
||||
*/
|
||||
bool Exist(void);
|
||||
bool IsFile(void);
|
||||
bool IsFolder(void);
|
||||
bool IsLink(void);
|
||||
// User
|
||||
bool IsUserReadable(void);
|
||||
bool IsUserWritable(void);
|
||||
bool IsUserRunable(void);
|
||||
void SetUserReadable(bool newStatus);
|
||||
void SetUserWritable(bool newStatus);
|
||||
void SetUserRunable(bool newStatus);
|
||||
// group
|
||||
bool IsGroupReadable(void);
|
||||
bool IsGroupWritable(void);
|
||||
bool IsGroupRunable(void);
|
||||
void SetGroupReadable(bool newStatus);
|
||||
void SetGroupWritable(bool newStatus);
|
||||
void SetGroupRunable(bool newStatus);
|
||||
// other
|
||||
bool IsOtherReadable(void);
|
||||
bool IsOtherWritable(void);
|
||||
bool IsOtherRunable(void);
|
||||
void SetOtherReadable(bool newStatus);
|
||||
void SetOtherWritable(bool newStatus);
|
||||
void SetOtherRunable(bool newStatus);
|
||||
|
||||
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);
|
||||
|
||||
/*
|
||||
Common API :
|
||||
@ -198,8 +178,13 @@ namespace etk
|
||||
bool Touch(void);
|
||||
FSNType_te GetTypeAccess(void) { return m_type; };
|
||||
bool Remove(void);
|
||||
uint64_t TimeCreated(void);
|
||||
uint64_t TimeModified(void);
|
||||
// File time properties
|
||||
uint64_t TimeCreated(void) const;
|
||||
etk::UString TimeCreatedString(void) const;
|
||||
uint64_t TimeModified(void) const;
|
||||
etk::UString TimeModifiedString(void) const;
|
||||
uint64_t TimeAccessed(void) const;
|
||||
etk::UString TimeAccessedString(void) const;
|
||||
|
||||
/*
|
||||
Operator :
|
||||
@ -212,16 +197,19 @@ namespace etk
|
||||
/*
|
||||
Folder specific :
|
||||
*/
|
||||
int32_t FolderCount(void);
|
||||
etk::Vector<etk::FSNode> FolderGetSubList(void);
|
||||
etk::FSNode FolderGetParent(void); // ordered by name ...
|
||||
int32_t FolderCount(void);
|
||||
etk::Vector<etk::FSNode *> FolderGetSubList(bool showHidenFile=true,
|
||||
bool getFolderAndOther=true,
|
||||
bool getFile=true,
|
||||
bool temporaryFile=true);
|
||||
etk::FSNode FolderGetParent(void); // ordered by name ...
|
||||
|
||||
/*
|
||||
File Specific :
|
||||
*/
|
||||
bool FileHasExtention(void);
|
||||
etk::UString FileGetExtention(void);
|
||||
int32_t FileSize(void);
|
||||
uint64_t FileSize(void);
|
||||
bool FileOpenRead(void);
|
||||
bool FileOpenWrite(void);
|
||||
bool FileClose(void);
|
||||
|
252
Sources/libetk/etk/os/FSNodeRight.cpp
Normal file
252
Sources/libetk/etk/os/FSNodeRight.cpp
Normal file
@ -0,0 +1,252 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file etk/os/FSNodeRight.cpp
|
||||
* @brief Ewol Tool Kit : File System node access abstraction (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 2/11/2012
|
||||
* @par Project
|
||||
* Ewol TK
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <etk/DebugInternal.h>
|
||||
#include <etk/os/FSNodeRight.h>
|
||||
|
||||
// Right Flags :
|
||||
enum {
|
||||
RIGHT_OTHER_EXECUTE = 1 << 0,
|
||||
RIGHT_OTHER_WRITE = 1 << 1,
|
||||
RIGHT_OTHER_READ = 1 << 2,
|
||||
RIGHT_GROUP_EXECUTE = 1 << 3,
|
||||
RIGHT_GROUP_WRITE = 1 << 4,
|
||||
RIGHT_GROUP_READ = 1 << 5,
|
||||
RIGHT_USER_EXECUTE = 1 << 6,
|
||||
RIGHT_USER_WRITE = 1 << 7,
|
||||
RIGHT_USER_READ = 1 << 8,
|
||||
};
|
||||
|
||||
etk::FSNodeRight::FSNodeRight(void) :
|
||||
m_rights(0)
|
||||
{
|
||||
|
||||
}
|
||||
etk::FSNodeRight::FSNodeRight(int16_t newRight) :
|
||||
m_rights(newRight&0x01FF)
|
||||
{
|
||||
|
||||
}
|
||||
// copy operator :
|
||||
const etk::FSNodeRight& etk::FSNodeRight::operator= (const etk::FSNodeRight &obj )
|
||||
{
|
||||
m_rights = obj.m_rights;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// set right :
|
||||
const etk::FSNodeRight& etk::FSNodeRight::operator= (const int32_t newVal )
|
||||
{
|
||||
m_rights = newVal&0x01FF;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// User
|
||||
bool etk::FSNodeRight::IsUserReadable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_USER_READ)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::FSNodeRight::IsUserWritable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_USER_WRITE)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::FSNodeRight::IsUserRunable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_USER_EXECUTE)!=0)?true:false;
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetUserReadable(bool newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_USER_READ);
|
||||
if (true == newStatus) {
|
||||
m_rights |= RIGHT_USER_READ;
|
||||
}
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetUserWritable(bool newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_USER_WRITE);
|
||||
if (true == newStatus) {
|
||||
m_rights |= RIGHT_USER_WRITE;
|
||||
}
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetUserRunable(bool newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_USER_EXECUTE);
|
||||
if (true == newStatus) {
|
||||
m_rights |= RIGHT_USER_EXECUTE;
|
||||
}
|
||||
}
|
||||
|
||||
// group
|
||||
bool etk::FSNodeRight::IsGroupReadable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_GROUP_READ)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::FSNodeRight::IsGroupWritable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_GROUP_WRITE)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::FSNodeRight::IsGroupRunable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_GROUP_EXECUTE)!=0)?true:false;
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetGroupReadable(bool newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_READ);
|
||||
if (true == newStatus) {
|
||||
m_rights |= RIGHT_GROUP_READ;
|
||||
}
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetGroupWritable(bool newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_WRITE);
|
||||
if (true == newStatus) {
|
||||
m_rights |= RIGHT_GROUP_WRITE;
|
||||
}
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetGroupRunable(bool newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_EXECUTE);
|
||||
if (true == newStatus) {
|
||||
m_rights |= RIGHT_GROUP_EXECUTE;
|
||||
}
|
||||
}
|
||||
|
||||
// other
|
||||
bool etk::FSNodeRight::IsOtherReadable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_OTHER_READ)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::FSNodeRight::IsOtherWritable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_OTHER_WRITE)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::FSNodeRight::IsOtherRunable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_OTHER_EXECUTE)!=0)?true:false;
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetOtherReadable(bool newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_READ);
|
||||
if (true == newStatus) {
|
||||
m_rights |= RIGHT_OTHER_READ;
|
||||
}
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetOtherWritable(bool newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_WRITE);
|
||||
if (true == newStatus) {
|
||||
m_rights |= RIGHT_OTHER_WRITE;
|
||||
}
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetOtherRunable(bool newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_EXECUTE);
|
||||
if (true == newStatus) {
|
||||
m_rights |= RIGHT_OTHER_EXECUTE;
|
||||
}
|
||||
}
|
||||
etk::UString etk::FSNodeRight::GetRight(void) const
|
||||
{
|
||||
etk::UString tmp;
|
||||
if (true==IsUserReadable()) {
|
||||
tmp += "r";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsUserWritable()) {
|
||||
tmp += "w";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsUserRunable()) {
|
||||
tmp += "x";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsGroupReadable()) {
|
||||
tmp += "r";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsGroupWritable()) {
|
||||
tmp += "w";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsGroupRunable()) {
|
||||
tmp += "x";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsOtherReadable()) {
|
||||
tmp += "r";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsOtherWritable()) {
|
||||
tmp += "w";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsOtherRunable()) {
|
||||
tmp += "x";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
etk::CCout& etk::operator <<(etk::CCout &os, const etk::FSNodeRight &obj)
|
||||
{
|
||||
os << obj.GetRight();
|
||||
return os;
|
||||
};
|
||||
|
74
Sources/libetk/etk/os/FSNodeRight.h
Normal file
74
Sources/libetk/etk/os/FSNodeRight.h
Normal file
@ -0,0 +1,74 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file etk/os/FSNodeRight.h
|
||||
* @brief Ewol Tool Kit : File System node access abstraction (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 2/11/2012
|
||||
* @par Project
|
||||
* Ewol TK
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __ETK_FILE_SYSTEM_NODE_RIGHT_H__
|
||||
#define __ETK_FILE_SYSTEM_NODE_RIGHT_H__
|
||||
|
||||
#include <etk/UString.h>
|
||||
|
||||
namespace etk
|
||||
{
|
||||
class FSNodeRight
|
||||
{
|
||||
private:
|
||||
uint16_t m_rights;
|
||||
public:
|
||||
FSNodeRight(void);
|
||||
FSNodeRight(int16_t newRight);
|
||||
~FSNodeRight(void) { };
|
||||
// copy operator :
|
||||
const etk::FSNodeRight& operator= (const etk::FSNodeRight &obj );
|
||||
// set right :
|
||||
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);
|
||||
// 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);
|
||||
// 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);
|
||||
|
||||
etk::UString GetRight(void) const;
|
||||
};
|
||||
etk::CCout& operator <<(etk::CCout &os, const etk::FSNodeRight &obj);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -18,6 +18,7 @@ FILE_LIST+= \
|
||||
|
||||
FILE_LIST+= \
|
||||
etk/os/FSNode.cpp \
|
||||
etk/os/FSNodeRight.cpp \
|
||||
etk/os/Memory.cpp \
|
||||
|
||||
|
||||
|
@ -334,7 +334,7 @@ bool ewol::resource::Keep(etk::UString& filename, ewol::TextureFile*& object, et
|
||||
TmpFilename += "x";
|
||||
TmpFilename += size2.y;
|
||||
|
||||
EWOL_INFO("KEEP : TectureFile : file : \"" << TmpFilename << "\" basic size=" << size);
|
||||
EWOL_INFO("KEEP : TextureFile : file : \"" << TmpFilename << "\" basic size=" << size);
|
||||
object = static_cast<ewol::TextureFile*>(LocalKeep(TmpFilename));
|
||||
if (NULL != object) {
|
||||
return true;
|
||||
|
@ -125,10 +125,11 @@ int32_t ewol::Program::GetAttribute(etk::UString tmpElement)
|
||||
tmp.m_name = tmpElement;
|
||||
tmp.m_isAttribute = true;
|
||||
tmp.m_elementId = glGetAttribLocation(m_program, tmp.m_name.c_str());
|
||||
tmp.m_isLinked = true;
|
||||
if (tmp.m_elementId<0) {
|
||||
checkGlError("glGetAttribLocation", __LINE__);
|
||||
EWOL_INFO("glGetAttribLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
|
||||
return -1;
|
||||
EWOL_WARNING("glGetAttribLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
|
||||
tmp.m_isLinked = false;
|
||||
}
|
||||
m_elementList.PushBack(tmp);
|
||||
return m_elementList.Size()-1;
|
||||
@ -148,10 +149,11 @@ int32_t ewol::Program::GetUniform(etk::UString tmpElement)
|
||||
tmp.m_name = tmpElement;
|
||||
tmp.m_isAttribute = false;
|
||||
tmp.m_elementId = glGetUniformLocation(m_program, tmp.m_name.c_str());
|
||||
tmp.m_isLinked = true;
|
||||
if (tmp.m_elementId<0) {
|
||||
checkGlError("glGetUniformLocation", __LINE__);
|
||||
EWOL_ERROR("glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
|
||||
return -1;
|
||||
EWOL_WARNING("glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
|
||||
tmp.m_isLinked = false;
|
||||
}
|
||||
m_elementList.PushBack(tmp);
|
||||
return m_elementList.Size()-1;
|
||||
@ -197,15 +199,19 @@ void ewol::Program::UpdateContext(void)
|
||||
for(int32_t iii=0; iii<m_elementList.Size(); iii++) {
|
||||
if (true==m_elementList[iii].m_isAttribute) {
|
||||
m_elementList[iii].m_elementId = glGetAttribLocation(m_program, m_elementList[iii].m_name.c_str());
|
||||
m_elementList[iii].m_isLinked = true;
|
||||
if (m_elementList[iii].m_elementId<0) {
|
||||
m_elementList[iii].m_isLinked = false;
|
||||
checkGlError("glGetAttribLocation", __LINE__);
|
||||
EWOL_ERROR("glGetAttribLocation(\"" << m_elementList[iii].m_name << "\") = " << m_elementList[iii].m_elementId);
|
||||
EWOL_WARNING("glGetAttribLocation(\"" << m_elementList[iii].m_name << "\") = " << m_elementList[iii].m_elementId);
|
||||
}
|
||||
} else {
|
||||
m_elementList[iii].m_elementId = glGetUniformLocation(m_program, m_elementList[iii].m_name.c_str());
|
||||
m_elementList[iii].m_isLinked = true;
|
||||
if (m_elementList[iii].m_elementId<0) {
|
||||
m_elementList[iii].m_isLinked = false;
|
||||
checkGlError("glGetUniformLocation", __LINE__);
|
||||
EWOL_ERROR("glGetUniformLocation(\"" << m_elementList[iii].m_name << "\") = " << m_elementList[iii].m_elementId);
|
||||
EWOL_WARNING("glGetUniformLocation(\"" << m_elementList[iii].m_name << "\") = " << m_elementList[iii].m_elementId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -291,6 +297,9 @@ void ewol::Program::SendAttribute(int32_t idElem, int32_t nbElement, void* point
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glVertexAttribPointer(m_elementList[idElem].m_elementId, // attribute ID of OpenGL
|
||||
nbElement, // number of elements per vertex, here (r,g,b,a)
|
||||
GL_FLOAT, // the type of each element
|
||||
@ -309,6 +318,9 @@ void ewol::Program::UniformMatrix4fv(int32_t idElem, int32_t nbElement, etk::Mat
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
// note : Android des not supported the transposition of the matrix, then we will done it oursef:
|
||||
if (true == transpose) {
|
||||
_matrix.Transpose();
|
||||
@ -325,6 +337,9 @@ void ewol::Program::Uniform1f(int32_t idElem, float value1)
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glUniform1f(m_elementList[idElem].m_elementId, value1);
|
||||
checkGlError("glUniform1f", __LINE__);
|
||||
}
|
||||
@ -334,6 +349,9 @@ void ewol::Program::Uniform2f(int32_t idElem, float value1, float value2)
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glUniform2f(m_elementList[idElem].m_elementId, value1, value2);
|
||||
checkGlError("glUniform2f", __LINE__);
|
||||
}
|
||||
@ -343,6 +361,9 @@ void ewol::Program::Uniform3f(int32_t idElem, float value1, float value2, float
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glUniform3f(m_elementList[idElem].m_elementId, value1, value2, value3);
|
||||
checkGlError("glUniform3f", __LINE__);
|
||||
}
|
||||
@ -352,6 +373,9 @@ void ewol::Program::Uniform4f(int32_t idElem, float value1, float value2, float
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glUniform4f(m_elementList[idElem].m_elementId, value1, value2, value3, value4);
|
||||
checkGlError("glUniform4f", __LINE__);
|
||||
}
|
||||
@ -365,6 +389,9 @@ void ewol::Program::Uniform1i(int32_t idElem, int32_t value1)
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glUniform1i(m_elementList[idElem].m_elementId, value1);
|
||||
checkGlError("glUniform1i", __LINE__);
|
||||
}
|
||||
@ -374,6 +401,9 @@ void ewol::Program::Uniform2i(int32_t idElem, int32_t value1, int32_t value2)
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glUniform2i(m_elementList[idElem].m_elementId, value1, value2);
|
||||
checkGlError("glUniform2i", __LINE__);
|
||||
}
|
||||
@ -383,6 +413,9 @@ void ewol::Program::Uniform3i(int32_t idElem, int32_t value1, int32_t value2, in
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glUniform3i(m_elementList[idElem].m_elementId, value1, value2, value3);
|
||||
checkGlError("glUniform3i", __LINE__);
|
||||
}
|
||||
@ -392,6 +425,9 @@ void ewol::Program::Uniform4i(int32_t idElem, int32_t value1, int32_t value2, in
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glUniform4i(m_elementList[idElem].m_elementId, value1, value2, value3, value4);
|
||||
checkGlError("glUniform4i", __LINE__);
|
||||
}
|
||||
@ -405,6 +441,9 @@ void ewol::Program::Uniform1fv(int32_t idElem, int32_t nbElement, float *value)
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
if (0==nbElement) {
|
||||
EWOL_ERROR("No element to send at open GL ...");
|
||||
return;
|
||||
@ -422,6 +461,9 @@ void ewol::Program::Uniform2fv(int32_t idElem, int32_t nbElement, float *value)
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
if (0==nbElement) {
|
||||
EWOL_ERROR("No element to send at open GL ...");
|
||||
return;
|
||||
@ -439,6 +481,9 @@ void ewol::Program::Uniform3fv(int32_t idElem, int32_t nbElement, float *value)
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
if (0==nbElement) {
|
||||
EWOL_ERROR("No element to send at open GL ...");
|
||||
return;
|
||||
@ -456,6 +501,9 @@ void ewol::Program::Uniform4fv(int32_t idElem, int32_t nbElement, float *value)
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
if (0==nbElement) {
|
||||
EWOL_ERROR("No element to send at open GL ...");
|
||||
return;
|
||||
@ -476,6 +524,9 @@ void ewol::Program::Uniform1iv(int32_t idElem, int32_t nbElement, int32_t *value
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
if (0==nbElement) {
|
||||
EWOL_ERROR("No element to send at open GL ...");
|
||||
return;
|
||||
@ -493,6 +544,9 @@ void ewol::Program::Uniform2iv(int32_t idElem, int32_t nbElement, int32_t *value
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
if (0==nbElement) {
|
||||
EWOL_ERROR("No element to send at open GL ...");
|
||||
return;
|
||||
@ -510,6 +564,9 @@ void ewol::Program::Uniform3iv(int32_t idElem, int32_t nbElement, int32_t *value
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
if (0==nbElement) {
|
||||
EWOL_ERROR("No element to send at open GL ...");
|
||||
return;
|
||||
@ -527,6 +584,9 @@ void ewol::Program::Uniform4iv(int32_t idElem, int32_t nbElement, int32_t *value
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
if (0==nbElement) {
|
||||
EWOL_ERROR("No element to send at open GL ...");
|
||||
return;
|
||||
@ -553,6 +613,9 @@ void ewol::Program::SetTexture0(int32_t idElem, GLint textureOpenGlID)
|
||||
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
checkGlError("glEnable", __LINE__);
|
||||
|
@ -39,6 +39,7 @@
|
||||
etk::UString m_name;
|
||||
GLint m_elementId;
|
||||
bool m_isAttribute;
|
||||
bool m_isLinked;
|
||||
};
|
||||
|
||||
class Program : public ewol::Resource
|
||||
|
@ -42,19 +42,12 @@ ewol::Shader::Shader(etk::UString& filename):
|
||||
EWOL_DEBUG("OGL : load SHADER \"" << filename << "\"");
|
||||
// load data from file "all the time ..."
|
||||
|
||||
etk::FSNode file(m_name);
|
||||
if (false == file.Exist()) {
|
||||
EWOL_ERROR("File does not Exist : \"" << file << "\"");
|
||||
return;
|
||||
}
|
||||
|
||||
etk::UString fileExtention = file.FileGetExtention();
|
||||
if (fileExtention == "frag") {
|
||||
if (true == m_name.EndWith(".frag") ) {
|
||||
m_type = GL_FRAGMENT_SHADER;
|
||||
} else if (fileExtention == "vert") {
|
||||
} else if (true == m_name.EndWith(".vert") ) {
|
||||
m_type = GL_VERTEX_SHADER;
|
||||
} else {
|
||||
EWOL_ERROR("File does not have extention \".vert\" for Vertex Shader or \".frag\" for Fragment Shader. but : \"" << fileExtention << "\"");
|
||||
EWOL_ERROR("File does not have extention \".vert\" for Vertex Shader or \".frag\" for Fragment Shader. but : \"" << m_name << "\"");
|
||||
return;
|
||||
}
|
||||
Reload();
|
||||
@ -143,7 +136,7 @@ void ewol::Shader::Reload(void)
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t fileSize = file.FileSize();
|
||||
int64_t fileSize = file.FileSize();
|
||||
if (0==fileSize) {
|
||||
EWOL_ERROR("This file is empty : " << file);
|
||||
return;
|
||||
|
@ -64,7 +64,7 @@ typedef enum {
|
||||
#undef __class__
|
||||
#define __class__ "texture::TextureBMP"
|
||||
|
||||
void ewol::imageBMP::GenerateImage(etk::FSNode & fileName, draw::Image & ouputImage)
|
||||
bool ewol::imageBMP::GenerateImage(etk::UString & inputFile, draw::Image & ouputImage)
|
||||
{
|
||||
modeBitmap_te m_dataMode = BITS_16_R5G6B5;
|
||||
int32_t m_width = 0;
|
||||
@ -72,41 +72,46 @@ void ewol::imageBMP::GenerateImage(etk::FSNode & fileName, draw::Image & ouputIm
|
||||
bitmapFileHeader_ts m_FileHeader;
|
||||
bitmapInfoHeader_ts m_InfoHeader;
|
||||
|
||||
etk::FSNode fileName(inputFile);
|
||||
// Get the fileSize ...
|
||||
/*if (fileName.Size() < (int32_t)(sizeof(bitmapFileHeader_ts) + sizeof(bitmapInfoHeader_ts) ) ) {
|
||||
EWOL_ERROR("not enought data in the file named=\"" << fileName << "\"");
|
||||
return;
|
||||
}*/
|
||||
if (false==fileName.Exist()) {
|
||||
EWOL_ERROR("File does not existed=\"" << fileName << "\"");
|
||||
return false;
|
||||
}
|
||||
if(false == fileName.FileOpenRead() ) {
|
||||
EWOL_ERROR("Can not find the file name=\"" << fileName << "\"");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// get the data :
|
||||
if (fileName.FileRead(&m_FileHeader,sizeof(bitmapFileHeader_ts),1) != 1) {
|
||||
EWOL_ERROR("error loading file header");
|
||||
fileName.FileClose();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (fileName.FileRead(&m_InfoHeader,sizeof(bitmapInfoHeader_ts),1) != 1) {
|
||||
EWOL_ERROR("error loading file header");
|
||||
fileName.FileClose();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if(false == fileName.FileSeek(m_FileHeader.bfOffBits, SEEK_SET)) {
|
||||
EWOL_ERROR("error with the 'bfOffBits' in the file named=\"" << fileName << "\"");
|
||||
fileName.FileClose();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// Check the header error :
|
||||
if (m_FileHeader.bfType != 0x4D42) {
|
||||
EWOL_ERROR("the file=\"" << fileName << "\" is not a bitmap file ...");
|
||||
fileName.FileClose();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (m_FileHeader.bfReserved != 0x00000000) {
|
||||
EWOL_ERROR("the bfReserved feald is not at 0 ==> not supported format ...");
|
||||
fileName.FileClose();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if( m_InfoHeader.biBitCount == 16
|
||||
&& m_InfoHeader.biCompression == 0)
|
||||
@ -131,7 +136,7 @@ void ewol::imageBMP::GenerateImage(etk::FSNode & fileName, draw::Image & ouputIm
|
||||
} else {
|
||||
EWOL_ERROR("the biBitCount & biCompression fealds are unknow ==> not supported format ...");
|
||||
fileName.FileClose();;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
m_width = m_InfoHeader.biWidth;
|
||||
m_height = m_InfoHeader.biHeight;
|
||||
@ -234,6 +239,7 @@ void ewol::imageBMP::GenerateImage(etk::FSNode & fileName, draw::Image & ouputIm
|
||||
delete(m_data);
|
||||
m_data=NULL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
void ewol::texture::TextureBMP::Display(void)
|
||||
|
@ -34,7 +34,7 @@ namespace ewol
|
||||
{
|
||||
namespace imageBMP
|
||||
{
|
||||
void GenerateImage(etk::FSNode & fileName, draw::Image & ouputImage);
|
||||
bool GenerateImage(etk::UString & inputFile, draw::Image & ouputImage);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -36,34 +36,30 @@
|
||||
ewol::TextureFile::TextureFile(etk::UString genName, etk::UString tmpfileName, etk::Vector2D<int32_t> size) :
|
||||
Texture(genName)
|
||||
{
|
||||
// load data
|
||||
etk::FSNode fileName(etk::UString("DATA:") + tmpfileName);
|
||||
if (false == fileName.Exist()) {
|
||||
EWOL_ERROR("File does not Exist ... " << fileName << " from : " << tmpfileName);
|
||||
} else {
|
||||
// get the upper paw2 ot the size requested...
|
||||
if (size.x>0 && size.y>0) {
|
||||
SetImageSize(size);
|
||||
}
|
||||
|
||||
etk::UString fileExtention = fileName.FileGetExtention();
|
||||
if (fileExtention == "bmp") {
|
||||
// generate the texture
|
||||
ewol::imageBMP::GenerateImage(fileName, m_data);
|
||||
} else if (fileExtention == "svg") {
|
||||
svg::Parser m_element(fileName);
|
||||
if (false == m_element.IsLoadOk()) {
|
||||
EWOL_ERROR("Error To load SVG file " << fileName );
|
||||
} else {
|
||||
// generate the texture
|
||||
m_element.GenerateAnImage(size, m_data);
|
||||
}
|
||||
} else if (fileExtention == "png") {
|
||||
EWOL_ERROR("Extention not supported now, but soon " << fileName );
|
||||
} else {
|
||||
EWOL_ERROR("Extention not managed " << fileName << " Sopported extention : .bmp / .svg / .png");
|
||||
}
|
||||
Flush();
|
||||
etk::UString tmpName = etk::UString("DATA:") + tmpfileName;
|
||||
// get the upper paw2 ot the size requested...
|
||||
if (size.x>0 && size.y>0) {
|
||||
SetImageSize(size);
|
||||
}
|
||||
// load data
|
||||
if (true == tmpName.EndWith(".bmp") ) {
|
||||
// generate the texture
|
||||
if (false == ewol::imageBMP::GenerateImage(tmpName, m_data)) {
|
||||
EWOL_ERROR("Error To load BMP file " << tmpName );
|
||||
}
|
||||
} else if (true == tmpName.EndWith(".svg") ) {
|
||||
svg::Parser m_element(tmpName);
|
||||
if (false == m_element.IsLoadOk()) {
|
||||
EWOL_ERROR("Error To load SVG file " << tmpName );
|
||||
} else {
|
||||
// generate the texture
|
||||
m_element.GenerateAnImage(size, m_data);
|
||||
}
|
||||
} else if (true == tmpName.EndWith(".png") ) {
|
||||
EWOL_ERROR("Extention not supported now, but soon " << tmpName );
|
||||
} else {
|
||||
EWOL_ERROR("Extention not managed " << tmpName << " Sopported extention : .bmp / .svg / .png");
|
||||
}
|
||||
Flush();
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,8 @@
|
||||
#define __class__ "texture::TextureSVG"
|
||||
|
||||
|
||||
ewol::texture::TextureSVG::TextureSVG(etk::FSNode & fileName, int32_t width, int32_t height) : m_elementParsed(fileName)
|
||||
ewol::texture::TextureSVG::TextureSVG(etk::UString & fileName, int32_t width, int32_t height) :
|
||||
m_elementParsed(fileName)
|
||||
{
|
||||
m_loadOK = false;
|
||||
if (false == m_elementParsed.IsLoadOk()) {
|
||||
|
@ -42,7 +42,7 @@ namespace ewol
|
||||
uint8_t * m_data;
|
||||
bool m_loadOK;
|
||||
public:
|
||||
TextureSVG(etk::FSNode & fileName, int32_t width, int32_t height);
|
||||
TextureSVG(etk::UString & fileName, int32_t width, int32_t height);
|
||||
~TextureSVG(void);
|
||||
bool LoadOK(void);
|
||||
int32_t Width(void);
|
||||
|
@ -210,21 +210,11 @@ void ewol::Entry::OnDraw(DrawProperty& displayProp)
|
||||
// position :
|
||||
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||
// all entry parameters :
|
||||
if (0<=m_GLsizeBorder) {
|
||||
m_GLprogram->Uniform1f(m_GLsizeBorder, m_borderSize);
|
||||
}
|
||||
if (0<=m_GLsizePadding) {
|
||||
m_GLprogram->Uniform1f(m_GLsizePadding, m_paddingSize);
|
||||
}
|
||||
if (0<=m_GLsize) {
|
||||
m_GLprogram->Uniform2fv(m_GLsize, 1, &m_size.x);
|
||||
}
|
||||
if (0<=m_GLposText) {
|
||||
m_GLprogram->Uniform4fv(m_GLposText, 1, m_pos);
|
||||
}
|
||||
if (0<=m_GLstate) {
|
||||
m_GLprogram->Uniform1i(m_GLstate, 0);
|
||||
}
|
||||
m_GLprogram->Uniform1f(m_GLsizeBorder, m_borderSize);
|
||||
m_GLprogram->Uniform1f(m_GLsizePadding, m_paddingSize);
|
||||
m_GLprogram->Uniform2fv(m_GLsize, 1, &m_size.x);
|
||||
m_GLprogram->Uniform4fv(m_GLposText, 1, m_pos);
|
||||
m_GLprogram->Uniform1i(m_GLstate, 0);
|
||||
// Request the draw of the elements :
|
||||
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||
m_GLprogram->UnUse();
|
||||
|
@ -25,13 +25,6 @@
|
||||
#include <ewol/widget/ListFileSystem.h>
|
||||
#include <etk/tool.h>
|
||||
|
||||
#include <etk/os/FSNode.h>
|
||||
|
||||
// TODO : Remove the link with this at this level of abstraction ...
|
||||
extern "C" {
|
||||
// file browsing ...
|
||||
#include <dirent.h>
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ListFileSystem"
|
||||
@ -41,26 +34,6 @@ extern const char * const ewolEventFSFileValidate = "ewol-event-file-system-fi
|
||||
extern const char * const ewolEventFSFolderSelect = "ewol-event-file-system-folder-select";
|
||||
extern const char * const ewolEventFSFolderValidate = "ewol-event-file-system-folder-validate";
|
||||
|
||||
static void SortElementList(etk::Vector<ewol::elementFS *> &list)
|
||||
{
|
||||
etk::Vector<ewol::elementFS *> 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++) {
|
||||
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
|
||||
if (list[jjj]!=NULL) {
|
||||
if (tmpList[iii]->m_name > list[jjj]->m_name) {
|
||||
findPos = jjj+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
//EWOL_DEBUG("position="<<findPos);
|
||||
list.Insert(findPos, tmpList[iii]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -98,13 +71,6 @@ draw::Color ewol::ListFileSystem::GetBasicBG(void) {
|
||||
return bg;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
DIRECTORY_TYPE_NONE,
|
||||
DIRECTORY_TYPE_FILE,
|
||||
DIRECTORY_TYPE_LINK,
|
||||
DIRECTORY_TYPE_FOLDER,
|
||||
DIRECTORY_TYPE_OTHER,
|
||||
} typeDiretoryLocal_te;
|
||||
|
||||
void ewol::ListFileSystem::RegenerateView(void)
|
||||
{
|
||||
@ -115,97 +81,14 @@ void ewol::ListFileSystem::RegenerateView(void)
|
||||
m_list[iii] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
m_selectedLine = -1;
|
||||
m_list.Clear();
|
||||
m_originScrooled.x = 0;
|
||||
m_originScrooled.y = 0;
|
||||
|
||||
// regenerate the nex list :
|
||||
ewol::elementFS* tmpEmement = NULL;
|
||||
if (true==m_showFolder) {
|
||||
// the "." permit to reload the curent folder
|
||||
tmpEmement = new ewol::elementFS(".", ewol::EFS_FOLDER);
|
||||
if (NULL != tmpEmement) {
|
||||
m_list.PushBack(tmpEmement);
|
||||
}
|
||||
tmpEmement = NULL;
|
||||
// the ".." permit to show the upper folder (but not availlable for the "/" folder
|
||||
|
||||
#if defined(__TARGET_OS__Windows)
|
||||
if (m_folder != "c:/") {
|
||||
#else
|
||||
if (m_folder != "/") {
|
||||
#endif
|
||||
tmpEmement = new ewol::elementFS("..", ewol::EFS_FOLDER);
|
||||
if (NULL != tmpEmement) {
|
||||
m_list.PushBack(tmpEmement);
|
||||
}
|
||||
tmpEmement = NULL;
|
||||
}
|
||||
}
|
||||
DIR *dir = NULL;
|
||||
struct dirent *ent = NULL;
|
||||
dir = opendir(m_folder.c_str());
|
||||
if (dir != NULL) {
|
||||
// for each element in the drectory...
|
||||
while ((ent = readdir(dir)) != NULL) {
|
||||
typeDiretoryLocal_te localType = DIRECTORY_TYPE_NONE;
|
||||
#ifdef __TARGET_OS__Windows
|
||||
if (strchr(ent->d_name, '.') == NULL) {
|
||||
localType = DIRECTORY_TYPE_FOLDER;
|
||||
} else {
|
||||
localType = DIRECTORY_TYPE_FILE;
|
||||
}
|
||||
#else
|
||||
switch(ent->d_type)
|
||||
{
|
||||
case DT_DIR:
|
||||
localType = DIRECTORY_TYPE_FOLDER;
|
||||
break;
|
||||
case DT_REG:
|
||||
localType = DIRECTORY_TYPE_FILE;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if( true==m_showFile
|
||||
&& DIRECTORY_TYPE_FILE==localType) {
|
||||
if (ent->d_name != NULL) {
|
||||
etk::UString tmpString(ent->d_name);
|
||||
if( false==tmpString.StartWith(".")
|
||||
|| true ==m_showHidden) {
|
||||
tmpEmement = new ewol::elementFS(tmpString, ewol::EFS_FILE);
|
||||
if (NULL != tmpEmement) {
|
||||
m_list.PushBack(tmpEmement);
|
||||
}
|
||||
tmpEmement = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( true==m_showFolder
|
||||
&& DIRECTORY_TYPE_FOLDER==localType) {
|
||||
if (ent->d_name != NULL) {
|
||||
etk::UString tmpString(ent->d_name);
|
||||
//EWOL_DEBUG(" find Folder : \"" << tmpString << "\"(" << tmpString.Size() << ") ?= \"" << ent->d_name << "\"(" << strlen(ent->d_name) );
|
||||
if (tmpString != "." && tmpString != "..") {
|
||||
if( false==tmpString.StartWith(".")
|
||||
|| true ==m_showHidden) {
|
||||
tmpEmement = new ewol::elementFS(tmpString, ewol::EFS_FOLDER);
|
||||
if (NULL != tmpEmement) {
|
||||
m_list.PushBack(tmpEmement);
|
||||
}
|
||||
tmpEmement = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
} else {
|
||||
EWOL_ERROR("could not open directory : \"" << m_folder << "\"");
|
||||
}
|
||||
|
||||
// reorder the files
|
||||
SortElementList(m_list);
|
||||
etk::FSNode tmpFolder(m_folder);
|
||||
// Get the new list :
|
||||
m_list = tmpFolder.FolderGetSubList(m_showHidden, m_showFolder, m_showFile, m_showTemporaryFile);
|
||||
// request a redraw ...
|
||||
MarkToRedraw();
|
||||
}
|
||||
@ -253,7 +136,7 @@ etk::UString ewol::ListFileSystem::GetSelect(void)
|
||||
etk::UString tmpVal = "";
|
||||
if (m_selectedLine >= 0) {
|
||||
if (m_list[m_selectedLine] != NULL) {
|
||||
tmpVal = m_list[m_selectedLine]->m_name;
|
||||
tmpVal = m_list[m_selectedLine]->GetNameFile();
|
||||
}
|
||||
}
|
||||
return tmpVal;
|
||||
@ -266,7 +149,7 @@ void ewol::ListFileSystem::SetSelect( etk::UString data) {
|
||||
// search the coresponding file :
|
||||
for (int32_t iii=0; iii<m_list.Size(); iii++) {
|
||||
if (NULL!=m_list[iii]) {
|
||||
if (m_list[iii]->m_name == data) {
|
||||
if (m_list[iii]->GetNameFile() == data) {
|
||||
// we find the line :
|
||||
m_selectedLine = iii;
|
||||
break;
|
||||
@ -288,7 +171,7 @@ uint32_t ewol::ListFileSystem::GetNuberOfRaw(void) {
|
||||
};
|
||||
bool ewol::ListFileSystem::GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg) {
|
||||
if (raw >= 0 && raw < m_list.Size() && NULL != m_list[raw]) {
|
||||
myTextToWrite = m_list[raw]->m_name;
|
||||
myTextToWrite = m_list[raw]->GetNameFile();
|
||||
} else {
|
||||
myTextToWrite = "ERROR";
|
||||
}
|
||||
@ -321,13 +204,13 @@ bool ewol::ListFileSystem::OnItemEvent(int32_t IdInput, ewol::eventInputType_te
|
||||
&& m_selectedLine < m_list.Size()
|
||||
&& NULL != m_list[m_selectedLine] ) {
|
||||
// generate event extern :
|
||||
switch(m_list[m_selectedLine]->m_type)
|
||||
switch(m_list[m_selectedLine]->GetNodeType())
|
||||
{
|
||||
case ewol::EFS_FILE :
|
||||
GenerateEventId(ewolEventFSFileSelect, m_list[m_selectedLine]->m_name);
|
||||
case etk::FSN_FILE :
|
||||
GenerateEventId(ewolEventFSFileSelect, m_list[m_selectedLine]->GetNameFile());
|
||||
break;
|
||||
case ewol::EFS_FOLDER :
|
||||
GenerateEventId(ewolEventFSFolderSelect, m_list[m_selectedLine]->m_name);
|
||||
case etk::FSN_FOLDER :
|
||||
GenerateEventId(ewolEventFSFolderSelect, m_list[m_selectedLine]->GetNameFile());
|
||||
break;
|
||||
default:
|
||||
EWOL_ERROR("Can not generate event on an unknow type");
|
||||
@ -338,13 +221,13 @@ bool ewol::ListFileSystem::OnItemEvent(int32_t IdInput, ewol::eventInputType_te
|
||||
if( m_selectedLine >=0
|
||||
&& m_selectedLine < m_list.Size()
|
||||
&& NULL != m_list[m_selectedLine] ) {
|
||||
switch(m_list[m_selectedLine]->m_type)
|
||||
switch(m_list[m_selectedLine]->GetNodeType())
|
||||
{
|
||||
case ewol::EFS_FILE :
|
||||
GenerateEventId(ewolEventFSFileValidate, m_list[m_selectedLine]->m_name);
|
||||
case etk::FSN_FILE :
|
||||
GenerateEventId(ewolEventFSFileValidate, m_list[m_selectedLine]->GetNameFile());
|
||||
break;
|
||||
case ewol::EFS_FOLDER :
|
||||
GenerateEventId(ewolEventFSFolderValidate, m_list[m_selectedLine]->m_name);
|
||||
case etk::FSN_FOLDER :
|
||||
GenerateEventId(ewolEventFSFolderValidate, m_list[m_selectedLine]->GetNameFile());
|
||||
break;
|
||||
default:
|
||||
EWOL_ERROR("Can not generate event on an unknow type");
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define __EWOL_LIST_FILE_H__
|
||||
|
||||
#include <ewol/widget/List.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
|
||||
extern const char * const ewolEventFSFileSelect;
|
||||
extern const char * const ewolEventFSFileValidate;
|
||||
@ -33,35 +34,16 @@ extern const char * const ewolEventFSFolderSelect;
|
||||
extern const char * const ewolEventFSFolderValidate;
|
||||
|
||||
namespace ewol {
|
||||
typedef enum {
|
||||
EFS_FOLDER,
|
||||
EFS_FILE,
|
||||
EFS_LINK,
|
||||
} elementFS_te;
|
||||
|
||||
class elementFS
|
||||
{
|
||||
public :
|
||||
etk::UString m_name;
|
||||
elementFS_te m_type;
|
||||
int32_t m_rights;
|
||||
elementFS(etk::UString name, elementFS_te type) :
|
||||
m_name(name),
|
||||
m_type(type),
|
||||
m_rights(0)
|
||||
{ };
|
||||
~elementFS(void) {};
|
||||
};
|
||||
class ListFileSystem : public ewol::List
|
||||
{
|
||||
private:
|
||||
etk::Vector<ewol::elementFS *> m_list;
|
||||
etk::UString m_folder;
|
||||
int32_t m_selectedLine;
|
||||
bool m_showFile;
|
||||
bool m_showTemporaryFile;
|
||||
bool m_showFolder;
|
||||
bool m_showHidden;
|
||||
etk::Vector<etk::FSNode *> m_list;
|
||||
etk::UString m_folder;
|
||||
int32_t m_selectedLine;
|
||||
bool m_showFile;
|
||||
bool m_showTemporaryFile;
|
||||
bool m_showFolder;
|
||||
bool m_showHidden;
|
||||
public:
|
||||
ListFileSystem(void);
|
||||
~ListFileSystem(void);
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 4ee34e68155bfdc528d4371ed939b9de75aaf3c2
|
||||
Subproject commit edfe4d2aa6e50b496ff3c10203984e5b090c516d
|
Loading…
x
Reference in New Issue
Block a user