[DEV] interface new path backend

This commit is contained in:
Edouard DUPIN 2018-08-31 21:43:16 +02:00
parent 6a7d45b5b0
commit d302967081
18 changed files with 659 additions and 127 deletions

View File

@ -12,6 +12,7 @@
#include <etk/os/FSNode.hpp>
#include <etk/typeInfo.hpp>
#include <etk/Allocator.hpp>
#include <etk/theme/theme.hpp>
static int32_t nbTimeInit = 0;
@ -27,6 +28,7 @@ void etk::unInit() {
nbTimeInit = 0;
return;
}
etk::theme::uninit();
TK_INFO("ETK system un-init (BEGIN)");
ETK_MEM_SHOW_LOG();
TK_INFO("ETK system un-init (END)");
@ -51,7 +53,7 @@ void etk::init(int _argc, const char** _argv) {
etk::setArgZero(_argv[0]);
}
#endif
etk::theme::init();
for (int32_t iii=0; iii<_argc ; ++iii) {
etk::String data = _argv[iii];
if ( data == "-h"

View File

@ -4,166 +4,141 @@
* @license MPL v2.0 (see license file)
*/
#include <etk/fileSystem/Path.hpp>
#include <etk/log.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(etk::Path);
//#define TK_DBG_MODE TK_VERBOSE
#define TK_DBG_MODE TK_WARNING
static etk::Pair<etk::fileSystem::Type, etk::String> parsePath(etk::String _path) {
m_libSearch = "";
if ( _path.size() > 0
&& _path[0] == '{') {
// special case: Reference of searching in subLib folder ==> library use-case
size_t firstPos = _path.find('}');
if (firstPos != etk::String::npos) {
// we find a theme name : We extracted it :
m_libSearch = etk::String(_path, 1, firstPos-1);
_path = etk::String(_path, firstPos+1);
} else {
TK_ERROR("start a path name with '{' without '}' : " << _path);
// remove in case the {
_path = etk::String(_path, 1);
}
}
#ifdef HAVE_ZIP_DATA
m_zipContent = null;
m_zipReadingOffset = 0;
#endif
// Reset ALL DATA :
m_userFileName = "";
m_type = etk::FSNType_unknow;
m_data = "";
m_type = etk::fileSystem::Type::Unknow;
TK_DBG_MODE("1 : Set Name : \"" << _path << "\"");
// generate destination name in case of the input error
etk::String destFilename;
if (_path.size() == 0) {
// if no name ==> go to the root Folder
destFilename = "ROOT:";
} else {
destFilename = _path;
}
bool isRootFolder = false;
#ifdef __TARGET_OS__Windows
_path.replace("\\", "/");
for (char iii='a' ; iii<='z' ; iii++) {
char tmpVal[10];
char tmpValMaj[10];
char tmpDest[10];
sprintf(tmpVal, "%c:/", iii);
sprintf(tmpValMaj, "%c:/", iii+'A'-'a');
if( etk::start_with(destFilename, tmpVal) == true
|| etk::start_with(destFilename, tmpValMaj) == true) {
isRootFolder = true;
sprintf(tmpDest, "/%c/", iii);
if(etk::start_with(_path, tmpVal) == true) {
_path.replace(tmpVal, tmpDest);
break;
}
}
for (char iii='A' ; iii<='Z' ; iii++) {
char tmpVal[10];
char tmpDest[10];
sprintf(tmpVal, "%c:/", iii);
sprintf(tmpDest, "/%c/", iii+'a'-'A');
if(etk::start_with(_path, tmpVal) == true) {
_path.replace(tmpVal, tmpDest);
break;
}
}
#else
isRootFolder = destFilename[0] == '/';
#endif
if( start_with(destFilename, "ROOT:") == true
|| start_with(destFilename, "root:") == true ) {
// generate destination name in case of the input error
if (_path.size() == 0) {
// if no name ==> go to the root Folder
_path = "ROOT:";
}
if (_path[0] == '/') {
TK_DBG_MODE(" ==> detect root");
_path.erase(0, 1);
m_type = etk::fileSystem::Type::Direct;
} else if (start_with(_path, "ROOT:", false) == true) {
TK_DBG_MODE(" ==> detect root 2 ");
destFilename.erase(0, 5);
m_type = etk::FSNType_direct;
if(start_with(destFilename, "~") == true) {
destFilename.erase(0, 1);
m_type = etk::FSNType_home;
_path.erase(0, 5);
m_type = etk::fileSystem::Type::Direct;
if(start_with(_path, "~") == true) {
_path.erase(0, 1);
m_type = etk::fileSystem::Type::Home;
}
} else if( start_with(destFilename, "DIRECT:") == true
|| start_with(destFilename, "direct:") == true ) {
} else if (start_with(_path, "DIRECT:", false) == true) {
TK_DBG_MODE(" ==> detect direct");
destFilename.erase(0, 7);
m_type = etk::FSNType_direct;
if(start_with(destFilename, "~") == true) {
destFilename.erase(0, 1);
m_type = etk::FSNType_home;
_path.erase(0, 7);
m_type = etk::fileSystem::Type::Direct;
if(start_with(_path, "~") == true) {
_path.erase(0, 1);
m_type = etk::fileSystem::Type::Home;
}
} else if( start_with(destFilename, "DATA:") == true
|| start_with(destFilename, "data:") == true ) {
} else if (start_with(_path, "DATA:", false) == true) {
TK_DBG_MODE(" ==> detect data");
destFilename.erase(0, 5);
m_type = etk::FSNType_data;
} else if( start_with(destFilename, "USERDATA:") == true
|| start_with(destFilename, "userdata:") == true ) {
_path.erase(0, 5);
m_type = etk::fileSystem::Type::Data;
} else if (start_with(_path, "USERDATA:", false) == true) {
TK_DBG_MODE(" ==> detect User-data");
destFilename.erase(0, 9);
m_type = etk::FSNType_userData;
} else if( start_with(destFilename, "CACHE:") == true
|| start_with(destFilename, "cache:") == true ) {
_path.erase(0, 9);
m_type = etk::fileSystem::Type::UserData;
} else if (start_with(_path, "CACHE:", false) == true) {
TK_DBG_MODE(" ==> detect Cache");
destFilename.erase(0, 6);
m_type = etk::FSNType_cache;
} else if( start_with(destFilename, "THEME:") == true
|| start_with(destFilename, "theme:") == true ) {
_path.erase(0, 6);
m_type = etk::fileSystem::Type::Cache;
} else if (start_with(_path, "THEME:", false) == true) {
TK_DBG_MODE(" ==> detect theme");
destFilename.erase(0, 6);
m_type = etk::FSNType_theme;
} else if(start_with(destFilename, "./") == true) {
_path.erase(0, 6);
m_type = etk::fileSystem::Type::Theme;
} else if (start_with(_path, "./") == true) {
TK_DBG_MODE(" ==> detect relatif 1");
destFilename.erase(0, 2);
while (destFilename.size()>0 && destFilename[0] == '/') {
destFilename.erase(0, 1);
_path.erase(0, 2);
while (_path.size()>0 && _path[0] == '/') {
_path.erase(0, 1);
}
m_type = etk::FSNType_relatif;
} else if( start_with(destFilename, "REL:") == true
|| start_with(destFilename, "rel:") == true ) {
} else if (start_with(_path, "REL:", false) == true) {
TK_DBG_MODE(" ==> detect relatif 2");
destFilename.erase(0, 4);
while (destFilename.size()>0 && destFilename[0] == '/') {
destFilename.erase(0, 1);
_path.erase(0, 4);
while (_path.size()>0 && _path[0] == '/') {
_path.erase(0, 1);
}
m_type = etk::FSNType_relatif;
} else if(start_with(destFilename, baseRunPath) == true) {
} else if (start_with(_path, baseRunPath) == true) {
TK_DBG_MODE(" ==> detect relatif 3 (run path=" << baseRunPath << ")");
destFilename.erase(0, baseRunPath.size());
while (destFilename.size()>0 && destFilename[0] == '/') {
destFilename.erase(0, 1);
_path.erase(0, baseRunPath.size());
while (_path.size()>0 && _path[0] == '/') {
_path.erase(0, 1);
}
m_type = etk::FSNType_relatif;
} else if (( baseRunPath != baseRunPathInHome
&& ( start_with(destFilename, "~" + baseRunPathInHome) == true
|| start_with(destFilename, "HOME:" + baseRunPathInHome) == true
|| start_with(destFilename, "home:" + baseRunPathInHome) == true ) ) ) {
&& ( start_with(_path, "~" + baseRunPathInHome) == true
|| start_with(_path, "HOME:" + baseRunPathInHome, false) == true ) ) ) {
TK_DBG_MODE(" ==> detect relatif 4");
if (start_with(destFilename, "~" + baseRunPathInHome) == true) {
destFilename.erase(0, 1);
if (start_with(_path, "~" + baseRunPathInHome) == true) {
_path.erase(0, 1);
} else {
destFilename.erase(0, 5);
_path.erase(0, 5);
}
destFilename.erase(0, baseRunPathInHome.size());
while (destFilename.size()>0 && destFilename[0] == '/') {
destFilename.erase(0, 1);
_path.erase(0, baseRunPathInHome.size());
while (_path.size()>0 && _path[0] == '/') {
_path.erase(0, 1);
}
m_type = etk::FSNType_relatif;
} else if(start_with(destFilename, "~")) {
} else if (start_with(_path, "~")) {
TK_DBG_MODE(" ==> detect home 2");
destFilename.erase(0, 1);
m_type = etk::FSNType_home;
} else if( start_with(destFilename, "HOME:") == true
|| start_with(destFilename, "home:") == true ) {
_path.erase(0, 1);
m_type = etk::fileSystem::Type::Home;
} else if (start_with(_path, "HOME:", false) == true ) {
TK_DBG_MODE(" ==> detect home 3");
destFilename.erase(0, 5);
m_type = etk::FSNType_home;
if(start_with(destFilename, "~") == true) {
destFilename.erase(0, 1);
_path.erase(0, 5);
m_type = etk::fileSystem::Type::Home;
if(start_with(_path, "~") == true) {
_path.erase(0, 1);
}
} else if (start_with(destFilename, baseFolderHome) == true) {
} else if (start_with(_path, baseFolderHome) == true) {
TK_DBG_MODE(" ==> detect home");
destFilename.erase(0, baseFolderHome.size());
m_type = etk::FSNType_home;
} else if(isRootFolder == true) {
TK_DBG_MODE(" ==> detect root");
#ifdef __TARGET_OS__Windows
destFilename.erase(0, 3);
#else
destFilename.erase(0, 1);
#endif
m_type = etk::FSNType_direct;
_path.erase(0, baseFolderHome.size());
m_type = etk::fileSystem::Type::Home;
} else {
TK_DBG_MODE(" ==> detect other");
// nothing to remove
//Other type is Relative :
m_type = etk::FSNType_relatif;
}
m_userFileName = destFilename;
TK_DBG_MODE("3 : parse done : [" << m_type << "]->\"" << m_userFileName << "\"");
m_data = _path;
TK_DBG_MODE("3 : parse done : [" << m_type << "]->\"" << m_data << "\"");
// Now we reduce the path with all un-needed ../ and other thinks ...
// TODO : Do it whith link and the other sub thinks ...
@ -186,6 +161,26 @@ etk::Path::Path(const etk::String& _value) {
m_data =
}
etk::Path::Path(fileSystem::Type _type, const etk::String& _value) {
}
etk::String etk::Path::get() const {
}
etk::String etk::Path::getRelative() const {
}
etk::String etk::Path::getDecorated() const {
}
etk::String etk::Path::getNative() const {
}
bool etk::Path::operator== (const etk::Path &_obj) const {
return m_type == _obj.m_type
&& m_data == _obj.m_data;

View File

@ -29,6 +29,32 @@ namespace etk {
* @param[in] _value Element basic path
*/
Path(const etk::String& _value);
/**
* @brief Contructor with basic path.
* @param[in] _type type of path
* @param[in] _value offset in the path
*/
Path(fileSystem::Type _type, const etk::String& _value);
/**
* @brief Get the absolute path
* @return string like /home/userXXX/aaa/bbb/*** or /c/userXXX/aaa/bbb/***
*/
etk::String get() const;
/**
* @brief Get the relative path.
* @return string like ../../aaa/bbb/***
*/
etk::String getRelative() const;
/**
* @brief Get the Decorated path.
* @return string like DATA:aaa/bbb/***
*/
etk::String getDecorated() const;
/**
* @brief Get the absolute path
* @return string like /home/userXXX/aaa/bbb/*** or c:\userXXX\aaa\bbb\***
*/
etk::String getNative() const;
/**
* @brief Check if the 2 Path are identical.
* @param[in] _obj Path to compare.

View File

@ -9,7 +9,12 @@
#include <etk/stdTools.hpp>
#include <etk/typeInfo.hpp>
// Right Flags :
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(etk::filesystem::Permissions);
// Right Flags:
enum {
right_other_execute = 1 << 0,
right_other_write = 1 << 1,
@ -24,17 +29,21 @@ enum {
ETK_DECLARE_TYPE(etk::filesystem::Permissions);
etk::filesystem::Permissions::FSNodeRight(int16_t _newRight) :
etk::filesystem::Permissions::Permissions(uint16_t _newRight) :
m_rights(_newRight&0x01FF) {
}
uint16_t etk::filesystem::Permissions::getRight() const {
return m_rights;
}
etk::filesystem::Permissions& etk::filesystem::Permissions::operator= (const etk::filesystem::Permissions &_obj ) {
m_rights = _obj.m_rights;
return *this;
}
etk::filesystem::Permissions& etk::filesystem::Permissions::operator= (const int32_t _newVal) {
etk::filesystem::Permissions& etk::filesystem::Permissions::operator= (const uint32_t _newVal) {
m_rights = _newVal&0x01FF;
return *this;
}

View File

@ -22,7 +22,12 @@ namespace etk {
* @brief Right contructor.
* @param[in] _newRight Right to set by default
*/
Permissions(int16_t _newRight = 0);
Permissions(uint16_t _newRight = 0);
/**
* @brief Get Raw right
* @return the internal value.
*/
uint16_t getRight() const;
/**
* @brief Copy asignement operator (operator=)
* @param[in] _obj Object to copy
@ -34,7 +39,7 @@ namespace etk {
* @param[in] _newVal Value to set on the right
* @return Local reference on the object
*/
etk::filesystem::Permissions& operator= (const int32_t _newVal );
etk::filesystem::Permissions& operator= (const uint32_t _newVal );
/**
* @brief Clear right (set the value at 0 ==> cant not be read/write/execute
*/

View File

@ -0,0 +1,240 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etk/fileSystem/fileSystem.hpp>
#include <etk/log.hpp>
#ifdef __TARGET_OS__Windows
#include <tchar.h>
#include <windows.h>
#endif
extern "C" {
// file browsing ...
#include <dirent.h>
#include <sys/stat.h>
#include <errno.h>
}
void etk::fileSystem::copy(const etk::Path& _path1, const etk::Path& _path2) {
}
void etk::fileSystem::copyDirectory(const etk::Path& _path1, const etk::Path& _path2, bool _recursive) {
}
void etk::fileSystem::copyFile(const etk::Path& _path1, const etk::Path& _path2) {
}
void etk::fileSystem::move(const etk::Path& _path1, const etk::Path& _path2) {
}
void etk::fileSystem::moveDirectory(const etk::Path& _path1, const etk::Path& _path2) {
}
void etk::fileSystem::moveFile(const etk::Path& _path1, const etk::Path& _path2) {
}
void etk::fileSystem::remove(const etk::Path& _path) {
}
void etk::fileSystem::removeDirectory(const etk::Path& _path) {
}
void etk::fileSystem::removeFile(const etk::Path& _path) {
}
bool etk::fileSystem::exit(const etk::Path& _path) {
struct stat st;
int32_t status = 0;
if (stat(_path.get().c_str(), &st) != 0) {
return false;
}
return true;
}
uint64_t etk::fileSystem::fileSize(const etk::Path& _path) {
// Note : this is a proper methode to get the file size for Big files ... otherwithe the size is limited at 2^31 bytes
// tmpStat Buffer :
struct stat statProperty;
if (stat(_path.get().c_str(), &statProperty) == -1) {
//Normal case when the file does not exist ... ==> the it was in unknow mode ...
return 0;
}
TK_VERBOSE(" file size : " << (int64_t)statProperty.st_size << " bytes");
if ((uint64_t)statProperty.st_size <= 0) {
return 0;
}
return (uint64_t)statProperty.st_size;
}
bool etk::fileSystem::isDirectory(const etk::Path& _path) {
struct stat st;
int32_t status = 0;
if (stat(_path.get().c_str(), &st) != 0) {
return false;
} else if (!S_ISDIR(st.st_mode)) {
return false;
}
return true;
}
bool etk::fileSystem::isFile(const etk::Path& _path) {
struct stat st;
int32_t status = 0;
if (stat(_path.get().c_str(), &st) != 0) {
return false;
} else if (!S_ISREG(st.st_mode)) {
return false;
}
return true;
}
bool etk::fileSystem::isSymLink(const etk::Path& _path) {
struct stat st;
int32_t status = 0;
if (stat(_path.get().c_str(), &st) != 0) {
return false;
} else if (!S_ISLNK(st.st_mode)) {
return false;
}
return true;
}
etk::filesystem::Permissions etk::fileSystem::getPermission(const etk::Path& _path) {
etk::filesystem::Permissions permissions;
// tmpStat Buffer :
struct stat statProperty;
if (-1 == stat(m_systemFileName.c_str(), &statProperty)) {
//Normal case when the file does not exist ... ==> the it was in unknow mode ...
return permissions;
}
permissions = statProperty.st_mode;
return permissions;
}
etk::String etk::fileSystem::getRelativeString(const etk::Path& _path) {
return _path.getRelative();
}
etk::String etk::fileSystem::getDecoratedString(const etk::Path& _path) {
return _path.getDecorated();
}
etk::String etk::fileSystem::getAbsoluteString(const etk::Path& _path) {
return _path.get();
}
etk::String etk::fileSystem::getSystemString(const etk::Path& _path) {
return _path.getNative();
}
etk::String etk::fileSystem::getMimeType(const etk::Path& _path) {
}
etk::Path etk::fileSystem::getTemporaryPath() {
}
static bool initHomeFolder() {
static bool isInit = false;
if (isInit == false) {
TK_DBG_MODE("Real Ini Home folder:");
char * basicPath = getenv("HOME");
if (basicPath == null) {
TK_WARNING("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
} else {
baseFolderHome = basicPath;
}
TK_DBG_MODE(" home=:" << baseFolderHome);
isInit = true;
}
return isInit;
}
etk::String etk::fileSystem::getHomePathString() {
static bool isInit = false;
static etk::String data = "";
if (isInit == false) {
char * basicPath = getenv("HOME");
if (basicPath == null) {
TK_WARNING("ERROR while trying to get the path of the home folder");
#if defined(__TARGET_OS__Windows)
data = "c:/";
#elif defined(__TARGET_OS__Android)
data = "/sdcard";
#else
data = "~";
#endif
} else {
data = basicPath;
}
isInit = true;
}
return data;
}
etk::Path etk::fileSystem::getHomePath() {
return etk::Path(etk::fileSystem::Type::Home, "");
}
etk::Path etk::fileSystem::getExecutionPath() {
}
etk::Path etk::fileSystem::getBinaryPath() {
}
etk::Path etk::fileSystem::getDataPath() {
}
uint64_t etk::fileSystem::getCreateTime(const etk::Path& _path) {
}
uint64_t etk::fileSystem::getModifyTime(const etk::Path& _path) {
}
uint64_t etk::fileSystem::getAccessTime(const etk::Path& _path) {
}
uint32_t etk::fileSystem::getIdOwner(const etk::Path& _path) {
}
uint32_t etk::fileSystem::getIdGroup(const etk::Path& _path) {
}

View File

@ -10,20 +10,67 @@
namespace etk {
namespace fileSystem {
/**
* @brief Copy a path to an other (if possible...)
* @param[in] _path1 Path source.
* @param[in] _path2 Path destination.
*/
void copy(const etk::Path& _path1, const etk::Path& _path2);
/**
* @brief Copy a FOLDER path to an other (if possible...)
* @param[in] _path1 Path source.
* @param[in] _path2 Path destination.
*/
void copyDirectory(const etk::Path& _path1, const etk::Path& _path2, bool _recursive = true);
/**
* @brief Copy a FILE path to an other (if possible...)
* @param[in] _path1 Path source.
* @param[in] _path2 Path destination.
*/
void copyFile(const etk::Path& _path1, const etk::Path& _path2);
/**
* @brief Move a path to an other (if possible...)
* @param[in] _path1 Path source.
* @param[in] _path2 Path destination.
*/
void move(const etk::Path& _path1, const etk::Path& _path2);
/**
* @brief Move a FOLDER path to an other (if possible...)
* @param[in] _path1 Path source.
* @param[in] _path2 Path destination.
*/
void moveDirectory(const etk::Path& _path1, const etk::Path& _path2);
/**
* @brief Move a FILE path to an other (if possible...)
* @param[in] _path1 Path source.
* @param[in] _path2 Path destination.
*/
void moveFile(const etk::Path& _path1, const etk::Path& _path2);
void remove(const etk::Path& _path1, const etk::Path& _path2);
void removeDirectory(const etk::Path& _path1, const etk::Path& _path2);
void removeFile(const etk::Path& _path1, const etk::Path& _path2);
/**
* @brief Remove a path (if possible...)
* @param[in] _path Path to remove.
*/
void remove(const etk::Path& _path);
/**
* @brief Remove a FOLDER path (if possible...)
* @param[in] _path Path to remove.
*/
void removeDirectory(const etk::Path& _path);
/**
* @brief Remove a FILE path (if possible...)
* @param[in] _path Path to remove.
*/
void removeFile(const etk::Path& _path);
/**
* @brief Check if the path exist
* @param[in] _path1 Path source.
* @param[in] _path2 Path destination.
*/
bool exit(const etk::Path& _path);
uint_t fileSize(const etk::Path& _path);
uint64_t fileSize(const etk::Path& _path);
bool isDirectory(const etk::Path& _path);
bool isFile(const etk::Path& _path);
@ -34,10 +81,12 @@ namespace etk {
etk::String getRelativeString(const etk::Path& _path);
etk::String getDecoratedString(const etk::Path& _path);
etk::String getAbsoluteString(const etk::Path& _path);
etk::String getSystemString(const etk::Path& _path);
etk::String getMimeType(const etk::Path& _path);
etk::Path getTemporaryPath();
etk::String getHomePathString();
etk::Path getHomePath();
etk::Path getExecutionPath();
etk::Path getBinaryPath();

0
etk/os/Path.cpp Normal file
View File

0
etk/os/Path.hpp Normal file
View File

View File

@ -16,6 +16,15 @@ static etk::Map<etk::String, etk::String>& getThemeDefault() {
return g_listThemeDefault;
}
void etk::theme::init() {
}
void etk::theme::unInit() {
getTheme().clear();
getThemeDefault().clear();
}
void etk::theme::setName(const etk::String& _refName, const etk::String& _folderName) {
TK_WARNING("Change theme : '" << _refName << "' : '" << _folderName << "'");
getTheme().set(_refName, _folderName);

View File

@ -10,7 +10,14 @@
namespace etk {
namespace theme {
// TODO : Add an INIT ...
/**
* @brief initialize the theme system
*/
void init();
/**
* @brief un-initialize the theme system
*/
void unInit();
/**
* @brief Set the Folder of a subset of a theme ...
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"

View File

@ -27,6 +27,11 @@ def get_maintainer():
def configure(target, my_module):
my_module.add_src_file([
'test/main.cpp',
'test/testFileSystem.cpp',
'test/testPath.cpp',
'test/testPermissions.cpp',
'test/testTheme.cpp',
"""
'test/ConstructDestruct.cpp',
'test/testColor.cpp',
'test/testFunction.cpp',
@ -48,6 +53,7 @@ def configure(target, my_module):
'test/testTrait.cpp',
'test/testThrow.cpp',
'test/testUTF8.cpp',
"""
])
my_module.add_depend([
'etk',

View File

@ -34,6 +34,11 @@ def configure(target, my_module):
'etk/Noise.cpp',
'etk/Color.cpp',
'etk/RegEx.cpp',
'etk/fileSystem/fileSystem.cpp',
'etk/fileSystem/Path.cpp',
'etk/fileSystem/Permissions.cpp',
'etk/fileSystem/Type.cpp',
'etk/theme/theme.cpp',
'etk/math/Matrix2x2.cpp',
'etk/math/Matrix2x3.cpp',
'etk/math/Matrix3x3.cpp',
@ -46,7 +51,8 @@ def configure(target, my_module):
'etk/os/FSNode.cpp',
'etk/os/FSNodeRight.cpp',
'etk/archive/Archive.cpp',
'etk/archive/Zip.cpp'])
'etk/archive/Zip.cpp',
])
my_module.add_header_file([
'etk/etk.hpp',
@ -56,6 +62,11 @@ def configure(target, my_module):
'etk/Noise.hpp',
'etk/Color.hpp',
'etk/RegEx.hpp',
'etk/fileSystem/fileSystem.hpp',
'etk/fileSystem/Path.hpp',
'etk/fileSystem/Permissions.hpp',
'etk/fileSystem/Type.hpp',
'etk/theme/theme.hpp',
'etk/math/Matrix2x2.hpp',
'etk/math/Matrix2x3.hpp',
'etk/math/Matrix3x3.hpp',

View File

@ -9,7 +9,6 @@
#include <etest/etest.hpp>
#include <test-debug/debug.hpp>
#include <etk/os/FSNode.hpp>
#define NAME "FSNode"
TEST(TestEtkFSNode, checkHomePath) {
etk::String homePath = etk::FSNodeGetHomePath();

31
test/testFileSystem.cpp Normal file
View File

@ -0,0 +1,31 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
#include <etest/etest.hpp>
#include <test-debug/debug.hpp>
#include <etk/fileSystem/filesystem.hpp>
TEST(TestFileSystem, checkHomePath) {
EXPECT_EQ(etk::fileSystem::getHomePath(), "/home/heero");
}
TEST(TestEtkFSNode, checkHomePath) {
etk::String homePath = etk::FSNodeGetHomePath();
EXPECT_EQ(homePath, "/home/heero");
etk::FSNode myNodeTest1("HOME:filePresent.txt");
EXPECT_EQ(myNodeTest1.getNameFile(), "filePresent.txt");
EXPECT_EQ(myNodeTest1.getFileSystemName(), homePath + "/filePresent.txt");
EXPECT_EQ(myNodeTest1.getNameFolder(), "/home/heero");
etk::FSNode myNodeTest2("HOME:/filePresent.txt");
EXPECT_EQ(myNodeTest2.getNameFile(), "filePresent.txt");
EXPECT_EQ(myNodeTest2.getFileSystemName(), homePath + "/filePresent.txt");
EXPECT_EQ(myNodeTest2.getNameFolder(), "/home/heero");
etk::FSNode myNodeTest3("~/filePresent.txt");
EXPECT_EQ(myNodeTest3.getNameFile(), "filePresent.txt");
EXPECT_EQ(myNodeTest3.getFileSystemName(), homePath + "/filePresent.txt");
EXPECT_EQ(myNodeTest3.getNameFolder(), "/home/heero");

17
test/testPath.cpp Normal file
View File

@ -0,0 +1,17 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
#include <etest/etest.hpp>
#include <test-debug/debug.hpp>
#include <etk/fileSystem/Path.hpp>
TEST(TestPath, defaultContructor) {
etk::Path path;
EXPECT_EQ(path.getType(), etk::fileSystem::Type::Unknow);
EXPECT_EQ(path.get(), "");
}

86
test/testPermissions.cpp Normal file
View File

@ -0,0 +1,86 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
#include <etest/etest.hpp>
#include <test-debug/debug.hpp>
#include <etk/fileSystem/Permissions.hpp>
TEST(TestPermission, defaultContructor) {
etk::filesystem::Permissions permission;
EXPECT_EQ(permission.isUserReadable(), false);
EXPECT_EQ(permission.isUserWritable(), false);
EXPECT_EQ(permission.isUserRunable(), false);
EXPECT_EQ(permission.isGroupReadable(), false);
EXPECT_EQ(permission.isGroupWritable(), false);
EXPECT_EQ(permission.isGroupRunable(), false);
EXPECT_EQ(permission.isOtherReadable(), false);
EXPECT_EQ(permission.isOtherWritable(), false);
EXPECT_EQ(permission.isOtherRunable(), false);
EXPECT_EQ(permission.getRight(), "---------");
}
TEST(TestPermission, fullright) {
etk::filesystem::Permissions permission(o777);
EXPECT_EQ(permission.isUserReadable(), true);
EXPECT_EQ(permission.isUserWritable(), true);
EXPECT_EQ(permission.isUserRunable(), true);
EXPECT_EQ(permission.isGroupReadable(), true);
EXPECT_EQ(permission.isGroupWritable(), true);
EXPECT_EQ(permission.isGroupRunable(), true);
EXPECT_EQ(permission.isOtherReadable(), true);
EXPECT_EQ(permission.isOtherWritable(), true);
EXPECT_EQ(permission.isOtherRunable(), true);
EXPECT_EQ(permission.getRight(), "rwxrwxrwx");
}
TEST(TestPermission, user) {
etk::filesystem::Permissions permission(o700);
EXPECT_EQ(permission.isUserReadable(), true);
EXPECT_EQ(permission.isUserWritable(), true);
EXPECT_EQ(permission.isUserRunable(), true);
EXPECT_EQ(permission.isGroupReadable(), false);
EXPECT_EQ(permission.isGroupWritable(), false);
EXPECT_EQ(permission.isGroupRunable(), false);
EXPECT_EQ(permission.isOtherReadable(), false);
EXPECT_EQ(permission.isOtherWritable(), false);
EXPECT_EQ(permission.isOtherRunable(), false);
EXPECT_EQ(permission.getRight(), "rwx------");
}
TEST(TestPermission, group) {
etk::filesystem::Permissions permission(o070);
EXPECT_EQ(permission.isUserReadable(), false);
EXPECT_EQ(permission.isUserWritable(), false);
EXPECT_EQ(permission.isUserRunable(), false);
EXPECT_EQ(permission.isGroupReadable(), true);
EXPECT_EQ(permission.isGroupWritable(), true);
EXPECT_EQ(permission.isGroupRunable(), true);
EXPECT_EQ(permission.isOtherReadable(), false);
EXPECT_EQ(permission.isOtherWritable(), false);
EXPECT_EQ(permission.isOtherRunable(), false);
EXPECT_EQ(permission.getRight(), "---rwx---");
}
TEST(TestPermission, other) {
etk::filesystem::Permissions permission(o007);
EXPECT_EQ(permission.isUserReadable(), false);
EXPECT_EQ(permission.isUserWritable(), false);
EXPECT_EQ(permission.isUserRunable(), false);
EXPECT_EQ(permission.isGroupReadable(), false);
EXPECT_EQ(permission.isGroupWritable(), false);
EXPECT_EQ(permission.isGroupRunable(), false);
EXPECT_EQ(permission.isOtherReadable(), true);
EXPECT_EQ(permission.isOtherWritable(), true);
EXPECT_EQ(permission.isOtherRunable(), true);
EXPECT_EQ(permission.getRight(), "------rwx");
}

40
test/testTheme.cpp Normal file
View File

@ -0,0 +1,40 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
#include <etest/etest.hpp>
#include <test-debug/debug.hpp>
#include <etk/theme/theme.hpp>
TEST(TestTheme, init_uninit) {
etk::theme::init();
etk::theme::setName("AAA", "aaa");
EXPECT_EQ(etk::theme::getDefaultName("AAA"), "");
EXPECT_EQ(etk::theme::getName("AAA"), "aaa");
etk::theme::unInit()
EXPECT_EQ(etk::theme::getDefaultName("AAA"), "");
EXPECT_EQ(etk::theme::getName("AAA"), "");
}
TEST(TestTheme, set) {
etk::theme::init();
etk::theme::setDefaultName("AAA", "aaa");
EXPECT_EQ(etk::theme::getDefaultName("AAA"), "aaa");
EXPECT_EQ(etk::theme::getName("AAA"), "aaa");
etk::theme::unInit()
EXPECT_EQ(etk::theme::getDefaultName("AAA"), "");
EXPECT_EQ(etk::theme::getName("AAA"), "");
}
TEST(TestTheme, set2) {
etk::theme::init();
etk::theme::setDefaultName("AAA", "aaa");
etk::theme::setName("AAA", "bbb");
EXPECT_EQ(etk::theme::getDefaultName("AAA"), "aaa");
EXPECT_EQ(etk::theme::getName("AAA"), "bbb");
etk::theme::unInit()
}