[DEV] change etk::fs in etk::path
This commit is contained in:
parent
0997e7a39d
commit
9b318f4cac
@ -11,7 +11,7 @@
|
||||
#include <etk/Map.hpp>
|
||||
#include <ethread/Mutex.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <etk/fs/Path.hpp>
|
||||
#include <etk/path/Path.hpp>
|
||||
#include <etk/uri/Uri.hpp>
|
||||
|
||||
namespace etk {
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <etk/typeInfo.hpp>
|
||||
#include <etk/Allocator.hpp>
|
||||
#include <etk/theme/theme.hpp>
|
||||
#include <etk/fs/fileSystem.hpp>
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
#include <etk/uri/provider/provider.hpp>
|
||||
|
||||
static int32_t nbTimeInit = 0;
|
||||
@ -48,7 +48,7 @@ void etk::init(int _argc, const char** _argv) {
|
||||
} else {
|
||||
TK_INFO("ETK system init (BEGIN) ");
|
||||
}
|
||||
elog::init(_argc, _argv, etk::fs::getBinaryName());
|
||||
elog::init(_argc, _argv, etk::path::getBinaryName());
|
||||
etk::uri::provider::init();
|
||||
etk::theme::init();
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
@ -82,5 +82,5 @@ void etk::init(int _argc, const char** _argv) {
|
||||
}
|
||||
|
||||
etk::String etk::getApplicationName() {
|
||||
return etk::fs::getBinaryName();
|
||||
return etk::path::getBinaryName();
|
||||
}
|
||||
|
@ -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/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;
|
||||
}
|
||||
|
||||
|
@ -1,55 +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/Stream.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace etk {
|
||||
namespace fs {
|
||||
/**
|
||||
* @brief Type of the file/folder/... accessible in the Node
|
||||
*/
|
||||
enum class Type {
|
||||
Unknow, //!< Unknow type of the node (many time no file name seted)
|
||||
// user might done abstraction ==> acces of the sdcard when possible ...
|
||||
Direct, //!< Access at the file System with a direct naming like "/home/plop/xxx.txt"
|
||||
// depend on case
|
||||
// - PC : ~/
|
||||
// - Android : /sdcard/
|
||||
// - Apple : ????
|
||||
Home, //!< acces at the home path of the system (with name of the current user)
|
||||
// depend of the case
|
||||
// - PC : /usr/shared/programName/
|
||||
// - Android : Internal at the executable file (pointer on static area)
|
||||
// - Apple : Internal at the executable file
|
||||
Data, //!< Access on the application data (internal application data are the one provided with the binary)
|
||||
// depend on case
|
||||
// - PC : ~/.local/programName/
|
||||
// - Android : /data/data/programName/files/
|
||||
// - Apple : ????
|
||||
UserData, //!< Access on the user application data (where the data are stored when the application stop)
|
||||
// depend on case
|
||||
// - PC : ~/.programName/cache/
|
||||
// - Android : /data/data/programName/cache/
|
||||
// - Apple : ????
|
||||
Cache, //!< Access on the application temporary path (remove when user want and whe the compter restart or have not enought memory)
|
||||
// depend on case
|
||||
// - try on USER_DATA:/theme/themeName/xxx
|
||||
// - try on DATA:/theme/themeName/xxx
|
||||
// and jump to the default theme file
|
||||
// - try on USER_DATA:/theme/default/xxx
|
||||
// - try on DATA:/theme/default/xxx
|
||||
Theme, //!< Theme area
|
||||
ThemeData //!< Theme data area
|
||||
};
|
||||
}
|
||||
|
||||
//! @not_in_doc
|
||||
etk::Stream& operator <<(etk::Stream &_os, const etk::fs::Type &_obj);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/io/File.hpp>
|
||||
#include <etk/debug.hpp>
|
||||
#include <etk/fs/fileSystem.hpp>
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
#include <sys/stat.h>
|
||||
extern "C" {
|
||||
#include <errno.h>
|
||||
@ -67,7 +67,7 @@ bool etk::io::File::close() {
|
||||
}
|
||||
|
||||
uint64_t etk::io::File::size() {
|
||||
return etk::fs::fileSize(m_path);
|
||||
return etk::path::fileSize(m_path);
|
||||
}
|
||||
|
||||
bool etk::io::File::seek(uint64_t _offset, enum etk::io::SeekMode _origin) {
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/io/Interface.hpp>
|
||||
#include <etk/io/File.hpp>
|
||||
#include <etk/fs/Path.hpp>
|
||||
#include <etk/path/Path.hpp>
|
||||
|
||||
namespace etk {
|
||||
namespace io {
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/io/Interface.hpp>
|
||||
#include <etk/fs/Path.hpp>
|
||||
#include <etk/path/Path.hpp>
|
||||
#include <ememory/SharedPtr.hpp>
|
||||
#include <etk/archive/Archive.hpp>
|
||||
|
||||
|
@ -3,10 +3,10 @@
|
||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#include <etk/fs/Path.hpp>
|
||||
#include <etk/path/Path.hpp>
|
||||
#include <etk/debug.hpp>
|
||||
#include <etk/Exception.hpp>
|
||||
#include <etk/fs/fileSystem.hpp>
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(etk::Path);
|
||||
@ -23,7 +23,7 @@ static etk::String simplifyPath(etk::String _input) {
|
||||
return _input;
|
||||
}
|
||||
if (_input[0] == '~') {
|
||||
_input = etk::fs::getHomePath().getString() + "/" + _input.extract(1);
|
||||
_input = etk::path::getHomePath().getString() + "/" + _input.extract(1);
|
||||
}
|
||||
// step 2 : remove all '//'
|
||||
TK_DBG_MODE("Simplify(2) : '" << _input << "'");
|
||||
@ -192,7 +192,7 @@ etk::String etk::Path::getRelative() const {
|
||||
if (isRelative() == true) {
|
||||
return m_data;
|
||||
}
|
||||
etk::String execPath = etk::fs::getExecutionPath().getString();
|
||||
etk::String execPath = etk::path::getExecutionPath().getString();
|
||||
etk::String currentPath = m_data;
|
||||
etk::Vector<etk::String> execPathSplit = execPath.split('/');
|
||||
etk::Vector<etk::String> currentPathSplit = currentPath.split('/');
|
||||
@ -235,7 +235,7 @@ etk::String etk::Path::getAbsolute() const {
|
||||
if (isAbsolute() == true) {
|
||||
return m_data;
|
||||
}
|
||||
return (etk::fs::getExecutionPath() / m_data).getString();
|
||||
return (etk::path::getExecutionPath() / m_data).getString();
|
||||
}
|
||||
|
||||
etk::String etk::Path::getAbsoluteWindows() const {
|
@ -6,7 +6,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/fs/Type.hpp>
|
||||
#include <etk/String.hpp>
|
||||
|
||||
namespace etk {
|
@ -7,11 +7,11 @@
|
||||
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
#include <etk/fs/Permissions.hpp>
|
||||
#include <etk/path/Permissions.hpp>
|
||||
|
||||
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(etk::fs::Permissions);
|
||||
ETK_DECLARE_TYPE(etk::path::Permissions);
|
||||
|
||||
|
||||
// Right Flags:
|
||||
@ -28,45 +28,45 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
etk::fs::Permissions etk::fs::Permissions::genericFolder{right_user_execute|right_user_write|right_user_read|right_group_read|right_group_execute};
|
||||
etk::fs::Permissions etk::fs::Permissions::genericFile{right_user_write|right_user_read|right_group_read};
|
||||
etk::path::Permissions etk::path::Permissions::genericFolder{right_user_execute|right_user_write|right_user_read|right_group_read|right_group_execute};
|
||||
etk::path::Permissions etk::path::Permissions::genericFile{right_user_write|right_user_read|right_group_read};
|
||||
|
||||
etk::fs::Permissions::Permissions(uint16_t _newRight) :
|
||||
etk::path::Permissions::Permissions(uint16_t _newRight) :
|
||||
m_rights(_newRight&0x01FF) {
|
||||
|
||||
}
|
||||
|
||||
uint16_t etk::fs::Permissions::getRightValue() const {
|
||||
uint16_t etk::path::Permissions::getRightValue() const {
|
||||
return m_rights;
|
||||
}
|
||||
|
||||
etk::fs::Permissions& etk::fs::Permissions::operator= (const etk::fs::Permissions &_obj ) {
|
||||
etk::path::Permissions& etk::path::Permissions::operator= (const etk::path::Permissions &_obj ) {
|
||||
m_rights = _obj.m_rights;
|
||||
return *this;
|
||||
}
|
||||
|
||||
etk::fs::Permissions& etk::fs::Permissions::operator= (const uint32_t _newVal) {
|
||||
etk::path::Permissions& etk::path::Permissions::operator= (const uint32_t _newVal) {
|
||||
m_rights = _newVal&0x01FF;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void etk::fs::Permissions::clear() {
|
||||
void etk::path::Permissions::clear() {
|
||||
m_rights = 0;
|
||||
}
|
||||
|
||||
bool etk::fs::Permissions::isUserReadable() const {
|
||||
bool etk::path::Permissions::isUserReadable() const {
|
||||
return ((m_rights&right_user_read)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::fs::Permissions::isUserWritable() const {
|
||||
bool etk::path::Permissions::isUserWritable() const {
|
||||
return ((m_rights&right_user_write)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::fs::Permissions::isUserRunable() const {
|
||||
bool etk::path::Permissions::isUserRunable() const {
|
||||
return ((m_rights&right_user_execute)!=0)?true:false;
|
||||
}
|
||||
|
||||
void etk::fs::Permissions::setUserReadable(bool _newStatus) {
|
||||
void etk::path::Permissions::setUserReadable(bool _newStatus) {
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - right_user_read);
|
||||
if (_newStatus == true) {
|
||||
@ -74,7 +74,7 @@ void etk::fs::Permissions::setUserReadable(bool _newStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
void etk::fs::Permissions::setUserWritable(bool _newStatus) {
|
||||
void etk::path::Permissions::setUserWritable(bool _newStatus) {
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - right_user_write);
|
||||
if (_newStatus == true) {
|
||||
@ -82,7 +82,7 @@ void etk::fs::Permissions::setUserWritable(bool _newStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
void etk::fs::Permissions::setUserRunable(bool _newStatus) {
|
||||
void etk::path::Permissions::setUserRunable(bool _newStatus) {
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - right_user_execute);
|
||||
if (_newStatus == true) {
|
||||
@ -90,19 +90,19 @@ void etk::fs::Permissions::setUserRunable(bool _newStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
bool etk::fs::Permissions::isGroupReadable() const {
|
||||
bool etk::path::Permissions::isGroupReadable() const {
|
||||
return ((m_rights&right_group_read)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::fs::Permissions::isGroupWritable() const {
|
||||
bool etk::path::Permissions::isGroupWritable() const {
|
||||
return ((m_rights&right_group_write)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::fs::Permissions::isGroupRunable() const {
|
||||
bool etk::path::Permissions::isGroupRunable() const {
|
||||
return ((m_rights&right_group_execute)!=0)?true:false;
|
||||
}
|
||||
|
||||
void etk::fs::Permissions::setGroupReadable(bool _newStatus) {
|
||||
void etk::path::Permissions::setGroupReadable(bool _newStatus) {
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - right_group_read);
|
||||
if (true == _newStatus) {
|
||||
@ -110,7 +110,7 @@ void etk::fs::Permissions::setGroupReadable(bool _newStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
void etk::fs::Permissions::setGroupWritable(bool _newStatus) {
|
||||
void etk::path::Permissions::setGroupWritable(bool _newStatus) {
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - right_group_write);
|
||||
if (true == _newStatus) {
|
||||
@ -118,7 +118,7 @@ void etk::fs::Permissions::setGroupWritable(bool _newStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
void etk::fs::Permissions::setGroupRunable(bool _newStatus) {
|
||||
void etk::path::Permissions::setGroupRunable(bool _newStatus) {
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - right_group_execute);
|
||||
if (true == _newStatus) {
|
||||
@ -126,19 +126,19 @@ void etk::fs::Permissions::setGroupRunable(bool _newStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
bool etk::fs::Permissions::isOtherReadable() const {
|
||||
bool etk::path::Permissions::isOtherReadable() const {
|
||||
return ((m_rights&right_other_read) != 0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::fs::Permissions::isOtherWritable() const {
|
||||
bool etk::path::Permissions::isOtherWritable() const {
|
||||
return ((m_rights&right_other_write) != 0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::fs::Permissions::isOtherRunable() const {
|
||||
bool etk::path::Permissions::isOtherRunable() const {
|
||||
return ((m_rights&right_other_execute) != 0)?true:false;
|
||||
}
|
||||
|
||||
void etk::fs::Permissions::setOtherReadable(bool _newStatus) {
|
||||
void etk::path::Permissions::setOtherReadable(bool _newStatus) {
|
||||
// reset the flag:
|
||||
m_rights &= (0xFFFFFFFF - right_other_read);
|
||||
if (_newStatus == true) {
|
||||
@ -146,7 +146,7 @@ void etk::fs::Permissions::setOtherReadable(bool _newStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
void etk::fs::Permissions::setOtherWritable(bool _newStatus) {
|
||||
void etk::path::Permissions::setOtherWritable(bool _newStatus) {
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - right_other_write);
|
||||
if (_newStatus == true) {
|
||||
@ -154,7 +154,7 @@ void etk::fs::Permissions::setOtherWritable(bool _newStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
void etk::fs::Permissions::setOtherRunable(bool _newStatus) {
|
||||
void etk::path::Permissions::setOtherRunable(bool _newStatus) {
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - right_other_execute);
|
||||
if (_newStatus == true) {
|
||||
@ -162,7 +162,7 @@ void etk::fs::Permissions::setOtherRunable(bool _newStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
etk::String etk::fs::Permissions::getRight() const {
|
||||
etk::String etk::path::Permissions::getRight() const {
|
||||
etk::String tmp;
|
||||
if (isUserReadable() == true) {
|
||||
tmp += "r";
|
||||
@ -213,7 +213,7 @@ etk::String etk::fs::Permissions::getRight() const {
|
||||
}
|
||||
|
||||
|
||||
etk::Stream& etk::operator <<(etk::Stream &_os, const etk::fs::Permissions &_obj) {
|
||||
etk::Stream& etk::operator <<(etk::Stream &_os, const etk::path::Permissions &_obj) {
|
||||
_os << _obj.getRight();
|
||||
return _os;
|
||||
};
|
@ -11,7 +11,7 @@
|
||||
#include <etk/String.hpp>
|
||||
|
||||
namespace etk {
|
||||
namespace fs {
|
||||
namespace path {
|
||||
/**
|
||||
* @brief File System Right management
|
||||
*/
|
||||
@ -155,7 +155,7 @@ namespace etk {
|
||||
};
|
||||
}
|
||||
//! @not_in_doc
|
||||
etk::Stream& operator <<(etk::Stream &_os, const etk::fs::Permissions &_obj);
|
||||
etk::Stream& operator <<(etk::Stream &_os, const etk::path::Permissions &_obj);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#include <etk/fs/fileSystem.hpp>
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
#include <etk/debug.hpp>
|
||||
|
||||
#ifdef __TARGET_OS__Windows
|
||||
@ -29,26 +29,26 @@ extern "C" {
|
||||
#include <etk/io/File.hpp>
|
||||
#include <etk/io/SeekMode.hpp>
|
||||
|
||||
bool etk::fs::copy(const etk::Path& _path1, const etk::Path& _path2) {
|
||||
bool etk::path::copy(const etk::Path& _path1, const etk::Path& _path2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool etk::fs::copyDirectory(const etk::Path& _path1, const etk::Path& _path2, bool _recursive) {
|
||||
bool etk::path::copyDirectory(const etk::Path& _path1, const etk::Path& _path2, bool _recursive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool etk::fs::copyFile(const etk::Path& _path1, const etk::Path& _path2) {
|
||||
bool etk::path::copyFile(const etk::Path& _path1, const etk::Path& _path2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool etk::fs::move(const etk::Path& _path1, const etk::Path& _path2) {
|
||||
bool etk::path::move(const etk::Path& _path1, const etk::Path& _path2) {
|
||||
TK_VERBOSE("Move : \"" << _path1 << "\" ==> \"" << _path2 << "\"");
|
||||
if (etk::fs::exist(_path2) == true) {
|
||||
if (etk::path::exist(_path2) == true) {
|
||||
removes(_path2);
|
||||
}
|
||||
// create path to be sure it exist ...
|
||||
etk::fs::makeDirectories(_path2.getParent());
|
||||
etk::path::makeDirectories(_path2.getParent());
|
||||
int32_t res = ::rename(_path1.getNative().c_str(), _path2.getNative().c_str());
|
||||
if (res != 0) {
|
||||
TK_ERROR("Can not move the file: '" << _path1 << "' ==> '" << _path2 << "' errno" << errno << " (" << strerror(errno) << ")");
|
||||
@ -57,27 +57,27 @@ bool etk::fs::move(const etk::Path& _path1, const etk::Path& _path2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool etk::fs::moveDirectory(const etk::Path& _path1, const etk::Path& _path2) {
|
||||
return etk::fs::move(_path1, _path2);
|
||||
bool etk::path::moveDirectory(const etk::Path& _path1, const etk::Path& _path2) {
|
||||
return etk::path::move(_path1, _path2);
|
||||
}
|
||||
|
||||
bool etk::fs::moveFile(const etk::Path& _path1, const etk::Path& _path2) {
|
||||
return etk::fs::move(_path1, _path2);
|
||||
bool etk::path::moveFile(const etk::Path& _path1, const etk::Path& _path2) {
|
||||
return etk::path::move(_path1, _path2);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
bool removeDirectories(const etk::Path& _path, bool _recursive);
|
||||
bool removes(const etk::Path& _path, bool _recursive) {
|
||||
TK_VERBOSE("remove: " << _path);
|
||||
if (etk::fs::isDirectory(_path) == true) {
|
||||
if (etk::path::isDirectory(_path) == true) {
|
||||
return detail::removeDirectories(_path, _recursive);
|
||||
}
|
||||
return etk::fs::removeFile(_path);
|
||||
return etk::path::removeFile(_path);
|
||||
}
|
||||
bool removeDirectories(const etk::Path& _path, bool _recursive) {
|
||||
TK_VERBOSE("remove Directory: " << _path);
|
||||
if (_recursive == true) {
|
||||
etk::Vector<etk::Path> elements = etk::fs::list(_path);
|
||||
etk::Vector<etk::Path> elements = etk::path::list(_path);
|
||||
for (auto& it : elements) {
|
||||
detail::removes(it, _recursive);
|
||||
}
|
||||
@ -92,23 +92,23 @@ namespace detail {
|
||||
}
|
||||
}
|
||||
|
||||
bool etk::fs::remove(const etk::Path& _path) {
|
||||
bool etk::path::remove(const etk::Path& _path) {
|
||||
return detail::removes(_path, false);
|
||||
}
|
||||
|
||||
bool etk::fs::removes(const etk::Path& _path) {
|
||||
bool etk::path::removes(const etk::Path& _path) {
|
||||
return detail::removes(_path, true);
|
||||
}
|
||||
|
||||
bool etk::fs::removeDirectory(const etk::Path& _path) {
|
||||
bool etk::path::removeDirectory(const etk::Path& _path) {
|
||||
return detail::removeDirectories(_path, false);
|
||||
}
|
||||
|
||||
bool etk::fs::removeDirectories(const etk::Path& _path) {
|
||||
bool etk::path::removeDirectories(const etk::Path& _path) {
|
||||
return detail::removeDirectories(_path, true);
|
||||
}
|
||||
|
||||
bool etk::fs::removeFile(const etk::Path& _path) {
|
||||
bool etk::path::removeFile(const etk::Path& _path) {
|
||||
TK_VERBOSE("remove File: " << _path);
|
||||
if (0 != unlink(_path.getNative().c_str()) ) {
|
||||
return false;
|
||||
@ -116,9 +116,9 @@ bool etk::fs::removeFile(const etk::Path& _path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool etk::fs::makeDirectory(const etk::Path& _path, etk::fs::Permissions _permission) {
|
||||
bool etk::path::makeDirectory(const etk::Path& _path, etk::path::Permissions _permission) {
|
||||
TK_VERBOSE("Make directory : " << _path << " perm: " << _permission);
|
||||
if (etk::fs::exist(_path) == true) {
|
||||
if (etk::path::exist(_path) == true) {
|
||||
return true;
|
||||
}
|
||||
#ifdef __TARGET_OS__Windows
|
||||
@ -136,9 +136,9 @@ bool etk::fs::makeDirectory(const etk::Path& _path, etk::fs::Permissions _permis
|
||||
return true;
|
||||
}
|
||||
|
||||
bool etk::fs::makeDirectories(const etk::Path& _path, etk::fs::Permissions _permission) {
|
||||
bool etk::path::makeDirectories(const etk::Path& _path, etk::path::Permissions _permission) {
|
||||
TK_VERBOSE("Make dirrectories: " << _path << " perm: " << _permission);
|
||||
if (etk::fs::exist(_path) == true) {
|
||||
if (etk::path::exist(_path) == true) {
|
||||
return true;
|
||||
}
|
||||
auto elements = _path.getNative().split('/');
|
||||
@ -149,16 +149,16 @@ bool etk::fs::makeDirectories(const etk::Path& _path, etk::fs::Permissions _perm
|
||||
}
|
||||
for (auto& it: elements) {
|
||||
pathToCreate /= it;
|
||||
if (etk::fs::makeDirectory(pathToCreate, _permission) == false) {
|
||||
if (etk::path::makeDirectory(pathToCreate, _permission) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool etk::fs::touch(const etk::Path& _path) {
|
||||
bool etk::path::touch(const etk::Path& _path) {
|
||||
TK_VERBOSE("Touch FILE : " << _path);
|
||||
if (etk::fs::exist(_path) == true ) {
|
||||
if (etk::path::exist(_path) == true ) {
|
||||
int rc = utimensat(0,
|
||||
_path.getAbsoluteNative().c_str(),
|
||||
NULL,
|
||||
@ -176,14 +176,14 @@ bool etk::fs::touch(const etk::Path& _path) {
|
||||
return file.close();
|
||||
}
|
||||
|
||||
bool etk::fs::exist(const etk::Path& _path) {
|
||||
bool etk::path::exist(const etk::Path& _path) {
|
||||
if (::access( _path.getNative().c_str(), F_OK ) != -1 ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t etk::fs::fileSize(const etk::Path& _path) {
|
||||
uint64_t etk::path::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;
|
||||
@ -199,7 +199,7 @@ uint64_t etk::fs::fileSize(const etk::Path& _path) {
|
||||
}
|
||||
|
||||
|
||||
bool etk::fs::isDirectory(const etk::Path& _path) {
|
||||
bool etk::path::isDirectory(const etk::Path& _path) {
|
||||
struct stat st;
|
||||
int32_t status = 0;
|
||||
if (stat(_path.getNative().c_str(), &st) != 0) {
|
||||
@ -210,7 +210,7 @@ bool etk::fs::isDirectory(const etk::Path& _path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool etk::fs::isFile(const etk::Path& _path) {
|
||||
bool etk::path::isFile(const etk::Path& _path) {
|
||||
struct stat st;
|
||||
int32_t status = 0;
|
||||
if (stat(_path.getNative().c_str(), &st) != 0) {
|
||||
@ -221,7 +221,7 @@ bool etk::fs::isFile(const etk::Path& _path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool etk::fs::isSymLink(const etk::Path& _path) {
|
||||
bool etk::path::isSymLink(const etk::Path& _path) {
|
||||
struct stat st;
|
||||
int32_t status = 0;
|
||||
if (stat(_path.getNative().c_str(), &st) != 0) {
|
||||
@ -233,8 +233,8 @@ bool etk::fs::isSymLink(const etk::Path& _path) {
|
||||
}
|
||||
|
||||
|
||||
etk::fs::Permissions etk::fs::getPermission(const etk::Path& _path) {
|
||||
etk::fs::Permissions permissions;
|
||||
etk::path::Permissions etk::path::getPermission(const etk::Path& _path) {
|
||||
etk::path::Permissions permissions;
|
||||
// tmpStat Buffer :
|
||||
struct stat statProperty;
|
||||
if (-1 == stat(_path.getNative().c_str(), &statProperty)) {
|
||||
@ -246,25 +246,25 @@ etk::fs::Permissions etk::fs::getPermission(const etk::Path& _path) {
|
||||
}
|
||||
|
||||
|
||||
etk::String etk::fs::getRelativeString(const etk::Path& _path) {
|
||||
etk::String etk::path::getRelativeString(const etk::Path& _path) {
|
||||
return _path.getRelative();
|
||||
}
|
||||
|
||||
etk::String etk::fs::getAbsoluteString(const etk::Path& _path) {
|
||||
etk::String etk::path::getAbsoluteString(const etk::Path& _path) {
|
||||
return _path.getAbsolute();
|
||||
}
|
||||
|
||||
etk::String etk::fs::getNativeString(const etk::Path& _path) {
|
||||
etk::String etk::path::getNativeString(const etk::Path& _path) {
|
||||
return _path.getNative();
|
||||
}
|
||||
|
||||
/*
|
||||
etk::String etk::fs::getMimeType(const etk::Path& _path) {
|
||||
etk::String etk::path::getMimeType(const etk::Path& _path) {
|
||||
return "*";
|
||||
}
|
||||
*/
|
||||
|
||||
etk::Path etk::fs::getTemporaryPath() {
|
||||
etk::Path etk::path::getTemporaryPath() {
|
||||
static char const *folder = null;
|
||||
if (folder == null) {
|
||||
#ifdef __TARGET_OS__Windows
|
||||
@ -298,18 +298,18 @@ namespace detail {
|
||||
etk::Path getTemporaryProcessPath(const etk::String& _patern) {
|
||||
etk::Path val;
|
||||
do {
|
||||
val = etk::fs::getTemporaryPath() / _patern + etk::random::generateString(16);
|
||||
} while (etk::fs::exist(val) == true);
|
||||
val = etk::path::getTemporaryPath() / _patern + etk::random::generateString(16);
|
||||
} while (etk::path::exist(val) == true);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
etk::Path etk::fs::getTemporaryProcessPath() {
|
||||
etk::Path etk::path::getTemporaryProcessPath() {
|
||||
static etk::Path out = detail::getTemporaryProcessPath("etk.process.");
|
||||
return out;
|
||||
}
|
||||
|
||||
etk::Path etk::fs::getTemporaryRandomPath() {
|
||||
etk::Path etk::path::getTemporaryRandomPath() {
|
||||
return detail::getTemporaryProcessPath("etk.random.");
|
||||
}
|
||||
|
||||
@ -335,11 +335,11 @@ static etk::String getHomePathString() {
|
||||
return data;
|
||||
}
|
||||
|
||||
etk::Path etk::fs::getHomePath() {
|
||||
etk::Path etk::path::getHomePath() {
|
||||
return etk::Path(getHomePathString());
|
||||
}
|
||||
|
||||
etk::Path etk::fs::getExecutionPath() {
|
||||
etk::Path etk::path::getExecutionPath() {
|
||||
static etk::Path g_path;
|
||||
if (g_path.getNative() != "") {
|
||||
return g_path;
|
||||
@ -358,7 +358,7 @@ etk::Path etk::fs::getExecutionPath() {
|
||||
return g_path;
|
||||
}
|
||||
|
||||
etk::Path etk::fs::realPath(const etk::Path& _path) {
|
||||
etk::Path etk::path::realPath(const etk::Path& _path) {
|
||||
#if ! defined(__TARGET_OS__Windows)
|
||||
char buf[8192];
|
||||
memset(buf, 0, 8192);
|
||||
@ -370,7 +370,7 @@ etk::Path etk::fs::realPath(const etk::Path& _path) {
|
||||
return _path;
|
||||
}
|
||||
|
||||
etk::Path etk::fs::getBinaryPath() {
|
||||
etk::Path etk::path::getBinaryPath() {
|
||||
static etk::Path out;
|
||||
if ( out.getNative() == "" ) {
|
||||
#if defined(__TARGET_OS__Windows) || defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__IOs)
|
||||
@ -395,23 +395,23 @@ etk::Path etk::fs::getBinaryPath() {
|
||||
} while (tmpValue.size() < 65536);
|
||||
out = tmpValue;
|
||||
#else
|
||||
if (etk::fs::exist("/proc/self/exe") == true) {
|
||||
out = etk::fs::realPath("/proc/self/exe");
|
||||
} else if (etk::fs::exist("/proc/curproc/file") == true) {
|
||||
out = etk::fs::realPath("/proc/curproc/file");
|
||||
} else if (etk::fs::exist("/proc/curproc/exe") == true) {
|
||||
out = etk::fs::realPath("/proc/curproc/exe");
|
||||
if (etk::path::exist("/proc/self/exe") == true) {
|
||||
out = etk::path::realPath("/proc/self/exe");
|
||||
} else if (etk::path::exist("/proc/curproc/file") == true) {
|
||||
out = etk::path::realPath("/proc/curproc/file");
|
||||
} else if (etk::path::exist("/proc/curproc/exe") == true) {
|
||||
out = etk::path::realPath("/proc/curproc/exe");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
etk::String etk::fs::getBinaryName() {
|
||||
etk::String etk::path::getBinaryName() {
|
||||
return getBinaryPath().getFileName();
|
||||
}
|
||||
|
||||
etk::Path etk::fs::getDataPath() {
|
||||
etk::Path etk::path::getDataPath() {
|
||||
#if defined(__TARGET_OS__Web)
|
||||
return "zz_generic_zz";
|
||||
#elif defined(__TARGET_OS__Android)
|
||||
@ -434,7 +434,7 @@ etk::Path etk::fs::getDataPath() {
|
||||
return "NO_DATA_PATH";
|
||||
}
|
||||
|
||||
uint64_t etk::fs::getCreateTime(const etk::Path& _path) {
|
||||
uint64_t etk::path::getCreateTime(const etk::Path& _path) {
|
||||
struct stat statProperty;
|
||||
if (-1 == stat(_path.getNative().c_str(), &statProperty)) {
|
||||
return 0;
|
||||
@ -442,7 +442,7 @@ uint64_t etk::fs::getCreateTime(const etk::Path& _path) {
|
||||
return statProperty.st_ctime;
|
||||
}
|
||||
|
||||
uint64_t etk::fs::getModifyTime(const etk::Path& _path) {
|
||||
uint64_t etk::path::getModifyTime(const etk::Path& _path) {
|
||||
struct stat statProperty;
|
||||
if (-1 == stat(_path.getNative().c_str(), &statProperty)) {
|
||||
return 0;
|
||||
@ -450,7 +450,7 @@ uint64_t etk::fs::getModifyTime(const etk::Path& _path) {
|
||||
return statProperty.st_mtime;
|
||||
}
|
||||
|
||||
uint64_t etk::fs::getAccessTime(const etk::Path& _path) {
|
||||
uint64_t etk::path::getAccessTime(const etk::Path& _path) {
|
||||
struct stat statProperty;
|
||||
if (-1 == stat(_path.getNative().c_str(), &statProperty)) {
|
||||
return 0;
|
||||
@ -458,7 +458,7 @@ uint64_t etk::fs::getAccessTime(const etk::Path& _path) {
|
||||
return statProperty.st_atime;
|
||||
}
|
||||
|
||||
uint32_t etk::fs::getIdOwner(const etk::Path& _path) {
|
||||
uint32_t etk::path::getIdOwner(const etk::Path& _path) {
|
||||
struct stat statProperty;
|
||||
if (-1 == stat(_path.getNative().c_str(), &statProperty)) {
|
||||
return 0;
|
||||
@ -466,7 +466,7 @@ uint32_t etk::fs::getIdOwner(const etk::Path& _path) {
|
||||
return statProperty.st_uid;
|
||||
}
|
||||
|
||||
uint32_t etk::fs::getIdGroup(const etk::Path& _path) {
|
||||
uint32_t etk::path::getIdGroup(const etk::Path& _path) {
|
||||
struct stat statProperty;
|
||||
if (-1 == stat(_path.getNative().c_str(), &statProperty)) {
|
||||
return 0;
|
||||
@ -474,9 +474,9 @@ uint32_t etk::fs::getIdGroup(const etk::Path& _path) {
|
||||
return statProperty.st_gid;
|
||||
}
|
||||
|
||||
etk::Vector<etk::Path> etk::fs::list(const etk::Path& _path) {
|
||||
etk::Vector<etk::Path> etk::path::list(const etk::Path& _path) {
|
||||
etk::Vector<etk::Path> out;
|
||||
if (etk::fs::isDirectory(_path) == false) {
|
||||
if (etk::path::isDirectory(_path) == false) {
|
||||
return out;
|
||||
}
|
||||
DIR *dir = null;
|
@ -7,11 +7,11 @@
|
||||
|
||||
#include <etk/types.hpp>
|
||||
|
||||
#include <etk/fs/Path.hpp>
|
||||
#include <etk/fs/Permissions.hpp>
|
||||
#include <etk/path/Path.hpp>
|
||||
#include <etk/path/Permissions.hpp>
|
||||
|
||||
namespace etk {
|
||||
namespace fs {
|
||||
namespace path {
|
||||
/**
|
||||
* @brief Copy a path to an other (if possible...)
|
||||
* @param[in] _path1 Path source.
|
||||
@ -103,7 +103,7 @@ namespace etk {
|
||||
* @return true Operation succeed.
|
||||
* @return false Operation Failed.
|
||||
*/
|
||||
bool makeDirectory(const etk::Path& _path, etk::fs::Permissions _permission = etk::fs::Permissions::genericFolder);
|
||||
bool makeDirectory(const etk::Path& _path, etk::path::Permissions _permission = etk::path::Permissions::genericFolder);
|
||||
/**
|
||||
* @brief Make a directory (With all parents if needed)
|
||||
* @param[in] _path Path to create.
|
||||
@ -111,7 +111,7 @@ namespace etk {
|
||||
* @return true Operation succeed.
|
||||
* @return false Operation Failed.
|
||||
*/
|
||||
bool makeDirectories(const etk::Path& _path, etk::fs::Permissions _permission = etk::fs::Permissions::genericFolder);
|
||||
bool makeDirectories(const etk::Path& _path, etk::path::Permissions _permission = etk::path::Permissions::genericFolder);
|
||||
/**
|
||||
* @brief update the Time of the file with the current time
|
||||
* @param[in] _path Path to touch.
|
||||
@ -258,7 +258,7 @@ namespace etk {
|
||||
* @param[in] _path Path of the requested information.
|
||||
* @return Generic permission class.
|
||||
*/
|
||||
etk::fs::Permissions getPermission(const etk::Path& _path);
|
||||
etk::path::Permissions getPermission(const etk::Path& _path);
|
||||
/**
|
||||
* @brief List the content of a specific path.
|
||||
* @param[in] Path to parse.
|
@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/fs/Type.hpp>
|
||||
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/Map.hpp>
|
||||
|
||||
|
@ -6,11 +6,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/fs/Type.hpp>
|
||||
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/Map.hpp>
|
||||
#include <etk/uri/Query.hpp>
|
||||
#include <etk/fs/Path.hpp>
|
||||
#include <etk/path/Path.hpp>
|
||||
|
||||
namespace etk {
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#include <etk/uri/provider/ProviderFile.hpp>
|
||||
#include <etk/io/File.hpp>
|
||||
#include <etk/fs/fileSystem.hpp>
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
#include <etk/debug.hpp>
|
||||
|
||||
etk::uri::provider::ProviderFile::ProviderFile() {
|
||||
@ -26,16 +26,16 @@ ememory::SharedPtr<etk::io::Interface> etk::uri::provider::ProviderFile::create(
|
||||
|
||||
bool etk::uri::provider::ProviderFile::exist(const etk::Uri& _uri) {
|
||||
if (m_offset.isEmpty() == true) {
|
||||
return etk::fs::exist(_uri.getPath());
|
||||
return etk::path::exist(_uri.getPath());
|
||||
}
|
||||
return etk::fs::exist(m_offset / _uri.getPath());
|
||||
return etk::path::exist(m_offset / _uri.getPath());
|
||||
}
|
||||
|
||||
etk::Vector<etk::Uri> etk::uri::provider::ProviderFile::list(const etk::Uri& _uri) {
|
||||
etk::Vector<etk::Path> tmp;
|
||||
etk::Vector<etk::Uri> out;
|
||||
if (m_offset.isEmpty() == true) {
|
||||
tmp = etk::fs::list(_uri.getPath());
|
||||
tmp = etk::path::list(_uri.getPath());
|
||||
for (auto& elem: tmp) {
|
||||
etk::Uri newUri = _uri;
|
||||
newUri.setPath(elem);
|
||||
@ -44,7 +44,7 @@ etk::Vector<etk::Uri> etk::uri::provider::ProviderFile::list(const etk::Uri& _ur
|
||||
return out;
|
||||
}
|
||||
TK_VERBOSE("list path: " << m_offset / _uri.getPath());
|
||||
tmp = etk::fs::list(m_offset / _uri.getPath());
|
||||
tmp = etk::path::list(m_offset / _uri.getPath());
|
||||
int32_t offset = m_offset.getString().size()+1;
|
||||
for (auto& elem: tmp) {
|
||||
etk::Uri newUri = _uri;
|
||||
|
@ -6,11 +6,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/fs/Type.hpp>
|
||||
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/Map.hpp>
|
||||
#include <etk/uri/Query.hpp>
|
||||
#include <etk/fs/Path.hpp>
|
||||
#include <etk/path/Path.hpp>
|
||||
#include <etk/io/Interface.hpp>
|
||||
#include <etk/uri/provider/Interface.hpp>
|
||||
#include <ememory/SharedPtr.hpp>
|
||||
|
14
lutin_etk.py
14
lutin_etk.py
@ -34,10 +34,9 @@ def configure(target, my_module):
|
||||
'etk/Noise.cpp',
|
||||
'etk/Color.cpp',
|
||||
'etk/RegEx.cpp',
|
||||
'etk/fs/fileSystem.cpp',
|
||||
'etk/fs/Path.cpp',
|
||||
'etk/fs/Permissions.cpp',
|
||||
'etk/fs/Type.cpp',
|
||||
'etk/path/fileSystem.cpp',
|
||||
'etk/path/Path.cpp',
|
||||
'etk/path/Permissions.cpp',
|
||||
'etk/io/OpenMode.cpp',
|
||||
'etk/io/SeekMode.cpp',
|
||||
'etk/io/Interface.cpp',
|
||||
@ -69,10 +68,9 @@ def configure(target, my_module):
|
||||
'etk/Noise.hpp',
|
||||
'etk/Color.hpp',
|
||||
'etk/RegEx.hpp',
|
||||
'etk/fs/fileSystem.hpp',
|
||||
'etk/fs/Path.hpp',
|
||||
'etk/fs/Permissions.hpp',
|
||||
'etk/fs/Type.hpp',
|
||||
'etk/path/fileSystem.hpp',
|
||||
'etk/path/Path.hpp',
|
||||
'etk/path/Permissions.hpp',
|
||||
'etk/io/OpenMode.hpp',
|
||||
'etk/io/SeekMode.hpp',
|
||||
'etk/io/Interface.hpp',
|
||||
|
@ -8,140 +8,140 @@
|
||||
|
||||
#include <etest/etest.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etk/fs/fileSystem.hpp>
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
|
||||
TEST(TestFileSystem, checkHomePath) {
|
||||
etk::String basicPath = getenv("HOME");
|
||||
EXPECT_EQ(etk::fs::getHomePath(), basicPath);
|
||||
EXPECT_EQ(etk::path::getHomePath(), basicPath);
|
||||
}
|
||||
|
||||
TEST(TestFileSystem, checkTmpPath) {
|
||||
EXPECT_EQ(etk::fs::getTemporaryPath(), "/tmp");
|
||||
EXPECT_EQ(etk::path::getTemporaryPath(), "/tmp");
|
||||
}
|
||||
|
||||
TEST(TestFileSystem, getBinaryName) {
|
||||
EXPECT_EQ(etk::fs::getBinaryName(), "etk-test");
|
||||
EXPECT_EQ(etk::path::getBinaryName(), "etk-test");
|
||||
}
|
||||
|
||||
TEST(TestFileSystem, getBinaryPath) {
|
||||
EXPECT_EQ(etk::fs::getBinaryPath().getString().split('/').size() > 2, true);
|
||||
EXPECT_EQ(etk::path::getBinaryPath().getString().split('/').size() > 2, true);
|
||||
}
|
||||
|
||||
TEST(TestFileSystem, randomProcessPath) {
|
||||
etk::Path path1 = etk::fs::getTemporaryProcessPath();
|
||||
etk::Path path2 = etk::fs::getTemporaryProcessPath();
|
||||
etk::Path path1 = etk::path::getTemporaryProcessPath();
|
||||
etk::Path path2 = etk::path::getTemporaryProcessPath();
|
||||
EXPECT_EQ(path1,path2);
|
||||
}
|
||||
|
||||
TEST(TestFileSystem, randomPath) {
|
||||
etk::Path path1 = etk::fs::getTemporaryRandomPath();
|
||||
etk::Path path2 = etk::fs::getTemporaryRandomPath();
|
||||
etk::Path path1 = etk::path::getTemporaryRandomPath();
|
||||
etk::Path path2 = etk::path::getTemporaryRandomPath();
|
||||
EXPECT_NE(path1,path2);
|
||||
}
|
||||
|
||||
TEST(TestFileSystem, create_and_remove_directory_relative) {
|
||||
etk::Path path = "hello";
|
||||
EXPECT_EQ(etk::fs::exist(path), false);
|
||||
EXPECT_EQ(etk::fs::makeDirectory(path), true);
|
||||
EXPECT_EQ(etk::fs::exist(path), true);
|
||||
EXPECT_EQ(etk::fs::makeDirectory(path), true);
|
||||
EXPECT_EQ(etk::fs::removeDirectory(path), true);
|
||||
EXPECT_EQ(etk::fs::exist(path), false);
|
||||
EXPECT_EQ(etk::path::exist(path), false);
|
||||
EXPECT_EQ(etk::path::makeDirectory(path), true);
|
||||
EXPECT_EQ(etk::path::exist(path), true);
|
||||
EXPECT_EQ(etk::path::makeDirectory(path), true);
|
||||
EXPECT_EQ(etk::path::removeDirectory(path), true);
|
||||
EXPECT_EQ(etk::path::exist(path), false);
|
||||
}
|
||||
|
||||
TEST(TestFileSystem, createDirectory_relative_error) {
|
||||
etk::Path path = "hello/sdfsdf";
|
||||
EXPECT_EQ(etk::fs::exist(path), false);
|
||||
EXPECT_EQ(etk::fs::makeDirectory(path), false);
|
||||
EXPECT_EQ(etk::fs::exist(path), false);
|
||||
EXPECT_EQ(etk::path::exist(path), false);
|
||||
EXPECT_EQ(etk::path::makeDirectory(path), false);
|
||||
EXPECT_EQ(etk::path::exist(path), false);
|
||||
}
|
||||
|
||||
TEST(TestFileSystem, create_and_remove_directories) {
|
||||
etk::Path pathRandom = etk::fs::getTemporaryRandomPath();
|
||||
etk::Path pathRandom = etk::path::getTemporaryRandomPath();
|
||||
etk::Path path = pathRandom / "eee" / "kjlk" / "kjhkjh";
|
||||
TEST_DEBUG("path tmp: " << path);
|
||||
EXPECT_EQ(etk::fs::exist(path), false);
|
||||
EXPECT_EQ(etk::fs::makeDirectories(path), true);
|
||||
EXPECT_EQ(etk::fs::exist(path), true);
|
||||
EXPECT_EQ(etk::fs::removeDirectories(pathRandom), true);
|
||||
EXPECT_EQ(etk::fs::exist(pathRandom), false);
|
||||
EXPECT_EQ(etk::fs::exist(path), false);
|
||||
EXPECT_EQ(etk::path::exist(path), false);
|
||||
EXPECT_EQ(etk::path::makeDirectories(path), true);
|
||||
EXPECT_EQ(etk::path::exist(path), true);
|
||||
EXPECT_EQ(etk::path::removeDirectories(pathRandom), true);
|
||||
EXPECT_EQ(etk::path::exist(pathRandom), false);
|
||||
EXPECT_EQ(etk::path::exist(path), false);
|
||||
}
|
||||
|
||||
TEST(TestFileSystem, create_and_remove_directories_error) {
|
||||
etk::Path pathRandom = etk::fs::getTemporaryRandomPath();
|
||||
etk::Path pathRandom = etk::path::getTemporaryRandomPath();
|
||||
etk::Path path = etk::Path("home") / "eee" / "kjlk" / "kjhkjh";
|
||||
TEST_DEBUG("path tmp: " << path);
|
||||
EXPECT_EQ(etk::fs::exist(path), false);
|
||||
EXPECT_EQ(etk::fs::makeDirectories(path), false);
|
||||
EXPECT_EQ(etk::fs::exist(path), false);
|
||||
EXPECT_EQ(etk::path::exist(path), false);
|
||||
EXPECT_EQ(etk::path::makeDirectories(path), false);
|
||||
EXPECT_EQ(etk::path::exist(path), false);
|
||||
}
|
||||
/*
|
||||
TEST(TestFileSystem, move_directory) {
|
||||
etk::Path pathRandom = etk::fs::getTemporaryRandomPath();
|
||||
etk::Path pathRandom = etk::path::getTemporaryRandomPath();
|
||||
etk::Path path1 = pathRandom / "eee1";
|
||||
etk::Path path2 = pathRandom / "eee2";
|
||||
etk::Path offset = etk::Path("kjlk") / "kjhkjh";
|
||||
EXPECT_EQ(etk::fs::exist(path1), false);
|
||||
EXPECT_EQ(etk::fs::exist(path2), false);
|
||||
EXPECT_EQ(etk::fs::exist(path1 / offset), false);
|
||||
EXPECT_EQ(etk::fs::exist(path2 / offset), false);
|
||||
EXPECT_EQ(etk::fs::makeDirectories(path1 / offset), true);
|
||||
EXPECT_EQ(etk::fs::exist(path1), true);
|
||||
EXPECT_EQ(etk::fs::exist(path2), false);
|
||||
EXPECT_EQ(etk::fs::exist(path1 / offset), true);
|
||||
EXPECT_EQ(etk::fs::exist(path2 / offset), false);
|
||||
EXPECT_EQ(etk::fs::move(path1, path2), true);
|
||||
EXPECT_EQ(etk::fs::exist(path1), false);
|
||||
EXPECT_EQ(etk::fs::exist(path2), true);
|
||||
EXPECT_EQ(etk::fs::exist(path1 / offset), false);
|
||||
EXPECT_EQ(etk::fs::exist(path2 / offset), true);
|
||||
EXPECT_EQ(etk::fs::removeDirectories(pathRandom), true);
|
||||
EXPECT_EQ(etk::fs::exist(pathRandom), false);
|
||||
EXPECT_EQ(etk::path::exist(path1), false);
|
||||
EXPECT_EQ(etk::path::exist(path2), false);
|
||||
EXPECT_EQ(etk::path::exist(path1 / offset), false);
|
||||
EXPECT_EQ(etk::path::exist(path2 / offset), false);
|
||||
EXPECT_EQ(etk::path::makeDirectories(path1 / offset), true);
|
||||
EXPECT_EQ(etk::path::exist(path1), true);
|
||||
EXPECT_EQ(etk::path::exist(path2), false);
|
||||
EXPECT_EQ(etk::path::exist(path1 / offset), true);
|
||||
EXPECT_EQ(etk::path::exist(path2 / offset), false);
|
||||
EXPECT_EQ(etk::path::move(path1, path2), true);
|
||||
EXPECT_EQ(etk::path::exist(path1), false);
|
||||
EXPECT_EQ(etk::path::exist(path2), true);
|
||||
EXPECT_EQ(etk::path::exist(path1 / offset), false);
|
||||
EXPECT_EQ(etk::path::exist(path2 / offset), true);
|
||||
EXPECT_EQ(etk::path::removeDirectories(pathRandom), true);
|
||||
EXPECT_EQ(etk::path::exist(pathRandom), false);
|
||||
}
|
||||
*/
|
||||
#include <unistd.h>
|
||||
|
||||
TEST(TestFileSystem, touch) {
|
||||
etk::Path pathRandom = etk::fs::getTemporaryRandomPath();
|
||||
etk::Path pathRandom = etk::path::getTemporaryRandomPath();
|
||||
etk::Path path = pathRandom / "eee" / "kjlk" / "kjhkjh.txt";
|
||||
TEST_DEBUG("path tmp: " << path);
|
||||
EXPECT_EQ(etk::fs::exist(path), false);
|
||||
EXPECT_EQ(etk::path::exist(path), false);
|
||||
// Touch a file in a unexisting path
|
||||
EXPECT_EQ(etk::fs::touch(path), false);
|
||||
EXPECT_EQ(etk::fs::makeDirectories(path.getParent()), true);
|
||||
EXPECT_EQ(etk::fs::exist(path), false);
|
||||
EXPECT_EQ(etk::path::touch(path), false);
|
||||
EXPECT_EQ(etk::path::makeDirectories(path.getParent()), true);
|
||||
EXPECT_EQ(etk::path::exist(path), false);
|
||||
// Touch a file in an existing path
|
||||
EXPECT_EQ(etk::fs::touch(path), true);
|
||||
EXPECT_EQ(etk::fs::exist(path), true);
|
||||
uint64_t touch1 = etk::fs::getModifyTime(path);
|
||||
EXPECT_EQ(etk::path::touch(path), true);
|
||||
EXPECT_EQ(etk::path::exist(path), true);
|
||||
uint64_t touch1 = etk::path::getModifyTime(path);
|
||||
|
||||
usleep(1000000);
|
||||
// Tich a file already existing
|
||||
EXPECT_EQ(etk::fs::touch(path), true);
|
||||
EXPECT_EQ(etk::fs::exist(path), true);
|
||||
uint64_t touch2 = etk::fs::getModifyTime(path);
|
||||
EXPECT_EQ(etk::path::touch(path), true);
|
||||
EXPECT_EQ(etk::path::exist(path), true);
|
||||
uint64_t touch2 = etk::path::getModifyTime(path);
|
||||
EXPECT_NE(touch1, touch2);
|
||||
EXPECT_EQ(etk::fs::removeDirectories(pathRandom), true);
|
||||
EXPECT_EQ(etk::fs::exist(pathRandom), false);
|
||||
EXPECT_EQ(etk::fs::exist(path), false);
|
||||
EXPECT_EQ(etk::path::removeDirectories(pathRandom), true);
|
||||
EXPECT_EQ(etk::path::exist(pathRandom), false);
|
||||
EXPECT_EQ(etk::path::exist(path), false);
|
||||
}
|
||||
|
||||
TEST(TestFileSystem, move_file) {
|
||||
etk::Path pathRandom = etk::fs::getTemporaryRandomPath();
|
||||
etk::Path pathRandom = etk::path::getTemporaryRandomPath();
|
||||
etk::Path path1 = pathRandom / "eee1.txt";
|
||||
etk::Path path2 = pathRandom / "eee2.mov";
|
||||
EXPECT_EQ(etk::fs::exist(path1), false);
|
||||
EXPECT_EQ(etk::fs::exist(path2), false);
|
||||
EXPECT_EQ(etk::fs::makeDirectories(pathRandom), true);
|
||||
EXPECT_EQ(etk::fs::touch(path1), true);
|
||||
EXPECT_EQ(etk::fs::exist(path1), true);
|
||||
EXPECT_EQ(etk::fs::exist(path2), false);
|
||||
EXPECT_EQ(etk::fs::move(path1, path2), true);
|
||||
EXPECT_EQ(etk::fs::exist(path1), false);
|
||||
EXPECT_EQ(etk::fs::exist(path2), true);
|
||||
EXPECT_EQ(etk::path::exist(path1), false);
|
||||
EXPECT_EQ(etk::path::exist(path2), false);
|
||||
EXPECT_EQ(etk::path::makeDirectories(pathRandom), true);
|
||||
EXPECT_EQ(etk::path::touch(path1), true);
|
||||
EXPECT_EQ(etk::path::exist(path1), true);
|
||||
EXPECT_EQ(etk::path::exist(path2), false);
|
||||
EXPECT_EQ(etk::path::move(path1, path2), true);
|
||||
EXPECT_EQ(etk::path::exist(path1), false);
|
||||
EXPECT_EQ(etk::path::exist(path2), true);
|
||||
/*
|
||||
EXPECT_EQ(etk::fs::removeDirectories(pathRandom), true);
|
||||
EXPECT_EQ(etk::fs::exist(pathRandom), false);
|
||||
EXPECT_EQ(etk::path::removeDirectories(pathRandom), true);
|
||||
EXPECT_EQ(etk::path::exist(pathRandom), false);
|
||||
*/
|
||||
}
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
#include <etest/etest.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etk/fs/Path.hpp>
|
||||
#include <etk/fs/fileSystem.hpp>
|
||||
#include <etk/path/Path.hpp>
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
|
||||
TEST(TestPath, defaultContructor) {
|
||||
etk::Path path;
|
||||
@ -142,7 +142,7 @@ TEST(TestPath, getRelative) {
|
||||
EXPECT_EQ(path.getRelative(), "plouf.pdf");
|
||||
path = "/ici/plouf.pdf";
|
||||
etk::String test;
|
||||
auto elements = etk::fs::getExecutionPath().getString().split('/');
|
||||
auto elements = etk::path::getExecutionPath().getString().split('/');
|
||||
for (size_t iii=0; iii<elements.size(); ++iii) {
|
||||
if (elements[iii].size() == 0) {
|
||||
continue;
|
||||
@ -155,7 +155,7 @@ TEST(TestPath, getRelative) {
|
||||
|
||||
TEST(TestPath, getAbsolute) {
|
||||
etk::Path path("plouf.pdf");
|
||||
EXPECT_EQ(path.getAbsolute(), (etk::fs::getExecutionPath() / "plouf.pdf").getString());
|
||||
EXPECT_EQ(path.getAbsolute(), (etk::path::getExecutionPath() / "plouf.pdf").getString());
|
||||
path = "/plouf.pdf";
|
||||
EXPECT_EQ(path.getAbsolute(), "/plouf.pdf");
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
|
||||
#include <etest/etest.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etk/fs/Permissions.hpp>
|
||||
#include <etk/path/Permissions.hpp>
|
||||
|
||||
TEST(TestPermission, defaultContructor) {
|
||||
etk::fs::Permissions permission;
|
||||
etk::path::Permissions permission;
|
||||
EXPECT_EQ(permission.isUserReadable(), false);
|
||||
EXPECT_EQ(permission.isUserWritable(), false);
|
||||
EXPECT_EQ(permission.isUserRunable(), false);
|
||||
@ -26,7 +26,7 @@ TEST(TestPermission, defaultContructor) {
|
||||
|
||||
|
||||
TEST(TestPermission, fullright) {
|
||||
etk::fs::Permissions permission(0777);
|
||||
etk::path::Permissions permission(0777);
|
||||
EXPECT_EQ(permission.isUserReadable(), true);
|
||||
EXPECT_EQ(permission.isUserWritable(), true);
|
||||
EXPECT_EQ(permission.isUserRunable(), true);
|
||||
@ -41,7 +41,7 @@ TEST(TestPermission, fullright) {
|
||||
|
||||
|
||||
TEST(TestPermission, user) {
|
||||
etk::fs::Permissions permission(0700);
|
||||
etk::path::Permissions permission(0700);
|
||||
EXPECT_EQ(permission.isUserReadable(), true);
|
||||
EXPECT_EQ(permission.isUserWritable(), true);
|
||||
EXPECT_EQ(permission.isUserRunable(), true);
|
||||
@ -56,7 +56,7 @@ TEST(TestPermission, user) {
|
||||
|
||||
|
||||
TEST(TestPermission, group) {
|
||||
etk::fs::Permissions permission(0070);
|
||||
etk::path::Permissions permission(0070);
|
||||
EXPECT_EQ(permission.isUserReadable(), false);
|
||||
EXPECT_EQ(permission.isUserWritable(), false);
|
||||
EXPECT_EQ(permission.isUserRunable(), false);
|
||||
@ -71,7 +71,7 @@ TEST(TestPermission, group) {
|
||||
|
||||
|
||||
TEST(TestPermission, other) {
|
||||
etk::fs::Permissions permission(0007);
|
||||
etk::path::Permissions permission(0007);
|
||||
EXPECT_EQ(permission.isUserReadable(), false);
|
||||
EXPECT_EQ(permission.isUserWritable(), false);
|
||||
EXPECT_EQ(permission.isUserRunable(), false);
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <etk/uri/provider/provider.hpp>
|
||||
#include <etk/uri/provider/ProviderFile.hpp>
|
||||
#include <etk/uri/provider/ProviderFileZip.hpp>
|
||||
#include <etk/fs/fileSystem.hpp>
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
#include <etk/algorithm.hpp>
|
||||
|
||||
|
||||
@ -100,8 +100,8 @@ bool uriSortCallback(const etk::Uri& _left, const etk::Uri& _right) {
|
||||
|
||||
TEST(TestUriProvider, checkDirectAccess) {
|
||||
etk::uri::provider::clear();
|
||||
TEST_VERBOSE("data path: " << etk::fs::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFile>(etk::fs::getDataPath()));
|
||||
TEST_VERBOSE("data path: " << etk::path::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFile>(etk::path::getDataPath()));
|
||||
EXPECT_EQ(etk::uri::provider::exist("DATA"), true);
|
||||
ememory::SharedPtr<etk::uri::provider::Interface> provider = etk::uri::provider::getProvider("DATA");
|
||||
EXPECT_NE(provider, null);
|
||||
@ -133,8 +133,8 @@ etk::Vector<etk::Uri> listDirect2 = {
|
||||
|
||||
TEST(TestUriProvider, checkDirectAccess2) {
|
||||
etk::uri::provider::clear();
|
||||
TEST_VERBOSE("data path: " << etk::fs::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFile>(etk::fs::getDataPath()));
|
||||
TEST_VERBOSE("data path: " << etk::path::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFile>(etk::path::getDataPath()));
|
||||
EXPECT_EQ(etk::uri::provider::exist("DATA"), true);
|
||||
ememory::SharedPtr<etk::uri::provider::Interface> provider = etk::uri::provider::getProvider("DATA");
|
||||
EXPECT_NE(provider, null);
|
||||
@ -155,8 +155,8 @@ TEST(TestUriProvider, checkDirectAccess2) {
|
||||
|
||||
TEST(TestUriProvider, directExistFile) {
|
||||
etk::uri::provider::clear();
|
||||
TEST_VERBOSE("data path: " << etk::fs::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFile>(etk::fs::getDataPath()));
|
||||
TEST_VERBOSE("data path: " << etk::path::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFile>(etk::path::getDataPath()));
|
||||
EXPECT_EQ(etk::uri::provider::exist("DATA"), true);
|
||||
ememory::SharedPtr<etk::uri::provider::Interface> provider = etk::uri::provider::getProvider("DATA");
|
||||
EXPECT_NE(provider, null);
|
||||
@ -172,8 +172,8 @@ TEST(TestUriProvider, directExistFile) {
|
||||
|
||||
TEST(TestUriProvider, directReadFile) {
|
||||
etk::uri::provider::clear();
|
||||
TEST_VERBOSE("data path: " << etk::fs::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFile>(etk::fs::getDataPath()));
|
||||
TEST_VERBOSE("data path: " << etk::path::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFile>(etk::path::getDataPath()));
|
||||
EXPECT_EQ(etk::uri::provider::exist("DATA"), true);
|
||||
etk::Uri element("DATA:///data/dir_B/file_B_1.txt");
|
||||
ememory::SharedPtr<etk::io::Interface> ioElement = etk::uri::provider::get(element);
|
||||
@ -196,8 +196,8 @@ etk::Vector<etk::Uri> listZip = {
|
||||
|
||||
TEST(TestUriProvider, checkZipAccess) {
|
||||
etk::uri::provider::clear();
|
||||
TEST_VERBOSE("data path: " << etk::fs::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFileZip>(etk::fs::getDataPath() / "data_sample.zip", "data"));
|
||||
TEST_VERBOSE("data path: " << etk::path::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFileZip>(etk::path::getDataPath() / "data_sample.zip", "data"));
|
||||
EXPECT_EQ(etk::uri::provider::exist("DATA"), true);
|
||||
ememory::SharedPtr<etk::uri::provider::Interface> provider = etk::uri::provider::getProvider("DATA");
|
||||
EXPECT_NE(provider, null);
|
||||
@ -219,8 +219,8 @@ etk::Vector<etk::Uri> listZip2 = {
|
||||
|
||||
TEST(TestUriProvider, checkZipAccess2) {
|
||||
etk::uri::provider::clear();
|
||||
TEST_VERBOSE("data path: " << etk::fs::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFileZip>(etk::fs::getDataPath() / "data_sample.zip", "data"));
|
||||
TEST_VERBOSE("data path: " << etk::path::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFileZip>(etk::path::getDataPath() / "data_sample.zip", "data"));
|
||||
EXPECT_EQ(etk::uri::provider::exist("DATA"), true);
|
||||
ememory::SharedPtr<etk::uri::provider::Interface> provider = etk::uri::provider::getProvider("DATA");
|
||||
EXPECT_NE(provider, null);
|
||||
@ -236,8 +236,8 @@ TEST(TestUriProvider, checkZipAccess2) {
|
||||
|
||||
TEST(TestUriProvider, zipExistFile) {
|
||||
etk::uri::provider::clear();
|
||||
TEST_VERBOSE("data path: " << etk::fs::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFileZip>(etk::fs::getDataPath() / "data_sample.zip", "data"));
|
||||
TEST_VERBOSE("data path: " << etk::path::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFileZip>(etk::path::getDataPath() / "data_sample.zip", "data"));
|
||||
EXPECT_EQ(etk::uri::provider::exist("DATA"), true);
|
||||
ememory::SharedPtr<etk::uri::provider::Interface> provider = etk::uri::provider::getProvider("DATA");
|
||||
EXPECT_NE(provider, null);
|
||||
@ -253,8 +253,8 @@ TEST(TestUriProvider, zipExistFile) {
|
||||
|
||||
TEST(TestUriProvider, zipReadFile) {
|
||||
etk::uri::provider::clear();
|
||||
TEST_VERBOSE("data path: " << etk::fs::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFileZip>(etk::fs::getDataPath() / "data_sample.zip", "data"));
|
||||
TEST_VERBOSE("data path: " << etk::path::getDataPath());
|
||||
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFileZip>(etk::path::getDataPath() / "data_sample.zip", "data"));
|
||||
EXPECT_EQ(etk::uri::provider::exist("DATA"), true);
|
||||
etk::Uri element("DATA:///dir_B/file_B_1.txt");
|
||||
ememory::SharedPtr<etk::io::Interface> ioElement = etk::uri::provider::get(element);
|
||||
|
Loading…
x
Reference in New Issue
Block a user