[DEV] continue rework path
This commit is contained in:
parent
44655d7f78
commit
0720c3ffca
@ -11,7 +11,7 @@
|
|||||||
#include <etk/Map.hpp>
|
#include <etk/Map.hpp>
|
||||||
#include <ethread/Mutex.hpp>
|
#include <ethread/Mutex.hpp>
|
||||||
#include <ememory/memory.hpp>
|
#include <ememory/memory.hpp>
|
||||||
#include <etk/fileSystem/Path.hpp>
|
#include <etk/fs/Path.hpp>
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
/**
|
/**
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
|
||||||
* @license MPL v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
#include <etk/types.hpp>
|
|
||||||
#include <etk/fileSystem/Type.hpp>
|
|
||||||
|
|
||||||
etk::Stream& etk::operator <<(etk::Stream &_os, const enum etk::fileSystem::Type &_obj) {
|
|
||||||
switch (_obj) {
|
|
||||||
case etk::fileSystem::Type::Unknow:
|
|
||||||
_os << "etk::fileSystem::Type::Unknow";
|
|
||||||
break;
|
|
||||||
case etk::fileSystem::Type::Direct:
|
|
||||||
_os << "etk::fileSystem::Type::Direct";
|
|
||||||
break;
|
|
||||||
case etk::fileSystem::Type::Home:
|
|
||||||
_os << "etk::fileSystem::Type::Home";
|
|
||||||
break;
|
|
||||||
case etk::fileSystem::Type::Data:
|
|
||||||
_os << "etk::fileSystem::Type::Data";
|
|
||||||
break;
|
|
||||||
case etk::fileSystem::Type::UserData:
|
|
||||||
_os << "etk::fileSystem::Type::UserData";
|
|
||||||
break;
|
|
||||||
case etk::fileSystem::Type::Cache:
|
|
||||||
_os << "etk::fileSystem::Type::Cache";
|
|
||||||
break;
|
|
||||||
case etk::fileSystem::Type::Theme:
|
|
||||||
_os << "etk::fileSystem::Type::Theme";
|
|
||||||
break;
|
|
||||||
case etk::fileSystem::Type::ThemeData:
|
|
||||||
_os << "etk::fileSystem::Type::Theme(DATA)";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_os << "etk::fileSystem::Type::????";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return _os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -3,15 +3,16 @@
|
|||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
* @license MPL v2.0 (see license file)
|
* @license MPL v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
#include <etk/fileSystem/Path.hpp>
|
#include <etk/fs/Path.hpp>
|
||||||
#include <etk/debug.hpp>
|
#include <etk/debug.hpp>
|
||||||
#include <etk/Exception.hpp>
|
#include <etk/Exception.hpp>
|
||||||
|
#include <etk/fs/fileSystem.hpp>
|
||||||
|
|
||||||
#include <etk/typeInfo.hpp>
|
#include <etk/typeInfo.hpp>
|
||||||
ETK_DECLARE_TYPE(etk::Path);
|
ETK_DECLARE_TYPE(etk::Path);
|
||||||
|
|
||||||
//#define TK_DBG_MODE TK_VERBOSE
|
#define TK_DBG_MODE TK_VERBOSE
|
||||||
#define TK_DBG_MODE TK_WARNING
|
//#define TK_DBG_MODE TK_WARNING
|
||||||
|
|
||||||
|
|
||||||
static etk::String simplifyPath(etk::String _input) {
|
static etk::String simplifyPath(etk::String _input) {
|
||||||
@ -108,6 +109,10 @@ static etk::String simplifyPath(etk::String _input) {
|
|||||||
_input = "/";
|
_input = "/";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if ( _input.size() >= 1
|
||||||
|
&& _input[_input.size()-1] == '/') {
|
||||||
|
_input.erase(_input.size()-1, 1);
|
||||||
|
}
|
||||||
TK_DEBUG("Simplify(end) : '" << _input << "'");
|
TK_DEBUG("Simplify(end) : '" << _input << "'");
|
||||||
return _input;
|
return _input;
|
||||||
}
|
}
|
||||||
@ -118,6 +123,11 @@ static etk::String convertToWindows(etk::String _path) {
|
|||||||
&& _path[2] == '/') {
|
&& _path[2] == '/') {
|
||||||
_path[0] = _path[1];
|
_path[0] = _path[1];
|
||||||
_path[1] = ':';
|
_path[1] = ':';
|
||||||
|
} else if ( _path.size() == 2
|
||||||
|
&& _path[0] == '/') {
|
||||||
|
_path[0] = _path[1];
|
||||||
|
_path[1] = ':';
|
||||||
|
_path += '\\';
|
||||||
}
|
}
|
||||||
_path.replace("/", "\\");
|
_path.replace("/", "\\");
|
||||||
return _path;
|
return _path;
|
||||||
@ -208,8 +218,7 @@ etk::String etk::Path::getAbsolute() const {
|
|||||||
if (isAbsolute() == true) {
|
if (isAbsolute() == true) {
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
// TODO : plouf ...
|
return (etk::fs::getExecutionPath() / m_data).getString();
|
||||||
return "todo";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::String etk::Path::getAbsoluteWindows() const {
|
etk::String etk::Path::getAbsoluteWindows() const {
|
||||||
@ -247,7 +256,7 @@ etk::String etk::Path::getFileName() const {
|
|||||||
if (pos == etk::String::npos) {
|
if (pos == etk::String::npos) {
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
return m_data.extract(pos);
|
return m_data.extract(pos+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::String etk::Path::getExtention() const {
|
etk::String etk::Path::getExtention() const {
|
||||||
@ -260,7 +269,7 @@ etk::String etk::Path::getExtention() const {
|
|||||||
// a simple name started with a .
|
// a simple name started with a .
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return fileName.extract(pos);
|
return fileName.extract(pos+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::Path::parent() {
|
void etk::Path::parent() {
|
||||||
@ -281,32 +290,43 @@ etk::Path etk::Path::getParent() const {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::Path::operator== (const etk::Path &_obj) const {
|
bool etk::Path::operator== (const etk::Path& _obj) const {
|
||||||
return m_data == _obj.m_data;
|
return m_data == _obj.m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::Path::operator!= (const etk::Path &_obj) const {
|
bool etk::Path::operator!= (const etk::Path& _obj) const {
|
||||||
return m_data != _obj.m_data;
|
return m_data != _obj.m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path etk::Path::operator/ (const etk::String & _element) const {
|
etk::Path etk::Path::operator/ (const etk::String& _element) const {
|
||||||
etk::Path tmp = *this;
|
etk::Path tmp = *this;
|
||||||
tmp /= etk::Path(_element);
|
tmp /= etk::Path(_element);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path etk::Path::operator/ (const etk::Path & _path) const {
|
etk::Path etk::Path::operator/ (const char* _element) const {
|
||||||
|
etk::Path tmp = *this;
|
||||||
|
tmp /= etk::Path(_element);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::Path etk::Path::operator/ (const etk::Path& _path) const {
|
||||||
etk::Path tmp = *this;
|
etk::Path tmp = *this;
|
||||||
tmp /= _path;
|
tmp /= _path;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path& etk::Path::operator/= (const etk::String & _element) {
|
etk::Path& etk::Path::operator/= (const etk::String& _element) {
|
||||||
*this /= etk::Path(_element);
|
*this /= etk::Path(_element);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path& etk::Path::operator/= (const etk::Path & _path) {
|
etk::Path& etk::Path::operator/= (const char* _element) {
|
||||||
|
*this /= etk::Path(_element);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::Path& etk::Path::operator/= (const etk::Path& _path) {
|
||||||
if (_path.m_data.size() == 0) {
|
if (_path.m_data.size() == 0) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -318,24 +338,35 @@ etk::Path& etk::Path::operator/= (const etk::Path & _path) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path etk::Path::operator+ (const etk::String & _element) const {
|
etk::Path etk::Path::operator+ (const char* _element) const {
|
||||||
etk::Path tmp = *this;
|
etk::Path tmp = *this;
|
||||||
tmp += etk::Path(_element);
|
tmp += etk::Path(_element);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path etk::Path::operator+ (const etk::Path & _element) const {
|
etk::Path etk::Path::operator+ (const etk::String& _element) const {
|
||||||
|
etk::Path tmp = *this;
|
||||||
|
tmp += etk::Path(_element);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::Path etk::Path::operator+ (const etk::Path& _element) const {
|
||||||
etk::Path tmp = *this;
|
etk::Path tmp = *this;
|
||||||
tmp += _element;
|
tmp += _element;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path& etk::Path::operator+= (const etk::String & _element) {
|
etk::Path& etk::Path::operator+= (const char* _element) {
|
||||||
*this += etk::Path(_element);
|
*this += etk::Path(_element);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path& etk::Path::operator+= (const etk::Path & _element) {
|
etk::Path& etk::Path::operator+= (const etk::String& _element) {
|
||||||
|
*this += etk::Path(_element);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::Path& etk::Path::operator+= (const etk::Path& _element) {
|
||||||
if (_element.m_data.size() == 0) {
|
if (_element.m_data.size() == 0) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -344,7 +375,7 @@ etk::Path& etk::Path::operator+= (const etk::Path & _element) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path& etk::Path::operator= (const etk::String & _element) {
|
etk::Path& etk::Path::operator= (const etk::String& _element) {
|
||||||
m_data = parsePath(_element);
|
m_data = parsePath(_element);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -355,7 +386,7 @@ etk::Path& etk::Path::operator= (const char* _element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::Stream& etk::operator <<(etk::Stream &_os, const etk::Path &_obj) {
|
etk::Stream& etk::operator <<(etk::Stream& _os, const etk::Path& _obj) {
|
||||||
_os << _obj.getString();
|
_os << _obj.getString();
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
@ -6,7 +6,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <etk/fileSystem/Type.hpp>
|
#include <etk/fs/Type.hpp>
|
||||||
#include <etk/String.hpp>
|
#include <etk/String.hpp>
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
@ -126,41 +126,49 @@ namespace etk {
|
|||||||
* @param[in] _obj Path to compare.
|
* @param[in] _obj Path to compare.
|
||||||
* @return true : same path, false otherwise.
|
* @return true : same path, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool operator== (const etk::Path &_obj) const;
|
bool operator== (const etk::Path& _obj) const;
|
||||||
/**
|
/**
|
||||||
* @brief Check if the 2 Path are different.
|
* @brief Check if the 2 Path are different.
|
||||||
* @param[in] _obj Path to compare.
|
* @param[in] _obj Path to compare.
|
||||||
* @return false : same path, true otherwise.
|
* @return false : same path, true otherwise.
|
||||||
*/
|
*/
|
||||||
bool operator!= (const etk::Path &_obj) const;
|
bool operator!= (const etk::Path& _obj) const;
|
||||||
/**
|
/**
|
||||||
* @brief Add a subfolder on the current path.
|
* @brief Add a subfolder on the current path.
|
||||||
* @param[in] _element sub folder or file to add.
|
* @param[in] _element sub folder or file to add.
|
||||||
* @return false : same path, true otherwise.
|
* @return false : same path, true otherwise.
|
||||||
*/
|
*/
|
||||||
Path operator/ (const etk::String & _element) const;
|
Path operator/ (const etk::String& _element) const;
|
||||||
//! @preivious
|
//! @preivious
|
||||||
Path& operator/= (const etk::String & _element);
|
Path& operator/= (const etk::String& _element);
|
||||||
//! @preivious
|
//! @preivious
|
||||||
Path operator/ (const etk::Path & _element) const;
|
Path operator/ (const char* _element) const;
|
||||||
//! @preivious
|
//! @preivious
|
||||||
Path& operator/= (const etk::Path & _element);
|
Path& operator/= (const char* _element);
|
||||||
|
//! @preivious
|
||||||
|
Path operator/ (const etk::Path& _element) const;
|
||||||
|
//! @preivious
|
||||||
|
Path& operator/= (const etk::Path& _element);
|
||||||
/**
|
/**
|
||||||
* @brief Add a subfolder on the current path.
|
* @brief Add a subfolder on the current path.
|
||||||
* @param[in] _element sub folder or file to add.
|
* @param[in] _element sub folder or file to add.
|
||||||
* @return false : same path, true otherwise.
|
* @return false : same path, true otherwise.
|
||||||
*/
|
*/
|
||||||
Path operator+ (const etk::String & _element) const;
|
Path operator+ (const etk::String& _element) const;
|
||||||
//! @preivious
|
//! @preivious
|
||||||
Path& operator+= (const etk::String & _element);
|
Path& operator+= (const etk::String& _element);
|
||||||
//! @preivious
|
//! @preivious
|
||||||
Path operator+ (const etk::Path & _element) const;
|
Path operator+ (const char* _element) const;
|
||||||
//! @preivious
|
//! @preivious
|
||||||
Path& operator+= (const etk::Path & _element);
|
Path& operator+= (const char* _element);
|
||||||
|
//! @preivious
|
||||||
|
Path operator+ (const etk::Path& _element) const;
|
||||||
|
//! @preivious
|
||||||
|
Path& operator+= (const etk::Path& _element);
|
||||||
/**
|
/**
|
||||||
* @breif asignmendt operator:
|
* @breif asignmendt operator:
|
||||||
*/
|
*/
|
||||||
Path& operator= (const etk::String & _element);
|
Path& operator= (const etk::String& _element);
|
||||||
Path& operator= (const char* _element);
|
Path& operator= (const char* _element);
|
||||||
};
|
};
|
||||||
bool operator> (const Path& _left, const Path& _right);
|
bool operator> (const Path& _left, const Path& _right);
|
||||||
@ -168,6 +176,6 @@ namespace etk {
|
|||||||
bool operator< (const Path& _left, const Path& _right);
|
bool operator< (const Path& _left, const Path& _right);
|
||||||
bool operator<= (const Path& _left, const Path& _right);
|
bool operator<= (const Path& _left, const Path& _right);
|
||||||
//! @not_in_doc
|
//! @not_in_doc
|
||||||
etk::Stream& operator <<(etk::Stream &_os, const etk::Path &_obj);
|
etk::Stream& operator <<(etk::Stream& _os, const etk::Path& _obj);
|
||||||
}
|
}
|
||||||
|
|
@ -8,11 +8,11 @@
|
|||||||
#include <etk/os/FSNodeRight.hpp>
|
#include <etk/os/FSNodeRight.hpp>
|
||||||
#include <etk/stdTools.hpp>
|
#include <etk/stdTools.hpp>
|
||||||
#include <etk/typeInfo.hpp>
|
#include <etk/typeInfo.hpp>
|
||||||
#include <etk/fileSystem/Permissions.hpp>
|
#include <etk/fs/Permissions.hpp>
|
||||||
|
|
||||||
|
|
||||||
#include <etk/typeInfo.hpp>
|
#include <etk/typeInfo.hpp>
|
||||||
ETK_DECLARE_TYPE(etk::fileSystem::Permissions);
|
ETK_DECLARE_TYPE(etk::fs::Permissions);
|
||||||
|
|
||||||
|
|
||||||
// Right Flags:
|
// Right Flags:
|
||||||
@ -28,42 +28,42 @@ enum {
|
|||||||
right_user_read = 1 << 8,
|
right_user_read = 1 << 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
etk::fileSystem::Permissions::Permissions(uint16_t _newRight) :
|
etk::fs::Permissions::Permissions(uint16_t _newRight) :
|
||||||
m_rights(_newRight&0x01FF) {
|
m_rights(_newRight&0x01FF) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t etk::fileSystem::Permissions::getRightValue() const {
|
uint16_t etk::fs::Permissions::getRightValue() const {
|
||||||
return m_rights;
|
return m_rights;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::fileSystem::Permissions& etk::fileSystem::Permissions::operator= (const etk::fileSystem::Permissions &_obj ) {
|
etk::fs::Permissions& etk::fs::Permissions::operator= (const etk::fs::Permissions &_obj ) {
|
||||||
m_rights = _obj.m_rights;
|
m_rights = _obj.m_rights;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::fileSystem::Permissions& etk::fileSystem::Permissions::operator= (const uint32_t _newVal) {
|
etk::fs::Permissions& etk::fs::Permissions::operator= (const uint32_t _newVal) {
|
||||||
m_rights = _newVal&0x01FF;
|
m_rights = _newVal&0x01FF;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::fileSystem::Permissions::clear() {
|
void etk::fs::Permissions::clear() {
|
||||||
m_rights = 0;
|
m_rights = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::Permissions::isUserReadable() const {
|
bool etk::fs::Permissions::isUserReadable() const {
|
||||||
return ((m_rights&right_user_read)!=0)?true:false;
|
return ((m_rights&right_user_read)!=0)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::Permissions::isUserWritable() const {
|
bool etk::fs::Permissions::isUserWritable() const {
|
||||||
return ((m_rights&right_user_write)!=0)?true:false;
|
return ((m_rights&right_user_write)!=0)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::Permissions::isUserRunable() const {
|
bool etk::fs::Permissions::isUserRunable() const {
|
||||||
return ((m_rights&right_user_execute)!=0)?true:false;
|
return ((m_rights&right_user_execute)!=0)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::fileSystem::Permissions::setUserReadable(bool _newStatus) {
|
void etk::fs::Permissions::setUserReadable(bool _newStatus) {
|
||||||
// reset the flag :
|
// reset the flag :
|
||||||
m_rights &= (0xFFFFFFFF - right_user_read);
|
m_rights &= (0xFFFFFFFF - right_user_read);
|
||||||
if (_newStatus == true) {
|
if (_newStatus == true) {
|
||||||
@ -71,7 +71,7 @@ void etk::fileSystem::Permissions::setUserReadable(bool _newStatus) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::fileSystem::Permissions::setUserWritable(bool _newStatus) {
|
void etk::fs::Permissions::setUserWritable(bool _newStatus) {
|
||||||
// reset the flag :
|
// reset the flag :
|
||||||
m_rights &= (0xFFFFFFFF - right_user_write);
|
m_rights &= (0xFFFFFFFF - right_user_write);
|
||||||
if (_newStatus == true) {
|
if (_newStatus == true) {
|
||||||
@ -79,7 +79,7 @@ void etk::fileSystem::Permissions::setUserWritable(bool _newStatus) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::fileSystem::Permissions::setUserRunable(bool _newStatus) {
|
void etk::fs::Permissions::setUserRunable(bool _newStatus) {
|
||||||
// reset the flag :
|
// reset the flag :
|
||||||
m_rights &= (0xFFFFFFFF - right_user_execute);
|
m_rights &= (0xFFFFFFFF - right_user_execute);
|
||||||
if (_newStatus == true) {
|
if (_newStatus == true) {
|
||||||
@ -87,19 +87,19 @@ void etk::fileSystem::Permissions::setUserRunable(bool _newStatus) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::Permissions::isGroupReadable() const {
|
bool etk::fs::Permissions::isGroupReadable() const {
|
||||||
return ((m_rights&right_group_read)!=0)?true:false;
|
return ((m_rights&right_group_read)!=0)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::Permissions::isGroupWritable() const {
|
bool etk::fs::Permissions::isGroupWritable() const {
|
||||||
return ((m_rights&right_group_write)!=0)?true:false;
|
return ((m_rights&right_group_write)!=0)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::Permissions::isGroupRunable() const {
|
bool etk::fs::Permissions::isGroupRunable() const {
|
||||||
return ((m_rights&right_group_execute)!=0)?true:false;
|
return ((m_rights&right_group_execute)!=0)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::fileSystem::Permissions::setGroupReadable(bool _newStatus) {
|
void etk::fs::Permissions::setGroupReadable(bool _newStatus) {
|
||||||
// reset the flag :
|
// reset the flag :
|
||||||
m_rights &= (0xFFFFFFFF - right_group_read);
|
m_rights &= (0xFFFFFFFF - right_group_read);
|
||||||
if (true == _newStatus) {
|
if (true == _newStatus) {
|
||||||
@ -107,7 +107,7 @@ void etk::fileSystem::Permissions::setGroupReadable(bool _newStatus) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::fileSystem::Permissions::setGroupWritable(bool _newStatus) {
|
void etk::fs::Permissions::setGroupWritable(bool _newStatus) {
|
||||||
// reset the flag :
|
// reset the flag :
|
||||||
m_rights &= (0xFFFFFFFF - right_group_write);
|
m_rights &= (0xFFFFFFFF - right_group_write);
|
||||||
if (true == _newStatus) {
|
if (true == _newStatus) {
|
||||||
@ -115,7 +115,7 @@ void etk::fileSystem::Permissions::setGroupWritable(bool _newStatus) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::fileSystem::Permissions::setGroupRunable(bool _newStatus) {
|
void etk::fs::Permissions::setGroupRunable(bool _newStatus) {
|
||||||
// reset the flag :
|
// reset the flag :
|
||||||
m_rights &= (0xFFFFFFFF - right_group_execute);
|
m_rights &= (0xFFFFFFFF - right_group_execute);
|
||||||
if (true == _newStatus) {
|
if (true == _newStatus) {
|
||||||
@ -123,19 +123,19 @@ void etk::fileSystem::Permissions::setGroupRunable(bool _newStatus) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::Permissions::isOtherReadable() const {
|
bool etk::fs::Permissions::isOtherReadable() const {
|
||||||
return ((m_rights&right_other_read) != 0)?true:false;
|
return ((m_rights&right_other_read) != 0)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::Permissions::isOtherWritable() const {
|
bool etk::fs::Permissions::isOtherWritable() const {
|
||||||
return ((m_rights&right_other_write) != 0)?true:false;
|
return ((m_rights&right_other_write) != 0)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::Permissions::isOtherRunable() const {
|
bool etk::fs::Permissions::isOtherRunable() const {
|
||||||
return ((m_rights&right_other_execute) != 0)?true:false;
|
return ((m_rights&right_other_execute) != 0)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::fileSystem::Permissions::setOtherReadable(bool _newStatus) {
|
void etk::fs::Permissions::setOtherReadable(bool _newStatus) {
|
||||||
// reset the flag:
|
// reset the flag:
|
||||||
m_rights &= (0xFFFFFFFF - right_other_read);
|
m_rights &= (0xFFFFFFFF - right_other_read);
|
||||||
if (_newStatus == true) {
|
if (_newStatus == true) {
|
||||||
@ -143,7 +143,7 @@ void etk::fileSystem::Permissions::setOtherReadable(bool _newStatus) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::fileSystem::Permissions::setOtherWritable(bool _newStatus) {
|
void etk::fs::Permissions::setOtherWritable(bool _newStatus) {
|
||||||
// reset the flag :
|
// reset the flag :
|
||||||
m_rights &= (0xFFFFFFFF - right_other_write);
|
m_rights &= (0xFFFFFFFF - right_other_write);
|
||||||
if (_newStatus == true) {
|
if (_newStatus == true) {
|
||||||
@ -151,7 +151,7 @@ void etk::fileSystem::Permissions::setOtherWritable(bool _newStatus) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::fileSystem::Permissions::setOtherRunable(bool _newStatus) {
|
void etk::fs::Permissions::setOtherRunable(bool _newStatus) {
|
||||||
// reset the flag :
|
// reset the flag :
|
||||||
m_rights &= (0xFFFFFFFF - right_other_execute);
|
m_rights &= (0xFFFFFFFF - right_other_execute);
|
||||||
if (_newStatus == true) {
|
if (_newStatus == true) {
|
||||||
@ -159,7 +159,7 @@ void etk::fileSystem::Permissions::setOtherRunable(bool _newStatus) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::String etk::fileSystem::Permissions::getRight() const {
|
etk::String etk::fs::Permissions::getRight() const {
|
||||||
etk::String tmp;
|
etk::String tmp;
|
||||||
if (isUserReadable() == true) {
|
if (isUserReadable() == true) {
|
||||||
tmp += "r";
|
tmp += "r";
|
||||||
@ -210,7 +210,7 @@ etk::String etk::fileSystem::Permissions::getRight() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::Stream& etk::operator <<(etk::Stream &_os, const etk::fileSystem::Permissions &_obj) {
|
etk::Stream& etk::operator <<(etk::Stream &_os, const etk::fs::Permissions &_obj) {
|
||||||
_os << _obj.getRight();
|
_os << _obj.getRight();
|
||||||
return _os;
|
return _os;
|
||||||
};
|
};
|
@ -11,7 +11,7 @@
|
|||||||
#include <etk/String.hpp>
|
#include <etk/String.hpp>
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
namespace fileSystem {
|
namespace fs {
|
||||||
/**
|
/**
|
||||||
* @brief File System Right management
|
* @brief File System Right management
|
||||||
*/
|
*/
|
||||||
@ -152,7 +152,7 @@ namespace etk {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
//! @not_in_doc
|
//! @not_in_doc
|
||||||
etk::Stream& operator <<(etk::Stream &_os, const etk::fileSystem::Permissions &_obj);
|
etk::Stream& operator <<(etk::Stream &_os, const etk::fs::Permissions &_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
42
etk/fs/Type.cpp
Normal file
42
etk/fs/Type.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#include <etk/types.hpp>
|
||||||
|
#include <etk/fs/Type.hpp>
|
||||||
|
|
||||||
|
etk::Stream& etk::operator <<(etk::Stream &_os, const enum etk::fs::Type &_obj) {
|
||||||
|
switch (_obj) {
|
||||||
|
case etk::fs::Type::Unknow:
|
||||||
|
_os << "etk::fs::Type::Unknow";
|
||||||
|
break;
|
||||||
|
case etk::fs::Type::Direct:
|
||||||
|
_os << "etk::fs::Type::Direct";
|
||||||
|
break;
|
||||||
|
case etk::fs::Type::Home:
|
||||||
|
_os << "etk::fs::Type::Home";
|
||||||
|
break;
|
||||||
|
case etk::fs::Type::Data:
|
||||||
|
_os << "etk::fs::Type::Data";
|
||||||
|
break;
|
||||||
|
case etk::fs::Type::UserData:
|
||||||
|
_os << "etk::fs::Type::UserData";
|
||||||
|
break;
|
||||||
|
case etk::fs::Type::Cache:
|
||||||
|
_os << "etk::fs::Type::Cache";
|
||||||
|
break;
|
||||||
|
case etk::fs::Type::Theme:
|
||||||
|
_os << "etk::fs::Type::Theme";
|
||||||
|
break;
|
||||||
|
case etk::fs::Type::ThemeData:
|
||||||
|
_os << "etk::fs::Type::Theme(DATA)";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_os << "etk::fs::Type::????";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return _os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
namespace fileSystem {
|
namespace fs {
|
||||||
/**
|
/**
|
||||||
* @brief Type of the file/folder/... accessible in the Node
|
* @brief Type of the file/folder/... accessible in the Node
|
||||||
*/
|
*/
|
||||||
@ -50,6 +50,6 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! @not_in_doc
|
//! @not_in_doc
|
||||||
etk::Stream& operator <<(etk::Stream &_os, const etk::fileSystem::Type &_obj);
|
etk::Stream& operator <<(etk::Stream &_os, const etk::fs::Type &_obj);
|
||||||
}
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
* @license MPL v2.0 (see license file)
|
* @license MPL v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
#include <etk/fileSystem/fileSystem.hpp>
|
#include <etk/fs/fileSystem.hpp>
|
||||||
#include <etk/debug.hpp>
|
#include <etk/debug.hpp>
|
||||||
|
|
||||||
#ifdef __TARGET_OS__Windows
|
#ifdef __TARGET_OS__Windows
|
||||||
@ -71,21 +71,21 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::copy(const etk::Path& _path1, const etk::Path& _path2) {
|
bool etk::fs::copy(const etk::Path& _path1, const etk::Path& _path2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::copyDirectory(const etk::Path& _path1, const etk::Path& _path2, bool _recursive) {
|
bool etk::fs::copyDirectory(const etk::Path& _path1, const etk::Path& _path2, bool _recursive) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::copyFile(const etk::Path& _path1, const etk::Path& _path2) {
|
bool etk::fs::copyFile(const etk::Path& _path1, const etk::Path& _path2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool etk::fileSystem::move(const etk::Path& _path1, const etk::Path& _path2) {
|
bool etk::fs::move(const etk::Path& _path1, const etk::Path& _path2) {
|
||||||
if (etk::fileSystem::exist(_path2) == true) {
|
if (etk::fs::exist(_path2) == true) {
|
||||||
remove(_path2);
|
remove(_path2);
|
||||||
}
|
}
|
||||||
TK_DEBUG("Move : \"" << _path1 << "\" ==> \"" << _path2 << "\"");
|
TK_DEBUG("Move : \"" << _path1 << "\" ==> \"" << _path2 << "\"");
|
||||||
@ -100,23 +100,23 @@ bool etk::fileSystem::move(const etk::Path& _path1, const etk::Path& _path2) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::moveDirectory(const etk::Path& _path1, const etk::Path& _path2) {
|
bool etk::fs::moveDirectory(const etk::Path& _path1, const etk::Path& _path2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::moveFile(const etk::Path& _path1, const etk::Path& _path2) {
|
bool etk::fs::moveFile(const etk::Path& _path1, const etk::Path& _path2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool etk::fileSystem::remove(const etk::Path& _path) {
|
bool etk::fs::remove(const etk::Path& _path) {
|
||||||
if (etk::fileSystem::isDirectory(_path) == true) {
|
if (etk::fs::isDirectory(_path) == true) {
|
||||||
return etk::fileSystem::removeDirectory(_path);
|
return etk::fs::removeDirectory(_path);
|
||||||
}
|
}
|
||||||
return etk::fileSystem::removeFile(_path);
|
return etk::fs::removeFile(_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::removeDirectory(const etk::Path& _path) {
|
bool etk::fs::removeDirectory(const etk::Path& _path) {
|
||||||
if( 0 != ::rmdir(_path.getString().c_str()) ) {
|
if( 0 != ::rmdir(_path.getString().c_str()) ) {
|
||||||
if (ENOTEMPTY == errno) {
|
if (ENOTEMPTY == errno) {
|
||||||
TK_ERROR("The Directory is not empty...");
|
TK_ERROR("The Directory is not empty...");
|
||||||
@ -126,14 +126,14 @@ bool etk::fileSystem::removeDirectory(const etk::Path& _path) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::removeFile(const etk::Path& _path) {
|
bool etk::fs::removeFile(const etk::Path& _path) {
|
||||||
if (0 != unlink(_path.getString().c_str()) ) {
|
if (0 != unlink(_path.getString().c_str()) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::touch(const etk::Path& _path) {
|
bool etk::fs::touch(const etk::Path& _path) {
|
||||||
TK_DEBUG("Touch FILE : " << _path);
|
TK_DEBUG("Touch FILE : " << _path);
|
||||||
//just open in write an close ==> this will update the time
|
//just open in write an close ==> this will update the time
|
||||||
etk::io::File file{_path};
|
etk::io::File file{_path};
|
||||||
@ -143,7 +143,7 @@ bool etk::fileSystem::touch(const etk::Path& _path) {
|
|||||||
return file.close();
|
return file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::exist(const etk::Path& _path) {
|
bool etk::fs::exist(const etk::Path& _path) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int32_t status = 0;
|
int32_t status = 0;
|
||||||
if (stat(_path.getString().c_str(), &st) != 0) {
|
if (stat(_path.getString().c_str(), &st) != 0) {
|
||||||
@ -152,7 +152,7 @@ bool etk::fileSystem::exist(const etk::Path& _path) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t etk::fileSystem::fileSize(const etk::Path& _path) {
|
uint64_t etk::fs::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
|
// 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 :
|
// tmpStat Buffer :
|
||||||
struct stat statProperty;
|
struct stat statProperty;
|
||||||
@ -168,7 +168,7 @@ uint64_t etk::fileSystem::fileSize(const etk::Path& _path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool etk::fileSystem::isDirectory(const etk::Path& _path) {
|
bool etk::fs::isDirectory(const etk::Path& _path) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int32_t status = 0;
|
int32_t status = 0;
|
||||||
if (stat(_path.getString().c_str(), &st) != 0) {
|
if (stat(_path.getString().c_str(), &st) != 0) {
|
||||||
@ -179,7 +179,7 @@ bool etk::fileSystem::isDirectory(const etk::Path& _path) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::isFile(const etk::Path& _path) {
|
bool etk::fs::isFile(const etk::Path& _path) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int32_t status = 0;
|
int32_t status = 0;
|
||||||
if (stat(_path.getString().c_str(), &st) != 0) {
|
if (stat(_path.getString().c_str(), &st) != 0) {
|
||||||
@ -190,7 +190,7 @@ bool etk::fileSystem::isFile(const etk::Path& _path) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fileSystem::isSymLink(const etk::Path& _path) {
|
bool etk::fs::isSymLink(const etk::Path& _path) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int32_t status = 0;
|
int32_t status = 0;
|
||||||
if (stat(_path.getString().c_str(), &st) != 0) {
|
if (stat(_path.getString().c_str(), &st) != 0) {
|
||||||
@ -202,8 +202,8 @@ bool etk::fileSystem::isSymLink(const etk::Path& _path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::fileSystem::Permissions etk::fileSystem::getPermission(const etk::Path& _path) {
|
etk::fs::Permissions etk::fs::getPermission(const etk::Path& _path) {
|
||||||
etk::fileSystem::Permissions permissions;
|
etk::fs::Permissions permissions;
|
||||||
// tmpStat Buffer :
|
// tmpStat Buffer :
|
||||||
struct stat statProperty;
|
struct stat statProperty;
|
||||||
if (-1 == stat(_path.getString().c_str(), &statProperty)) {
|
if (-1 == stat(_path.getString().c_str(), &statProperty)) {
|
||||||
@ -215,27 +215,27 @@ etk::fileSystem::Permissions etk::fileSystem::getPermission(const etk::Path& _pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::String etk::fileSystem::getRelativeString(const etk::Path& _path) {
|
etk::String etk::fs::getRelativeString(const etk::Path& _path) {
|
||||||
return _path.getRelative();
|
return _path.getRelative();
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::String etk::fileSystem::getAbsoluteString(const etk::Path& _path) {
|
etk::String etk::fs::getAbsoluteString(const etk::Path& _path) {
|
||||||
return _path.getAbsolute();
|
return _path.getAbsolute();
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::String etk::fileSystem::getSystemString(const etk::Path& _path) {
|
etk::String etk::fs::getSystemString(const etk::Path& _path) {
|
||||||
return _path.getNative();
|
return _path.getNative();
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::String etk::fileSystem::getMimeType(const etk::Path& _path) {
|
etk::String etk::fs::getMimeType(const etk::Path& _path) {
|
||||||
return "*";
|
return "*";
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path etk::fileSystem::getTemporaryPath() {
|
etk::Path etk::fs::getTemporaryPath() {
|
||||||
return etk::Path{};
|
return etk::Path{"/tmp/"};
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::String etk::fileSystem::getHomePathString() {
|
etk::String etk::fs::getHomePathString() {
|
||||||
static bool isInit = false;
|
static bool isInit = false;
|
||||||
static etk::String data = "";
|
static etk::String data = "";
|
||||||
if (isInit == false) {
|
if (isInit == false) {
|
||||||
@ -257,40 +257,55 @@ etk::String etk::fileSystem::getHomePathString() {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path etk::fileSystem::getHomePath() {
|
etk::Path etk::fs::getHomePath() {
|
||||||
return etk::Path(etk::fileSystem::getHomePathString());
|
return etk::Path(etk::fs::getHomePathString());
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path etk::fileSystem::getExecutionPath() {
|
etk::Path etk::fs::getExecutionPath() {
|
||||||
|
static etk::Path g_path;
|
||||||
|
if (g_path.getString() != "") {
|
||||||
|
return g_path;
|
||||||
|
}
|
||||||
|
char cCurrentPath[FILENAME_MAX];
|
||||||
|
if (!getcwd(cCurrentPath, FILENAME_MAX)) {
|
||||||
|
g_path = ".";
|
||||||
|
} else {
|
||||||
|
cCurrentPath[FILENAME_MAX - 1] = '\0';
|
||||||
|
if (cCurrentPath[0] == '/') {
|
||||||
|
g_path = cCurrentPath;
|
||||||
|
} else {
|
||||||
|
g_path = etk::String("/") + cCurrentPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return g_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::Path etk::fs::getBinaryPath() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path etk::fileSystem::getBinaryPath() {
|
etk::Path etk::fs::getDataPath() {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::Path etk::fileSystem::getDataPath() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint64_t etk::fileSystem::getCreateTime(const etk::Path& _path) {
|
uint64_t etk::fs::getCreateTime(const etk::Path& _path) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t etk::fileSystem::getModifyTime(const etk::Path& _path) {
|
uint64_t etk::fs::getModifyTime(const etk::Path& _path) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t etk::fileSystem::getAccessTime(const etk::Path& _path) {
|
uint64_t etk::fs::getAccessTime(const etk::Path& _path) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t etk::fileSystem::getIdOwner(const etk::Path& _path) {
|
uint32_t etk::fs::getIdOwner(const etk::Path& _path) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t etk::fileSystem::getIdGroup(const etk::Path& _path) {
|
uint32_t etk::fs::getIdGroup(const etk::Path& _path) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
|
|
||||||
#include <etk/fileSystem/Path.hpp>
|
#include <etk/fs/Path.hpp>
|
||||||
#include <etk/fileSystem/Permissions.hpp>
|
#include <etk/fs/Permissions.hpp>
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
namespace fileSystem {
|
namespace fs {
|
||||||
/**
|
/**
|
||||||
* @brief Copy a path to an other (if possible...)
|
* @brief Copy a path to an other (if possible...)
|
||||||
* @param[in] _path1 Path source.
|
* @param[in] _path1 Path source.
|
||||||
@ -106,7 +106,7 @@ namespace etk {
|
|||||||
bool isFile(const etk::Path& _path);
|
bool isFile(const etk::Path& _path);
|
||||||
bool isSymLink(const etk::Path& _path);
|
bool isSymLink(const etk::Path& _path);
|
||||||
|
|
||||||
etk::fileSystem::Permissions getPermission(const etk::Path& _path);
|
etk::fs::Permissions getPermission(const etk::Path& _path);
|
||||||
|
|
||||||
etk::String getRelativeString(const etk::Path& _path);
|
etk::String getRelativeString(const etk::Path& _path);
|
||||||
etk::String getDecoratedString(const etk::Path& _path);
|
etk::String getDecoratedString(const etk::Path& _path);
|
@ -6,7 +6,7 @@
|
|||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <etk/io/File.hpp>
|
#include <etk/io/File.hpp>
|
||||||
#include <etk/debug.hpp>
|
#include <etk/debug.hpp>
|
||||||
#include <etk/fileSystem/fileSystem.hpp>
|
#include <etk/fs/fileSystem.hpp>
|
||||||
|
|
||||||
|
|
||||||
etk::io::File::File() {
|
etk::io::File::File() {
|
||||||
@ -64,7 +64,7 @@ bool etk::io::File::close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t etk::io::File::size() {
|
uint64_t etk::io::File::size() {
|
||||||
return etk::fileSystem::fileSize(m_path);
|
return etk::fs::fileSize(m_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool etk::io::File::seek(uint64_t _offset, enum etk::io::SeekMode _origin) {
|
bool etk::io::File::seek(uint64_t _offset, enum etk::io::SeekMode _origin) {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <etk/io/Interface.hpp>
|
#include <etk/io/Interface.hpp>
|
||||||
#include <etk/io/File.hpp>
|
#include <etk/io/File.hpp>
|
||||||
#include <etk/fileSystem/Path.hpp>
|
#include <etk/fs/Path.hpp>
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
namespace io {
|
namespace io {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <etk/io/Interface.hpp>
|
#include <etk/io/Interface.hpp>
|
||||||
#include <etk/fileSystem/Path.hpp>
|
#include <etk/fs/Path.hpp>
|
||||||
#include <ememory/SharedPtr.hpp>
|
#include <ememory/SharedPtr.hpp>
|
||||||
#include <etk/archive/Archive.hpp>
|
#include <etk/archive/Archive.hpp>
|
||||||
|
|
||||||
|
16
lutin_etk.py
16
lutin_etk.py
@ -34,10 +34,10 @@ def configure(target, my_module):
|
|||||||
'etk/Noise.cpp',
|
'etk/Noise.cpp',
|
||||||
'etk/Color.cpp',
|
'etk/Color.cpp',
|
||||||
'etk/RegEx.cpp',
|
'etk/RegEx.cpp',
|
||||||
'etk/fileSystem/fileSystem.cpp',
|
'etk/fs/fileSystem.cpp',
|
||||||
'etk/fileSystem/Path.cpp',
|
'etk/fs/Path.cpp',
|
||||||
'etk/fileSystem/Permissions.cpp',
|
'etk/fs/Permissions.cpp',
|
||||||
'etk/fileSystem/Type.cpp',
|
'etk/fs/Type.cpp',
|
||||||
'etk/io/OpenMode.cpp',
|
'etk/io/OpenMode.cpp',
|
||||||
'etk/io/SeekMode.cpp',
|
'etk/io/SeekMode.cpp',
|
||||||
'etk/io/Interface.cpp',
|
'etk/io/Interface.cpp',
|
||||||
@ -67,10 +67,10 @@ def configure(target, my_module):
|
|||||||
'etk/Noise.hpp',
|
'etk/Noise.hpp',
|
||||||
'etk/Color.hpp',
|
'etk/Color.hpp',
|
||||||
'etk/RegEx.hpp',
|
'etk/RegEx.hpp',
|
||||||
'etk/fileSystem/fileSystem.hpp',
|
'etk/fs/fileSystem.hpp',
|
||||||
'etk/fileSystem/Path.hpp',
|
'etk/fs/Path.hpp',
|
||||||
'etk/fileSystem/Permissions.hpp',
|
'etk/fs/Permissions.hpp',
|
||||||
'etk/fileSystem/Type.hpp',
|
'etk/fs/Type.hpp',
|
||||||
'etk/io/OpenMode.hpp',
|
'etk/io/OpenMode.hpp',
|
||||||
'etk/io/SeekMode.hpp',
|
'etk/io/SeekMode.hpp',
|
||||||
'etk/io/Interface.hpp',
|
'etk/io/Interface.hpp',
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
|
|
||||||
#include <etest/etest.hpp>
|
#include <etest/etest.hpp>
|
||||||
#include <test-debug/debug.hpp>
|
#include <test-debug/debug.hpp>
|
||||||
#include <etk/fileSystem/fileSystem.hpp>
|
#include <etk/fs/fileSystem.hpp>
|
||||||
|
|
||||||
TEST(TestFileSystem, checkHomePath) {
|
TEST(TestFileSystem, checkHomePath) {
|
||||||
etk::String basicPath = getenv("HOME");
|
etk::String basicPath = getenv("HOME");
|
||||||
EXPECT_EQ(etk::fileSystem::getHomePath(), basicPath);
|
EXPECT_EQ(etk::fs::getHomePath(), basicPath);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
TEST(TestEtkFSNode, checkHomePath) {
|
TEST(TestEtkFSNode, checkHomePath) {
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
#include <etest/etest.hpp>
|
#include <etest/etest.hpp>
|
||||||
#include <test-debug/debug.hpp>
|
#include <test-debug/debug.hpp>
|
||||||
#include <etk/fileSystem/Path.hpp>
|
#include <etk/fs/Path.hpp>
|
||||||
|
#include <etk/fs/fileSystem.hpp>
|
||||||
|
|
||||||
TEST(TestPath, defaultContructor) {
|
TEST(TestPath, defaultContructor) {
|
||||||
etk::Path path;
|
etk::Path path;
|
||||||
@ -48,7 +49,7 @@ TEST(TestPath, basic_absolute) {
|
|||||||
|
|
||||||
TEST(TestPath, basic_absolute_windows) {
|
TEST(TestPath, basic_absolute_windows) {
|
||||||
etk::Path path("k:\\");
|
etk::Path path("k:\\");
|
||||||
EXPECT_EQ(path.getString(), "/k/");
|
EXPECT_EQ(path.getString(), "/k");
|
||||||
EXPECT_EQ(path.getStringWindows(), "k:\\");
|
EXPECT_EQ(path.getStringWindows(), "k:\\");
|
||||||
EXPECT_EQ(path.isRelative(), false);
|
EXPECT_EQ(path.isRelative(), false);
|
||||||
EXPECT_EQ(path.isAbsolute(), true);
|
EXPECT_EQ(path.isAbsolute(), true);
|
||||||
@ -89,6 +90,65 @@ TEST(TestPath, simplification) {
|
|||||||
EXPECT_EQ(path.getString(), "/plouf");
|
EXPECT_EQ(path.getString(), "/plouf");
|
||||||
path = "/home/plouf/../";
|
path = "/home/plouf/../";
|
||||||
EXPECT_EQ(path.getString(), "/home");
|
EXPECT_EQ(path.getString(), "/home");
|
||||||
path = "/home/plouf/plaf/./././pluf/plouc/../../../mioch/narn/miasm/../";
|
path = "/home/plouf/plaf/./././pluf/plouc/../../../mioch/narn////miasm/../";
|
||||||
EXPECT_EQ(path.getString(), "/home/plouf/mioch/narn");
|
EXPECT_EQ(path.getString(), "/home/plouf/mioch/narn");
|
||||||
|
path = "../../hello";
|
||||||
|
EXPECT_EQ(path.getString(), "../../hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(TestPath, fileName) {
|
||||||
|
etk::Path path("/home/plouf.pdf");
|
||||||
|
EXPECT_EQ(path.getFileName(), "plouf.pdf");
|
||||||
|
path = "plouf.pdf";
|
||||||
|
EXPECT_EQ(path.getFileName(), "plouf.pdf");
|
||||||
|
path = "/hello/plouf";
|
||||||
|
EXPECT_EQ(path.getFileName(), "plouf");
|
||||||
|
path = "/plouf";
|
||||||
|
EXPECT_EQ(path.getFileName(), "plouf");
|
||||||
|
path = "/";
|
||||||
|
EXPECT_EQ(path.getFileName(), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(TestPath, extention) {
|
||||||
|
etk::Path path("/home/plouf.pdf");
|
||||||
|
EXPECT_EQ(path.getExtention(), "pdf");
|
||||||
|
path = "plouf.ma-super-extention";
|
||||||
|
EXPECT_EQ(path.getExtention(), "ma-super-extention");
|
||||||
|
path = "/home/plouf";
|
||||||
|
EXPECT_EQ(path.getExtention(), "");
|
||||||
|
path = "/ho.me/plouf";
|
||||||
|
EXPECT_EQ(path.getExtention(), "");
|
||||||
|
path = "/ho.me/.plouf";
|
||||||
|
EXPECT_EQ(path.getExtention(), "");
|
||||||
|
path = ".plouf";
|
||||||
|
EXPECT_EQ(path.getExtention(), "");
|
||||||
|
path = ".plouf.hello.pdf";
|
||||||
|
EXPECT_EQ(path.getExtention(), "pdf");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(TestPath, parent) {
|
||||||
|
etk::Path path("/home/plouf.pdf");
|
||||||
|
EXPECT_EQ(path.getParent(), "/home/");
|
||||||
|
path = "/home/plouf/plaf/plop";
|
||||||
|
EXPECT_EQ(path.getParent(), "/home/plouf/plaf");
|
||||||
|
path.parent();
|
||||||
|
EXPECT_EQ(path.getString(), "/home/plouf/plaf");
|
||||||
|
path = "/";
|
||||||
|
EXPECT_EQ(path.getParent(), "/");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(TestPath, getRelative) {
|
||||||
|
etk::Path path("plouf.pdf");
|
||||||
|
EXPECT_EQ(path.getRelative(), "plouf.pdf");
|
||||||
|
path = "/plouf.pdf";
|
||||||
|
EXPECT_EQ(path.getRelative(), "../../../../plouf.pdf");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(TestPath, getAbsolute) {
|
||||||
|
etk::Path path("plouf.pdf");
|
||||||
|
EXPECT_EQ(path.getAbsolute(), (etk::fs::getExecutionPath() / "plouf.pdf").getString());
|
||||||
|
path = "/plouf.pdf";
|
||||||
|
EXPECT_EQ(path.getAbsolute(), "/plouf.pdf");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
|
|
||||||
#include <etest/etest.hpp>
|
#include <etest/etest.hpp>
|
||||||
#include <test-debug/debug.hpp>
|
#include <test-debug/debug.hpp>
|
||||||
#include <etk/fileSystem/Permissions.hpp>
|
#include <etk/fs/Permissions.hpp>
|
||||||
|
|
||||||
TEST(TestPermission, defaultContructor) {
|
TEST(TestPermission, defaultContructor) {
|
||||||
etk::fileSystem::Permissions permission;
|
etk::fs::Permissions permission;
|
||||||
EXPECT_EQ(permission.isUserReadable(), false);
|
EXPECT_EQ(permission.isUserReadable(), false);
|
||||||
EXPECT_EQ(permission.isUserWritable(), false);
|
EXPECT_EQ(permission.isUserWritable(), false);
|
||||||
EXPECT_EQ(permission.isUserRunable(), false);
|
EXPECT_EQ(permission.isUserRunable(), false);
|
||||||
@ -26,7 +26,7 @@ TEST(TestPermission, defaultContructor) {
|
|||||||
|
|
||||||
|
|
||||||
TEST(TestPermission, fullright) {
|
TEST(TestPermission, fullright) {
|
||||||
etk::fileSystem::Permissions permission(0777);
|
etk::fs::Permissions permission(0777);
|
||||||
EXPECT_EQ(permission.isUserReadable(), true);
|
EXPECT_EQ(permission.isUserReadable(), true);
|
||||||
EXPECT_EQ(permission.isUserWritable(), true);
|
EXPECT_EQ(permission.isUserWritable(), true);
|
||||||
EXPECT_EQ(permission.isUserRunable(), true);
|
EXPECT_EQ(permission.isUserRunable(), true);
|
||||||
@ -41,7 +41,7 @@ TEST(TestPermission, fullright) {
|
|||||||
|
|
||||||
|
|
||||||
TEST(TestPermission, user) {
|
TEST(TestPermission, user) {
|
||||||
etk::fileSystem::Permissions permission(0700);
|
etk::fs::Permissions permission(0700);
|
||||||
EXPECT_EQ(permission.isUserReadable(), true);
|
EXPECT_EQ(permission.isUserReadable(), true);
|
||||||
EXPECT_EQ(permission.isUserWritable(), true);
|
EXPECT_EQ(permission.isUserWritable(), true);
|
||||||
EXPECT_EQ(permission.isUserRunable(), true);
|
EXPECT_EQ(permission.isUserRunable(), true);
|
||||||
@ -56,7 +56,7 @@ TEST(TestPermission, user) {
|
|||||||
|
|
||||||
|
|
||||||
TEST(TestPermission, group) {
|
TEST(TestPermission, group) {
|
||||||
etk::fileSystem::Permissions permission(0070);
|
etk::fs::Permissions permission(0070);
|
||||||
EXPECT_EQ(permission.isUserReadable(), false);
|
EXPECT_EQ(permission.isUserReadable(), false);
|
||||||
EXPECT_EQ(permission.isUserWritable(), false);
|
EXPECT_EQ(permission.isUserWritable(), false);
|
||||||
EXPECT_EQ(permission.isUserRunable(), false);
|
EXPECT_EQ(permission.isUserRunable(), false);
|
||||||
@ -71,7 +71,7 @@ TEST(TestPermission, group) {
|
|||||||
|
|
||||||
|
|
||||||
TEST(TestPermission, other) {
|
TEST(TestPermission, other) {
|
||||||
etk::fileSystem::Permissions permission(0007);
|
etk::fs::Permissions permission(0007);
|
||||||
EXPECT_EQ(permission.isUserReadable(), false);
|
EXPECT_EQ(permission.isUserReadable(), false);
|
||||||
EXPECT_EQ(permission.isUserWritable(), false);
|
EXPECT_EQ(permission.isUserWritable(), false);
|
||||||
EXPECT_EQ(permission.isUserRunable(), false);
|
EXPECT_EQ(permission.isUserRunable(), false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user