[DEV] finish filesystem interface
This commit is contained in:
parent
cb948b5014
commit
3f5ed121ec
@ -20,10 +20,12 @@ extern "C" {
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <fcntl.h> /* Definition of AT_* constants */
|
||||||
}
|
}
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <etk/tool.hpp>
|
||||||
#include <etk/io/File.hpp>
|
#include <etk/io/File.hpp>
|
||||||
#include <etk/io/SeekMode.hpp>
|
#include <etk/io/SeekMode.hpp>
|
||||||
|
|
||||||
@ -41,16 +43,15 @@ bool etk::fs::copyFile(const etk::Path& _path1, const etk::Path& _path2) {
|
|||||||
|
|
||||||
|
|
||||||
bool etk::fs::move(const etk::Path& _path1, const etk::Path& _path2) {
|
bool etk::fs::move(const etk::Path& _path1, const etk::Path& _path2) {
|
||||||
|
TK_VERBOSE("Move : \"" << _path1 << "\" ==> \"" << _path2 << "\"");
|
||||||
if (etk::fs::exist(_path2) == true) {
|
if (etk::fs::exist(_path2) == true) {
|
||||||
remove(_path2);
|
removes(_path2);
|
||||||
}
|
}
|
||||||
TK_DEBUG("Move : \"" << _path1 << "\" ==> \"" << _path2 << "\"");
|
|
||||||
// create path to be sure it exist ...
|
// create path to be sure it exist ...
|
||||||
TK_VERBOSE("create path: '" << _path2.getParent() << "'");
|
|
||||||
etk::fs::makeDirectories(_path2.getParent());
|
etk::fs::makeDirectories(_path2.getParent());
|
||||||
int32_t res = ::rename(_path1.getString().c_str(), _path2.getString().c_str());
|
int32_t res = ::rename(_path1.getNative().c_str(), _path2.getNative().c_str());
|
||||||
if (res!=0) {
|
if (res != 0) {
|
||||||
TK_ERROR("Can not move the file: '" << _path1 << "' ==> '" << _path2 << "'");
|
TK_ERROR("Can not move the file: '" << _path1 << "' ==> '" << _path2 << "' errno" << errno << " (" << strerror(errno) << ")");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -81,7 +82,7 @@ namespace detail {
|
|||||||
detail::removes(it, _recursive);
|
detail::removes(it, _recursive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( 0 != ::rmdir(_path.getString().c_str()) ) {
|
if ( 0 != ::rmdir(_path.getNative().c_str()) ) {
|
||||||
if (ENOTEMPTY == errno) {
|
if (ENOTEMPTY == errno) {
|
||||||
TK_ERROR("The Directory is not empty...");
|
TK_ERROR("The Directory is not empty...");
|
||||||
}
|
}
|
||||||
@ -109,7 +110,7 @@ bool etk::fs::removeDirectories(const etk::Path& _path) {
|
|||||||
|
|
||||||
bool etk::fs::removeFile(const etk::Path& _path) {
|
bool etk::fs::removeFile(const etk::Path& _path) {
|
||||||
TK_VERBOSE("remove File: " << _path);
|
TK_VERBOSE("remove File: " << _path);
|
||||||
if (0 != unlink(_path.getString().c_str()) ) {
|
if (0 != unlink(_path.getNative().c_str()) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -121,13 +122,13 @@ bool etk::fs::makeDirectory(const etk::Path& _path, etk::fs::Permissions _permis
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#ifdef __TARGET_OS__Windows
|
#ifdef __TARGET_OS__Windows
|
||||||
if (::mkdir(_path.getString().c_str()) != 0
|
if (::mkdir(_path.getNative().c_str()) != 0
|
||||||
&& errno != EEXIST) {
|
&& errno != EEXIST) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
mode_t mode = _permission.getRightValue();
|
mode_t mode = _permission.getRightValue();
|
||||||
if ( ::mkdir(_path.getString().c_str(), mode) != 0
|
if ( ::mkdir(_path.getNative().c_str(), mode) != 0
|
||||||
&& errno != EEXIST ) {
|
&& errno != EEXIST ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -140,7 +141,7 @@ bool etk::fs::makeDirectories(const etk::Path& _path, etk::fs::Permissions _perm
|
|||||||
if (etk::fs::exist(_path) == true) {
|
if (etk::fs::exist(_path) == true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
auto elements = _path.getString().split('/');
|
auto elements = _path.getNative().split('/');
|
||||||
etk::Path pathToCreate;
|
etk::Path pathToCreate;
|
||||||
if (elements[0].size() == 0) {
|
if (elements[0].size() == 0) {
|
||||||
elements.popFront();
|
elements.popFront();
|
||||||
@ -156,14 +157,16 @@ bool etk::fs::makeDirectories(const etk::Path& _path, etk::fs::Permissions _perm
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fs::touch(const etk::Path& _path) {
|
bool etk::fs::touch(const etk::Path& _path) {
|
||||||
TK_DEBUG("Touch FILE : " << _path);
|
TK_VERBOSE("Touch FILE : " << _path);
|
||||||
if (etk::fs::exist(_path) == true ) {
|
if (etk::fs::exist(_path) == true ) {
|
||||||
//just open in write an close ==> this will update the time
|
int rc = utimensat(0,
|
||||||
etk::io::File file{_path};
|
_path.getAbsoluteNative().c_str(),
|
||||||
if (file.open(etk::io::OpenMode::Append) == false) {
|
NULL,
|
||||||
|
AT_SYMLINK_NOFOLLOW);
|
||||||
|
if (rc) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return file.close();
|
return true;
|
||||||
}
|
}
|
||||||
// Write the file with nothing inside...
|
// Write the file with nothing inside...
|
||||||
etk::io::File file{_path};
|
etk::io::File file{_path};
|
||||||
@ -174,19 +177,17 @@ bool etk::fs::touch(const etk::Path& _path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool etk::fs::exist(const etk::Path& _path) {
|
bool etk::fs::exist(const etk::Path& _path) {
|
||||||
struct stat st;
|
if (::access( _path.getNative().c_str(), F_OK ) != -1 ) {
|
||||||
int32_t status = 0;
|
return true;
|
||||||
if (stat(_path.getString().c_str(), &st) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t etk::fs::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;
|
||||||
if (stat(_path.getString().c_str(), &statProperty) == -1) {
|
if (stat(_path.getNative().c_str(), &statProperty) == -1) {
|
||||||
//Normal case when the file does not exist ... ==> the it was in unknow mode ...
|
//Normal case when the file does not exist ... ==> the it was in unknow mode ...
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -201,7 +202,7 @@ uint64_t etk::fs::fileSize(const etk::Path& _path) {
|
|||||||
bool etk::fs::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.getNative().c_str(), &st) != 0) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!S_ISDIR(st.st_mode)) {
|
} else if (!S_ISDIR(st.st_mode)) {
|
||||||
return false;
|
return false;
|
||||||
@ -212,7 +213,7 @@ bool etk::fs::isDirectory(const etk::Path& _path) {
|
|||||||
bool etk::fs::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.getNative().c_str(), &st) != 0) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!S_ISREG(st.st_mode)) {
|
} else if (!S_ISREG(st.st_mode)) {
|
||||||
return false;
|
return false;
|
||||||
@ -223,7 +224,7 @@ bool etk::fs::isFile(const etk::Path& _path) {
|
|||||||
bool etk::fs::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.getNative().c_str(), &st) != 0) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!S_ISLNK(st.st_mode)) {
|
} else if (!S_ISLNK(st.st_mode)) {
|
||||||
return false;
|
return false;
|
||||||
@ -236,7 +237,7 @@ etk::fs::Permissions etk::fs::getPermission(const etk::Path& _path) {
|
|||||||
etk::fs::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.getNative().c_str(), &statProperty)) {
|
||||||
//Normal case when the file does not exist ... ==> the it was in unknow mode ...
|
//Normal case when the file does not exist ... ==> the it was in unknow mode ...
|
||||||
return permissions;
|
return permissions;
|
||||||
}
|
}
|
||||||
@ -295,20 +296,21 @@ etk::Path etk::fs::getTemporaryPath() {
|
|||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
etk::Path getTemporaryProcessPath(const etk::String& _patern) {
|
etk::Path getTemporaryProcessPath(const etk::String& _patern) {
|
||||||
char tmpName[1024];
|
etk::Path val;
|
||||||
strcpy(tmpName, _patern.c_str());
|
do {
|
||||||
mktemp(tmpName);
|
val = etk::fs::getTemporaryPath() / _patern + etk::random::generateString(16);
|
||||||
return etk::fs::getTemporaryPath() / tmpName;
|
} while (etk::fs::exist(val) == true);
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path etk::fs::getTemporaryProcessPath() {
|
etk::Path etk::fs::getTemporaryProcessPath() {
|
||||||
static etk::Path out = detail::getTemporaryProcessPath("etk.process.XXXXXX");
|
static etk::Path out = detail::getTemporaryProcessPath("etk.process.");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Path etk::fs::getTemporaryRandomPath() {
|
etk::Path etk::fs::getTemporaryRandomPath() {
|
||||||
return detail::getTemporaryProcessPath("etk.random.XXXXXX");
|
return detail::getTemporaryProcessPath("etk.random.");
|
||||||
}
|
}
|
||||||
|
|
||||||
static etk::String getHomePathString() {
|
static etk::String getHomePathString() {
|
||||||
@ -339,7 +341,7 @@ etk::Path etk::fs::getHomePath() {
|
|||||||
|
|
||||||
etk::Path etk::fs::getExecutionPath() {
|
etk::Path etk::fs::getExecutionPath() {
|
||||||
static etk::Path g_path;
|
static etk::Path g_path;
|
||||||
if (g_path.getString() != "") {
|
if (g_path.getNative() != "") {
|
||||||
return g_path;
|
return g_path;
|
||||||
}
|
}
|
||||||
char cCurrentPath[FILENAME_MAX];
|
char cCurrentPath[FILENAME_MAX];
|
||||||
@ -360,7 +362,7 @@ etk::Path etk::fs::realPath(const etk::Path& _path) {
|
|||||||
#if ! defined(__TARGET_OS__Windows)
|
#if ! defined(__TARGET_OS__Windows)
|
||||||
char buf[8192];
|
char buf[8192];
|
||||||
memset(buf, 0, 8192);
|
memset(buf, 0, 8192);
|
||||||
char *res = realpath(_path.getString().c_str(), buf);
|
char *res = realpath(_path.getNative().c_str(), buf);
|
||||||
if (res) {
|
if (res) {
|
||||||
return etk::Path{buf};
|
return etk::Path{buf};
|
||||||
}
|
}
|
||||||
@ -370,7 +372,7 @@ etk::Path etk::fs::realPath(const etk::Path& _path) {
|
|||||||
|
|
||||||
etk::Path etk::fs::getBinaryPath() {
|
etk::Path etk::fs::getBinaryPath() {
|
||||||
static etk::Path out;
|
static etk::Path out;
|
||||||
if ( out.getString() == "" ) {
|
if ( out.getNative() == "" ) {
|
||||||
#if defined(__TARGET_OS__Windows) || defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__IOs)
|
#if defined(__TARGET_OS__Windows) || defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__IOs)
|
||||||
etk::String tmpValue;
|
etk::String tmpValue;
|
||||||
tmpValue.resize(4096);
|
tmpValue.resize(4096);
|
||||||
@ -415,7 +417,7 @@ etk::Path etk::fs::getDataPath() {
|
|||||||
#endif
|
#endif
|
||||||
uint64_t etk::fs::getCreateTime(const etk::Path& _path) {
|
uint64_t etk::fs::getCreateTime(const etk::Path& _path) {
|
||||||
struct stat statProperty;
|
struct stat statProperty;
|
||||||
if (-1 == stat(_path.getString().c_str(), &statProperty)) {
|
if (-1 == stat(_path.getNative().c_str(), &statProperty)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return statProperty.st_ctime;
|
return statProperty.st_ctime;
|
||||||
@ -423,7 +425,7 @@ uint64_t etk::fs::getCreateTime(const etk::Path& _path) {
|
|||||||
|
|
||||||
uint64_t etk::fs::getModifyTime(const etk::Path& _path) {
|
uint64_t etk::fs::getModifyTime(const etk::Path& _path) {
|
||||||
struct stat statProperty;
|
struct stat statProperty;
|
||||||
if (-1 == stat(_path.getString().c_str(), &statProperty)) {
|
if (-1 == stat(_path.getNative().c_str(), &statProperty)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return statProperty.st_mtime;
|
return statProperty.st_mtime;
|
||||||
@ -431,7 +433,7 @@ uint64_t etk::fs::getModifyTime(const etk::Path& _path) {
|
|||||||
|
|
||||||
uint64_t etk::fs::getAccessTime(const etk::Path& _path) {
|
uint64_t etk::fs::getAccessTime(const etk::Path& _path) {
|
||||||
struct stat statProperty;
|
struct stat statProperty;
|
||||||
if (-1 == stat(_path.getString().c_str(), &statProperty)) {
|
if (-1 == stat(_path.getNative().c_str(), &statProperty)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return statProperty.st_atime;
|
return statProperty.st_atime;
|
||||||
@ -439,7 +441,7 @@ uint64_t etk::fs::getAccessTime(const etk::Path& _path) {
|
|||||||
|
|
||||||
uint32_t etk::fs::getIdOwner(const etk::Path& _path) {
|
uint32_t etk::fs::getIdOwner(const etk::Path& _path) {
|
||||||
struct stat statProperty;
|
struct stat statProperty;
|
||||||
if (-1 == stat(_path.getString().c_str(), &statProperty)) {
|
if (-1 == stat(_path.getNative().c_str(), &statProperty)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return statProperty.st_uid;
|
return statProperty.st_uid;
|
||||||
@ -447,7 +449,7 @@ uint32_t etk::fs::getIdOwner(const etk::Path& _path) {
|
|||||||
|
|
||||||
uint32_t etk::fs::getIdGroup(const etk::Path& _path) {
|
uint32_t etk::fs::getIdGroup(const etk::Path& _path) {
|
||||||
struct stat statProperty;
|
struct stat statProperty;
|
||||||
if (-1 == stat(_path.getString().c_str(), &statProperty)) {
|
if (-1 == stat(_path.getNative().c_str(), &statProperty)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return statProperty.st_gid;
|
return statProperty.st_gid;
|
||||||
@ -460,7 +462,7 @@ etk::Vector<etk::Path> etk::fs::list(const etk::Path& _path) {
|
|||||||
}
|
}
|
||||||
DIR *dir = null;
|
DIR *dir = null;
|
||||||
struct dirent *ent = null;
|
struct dirent *ent = null;
|
||||||
dir = opendir(_path.getString().c_str());
|
dir = opendir(_path.getNative().c_str());
|
||||||
if (dir != null) {
|
if (dir != null) {
|
||||||
// for each element in the drectory...
|
// for each element in the drectory...
|
||||||
while ((ent = readdir(dir)) != null) {
|
while ((ent = readdir(dir)) != null) {
|
||||||
|
@ -7,7 +7,10 @@
|
|||||||
#include <etk/io/File.hpp>
|
#include <etk/io/File.hpp>
|
||||||
#include <etk/debug.hpp>
|
#include <etk/debug.hpp>
|
||||||
#include <etk/fs/fileSystem.hpp>
|
#include <etk/fs/fileSystem.hpp>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
extern "C" {
|
||||||
|
#include <errno.h>
|
||||||
|
}
|
||||||
|
|
||||||
etk::io::File::File() {
|
etk::io::File::File() {
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
@ -33,17 +36,17 @@ bool etk::io::File::open(etk::io::OpenMode _mode) {
|
|||||||
TK_VERBOSE(" Read file : " << m_path);
|
TK_VERBOSE(" Read file : " << m_path);
|
||||||
switch (_mode) {
|
switch (_mode) {
|
||||||
case etk::io::OpenMode::Read:
|
case etk::io::OpenMode::Read:
|
||||||
m_pointer = fopen(m_path.getNative().c_str(),"rb");
|
m_pointer = fopen(m_path.getNative().c_str(), "rb");
|
||||||
break;
|
break;
|
||||||
case etk::io::OpenMode::Write:
|
case etk::io::OpenMode::Write:
|
||||||
m_pointer = fopen(m_path.getNative().c_str(),"wb");
|
m_pointer = fopen(m_path.getNative().c_str(), "wb");
|
||||||
break;
|
break;
|
||||||
case etk::io::OpenMode::Append:
|
case etk::io::OpenMode::Append:
|
||||||
m_pointer = fopen(m_path.getNative().c_str(),"ab");
|
m_pointer = fopen(m_path.getNative().c_str(), "ab");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(m_pointer == null) {
|
if(m_pointer == null) {
|
||||||
TK_ERROR("Can not open the file " << m_path );
|
TK_WARNING("Can not open the file " << m_path.getNative() << " mode: " << _mode << " errno" << errno << " (" << strerror(errno) << ")");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -115,3 +118,4 @@ int64_t etk::io::File::write(const void* _data, int64_t _blockSize, int64_t _nbB
|
|||||||
}
|
}
|
||||||
return fwrite(_data, _blockSize, _nbBlock, m_pointer);
|
return fwrite(_data, _blockSize, _nbBlock, m_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,3 +128,4 @@ int64_t etk::io::ZipFile::write(const void* _data, int64_t _blockSize, int64_t _
|
|||||||
TK_CRITICAL("Can not write on data inside APK : " << m_path);
|
TK_CRITICAL("Can not write on data inside APK : " << m_path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ TEST(TestFileSystem, create_and_remove_directories_error) {
|
|||||||
EXPECT_EQ(etk::fs::makeDirectories(path), false);
|
EXPECT_EQ(etk::fs::makeDirectories(path), false);
|
||||||
EXPECT_EQ(etk::fs::exist(path), false);
|
EXPECT_EQ(etk::fs::exist(path), false);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
TEST(TestFileSystem, move_directory) {
|
TEST(TestFileSystem, move_directory) {
|
||||||
etk::Path pathRandom = etk::fs::getTemporaryRandomPath();
|
etk::Path pathRandom = etk::fs::getTemporaryRandomPath();
|
||||||
etk::Path path1 = pathRandom / "eee1";
|
etk::Path path1 = pathRandom / "eee1";
|
||||||
@ -99,43 +99,49 @@ TEST(TestFileSystem, move_directory) {
|
|||||||
EXPECT_EQ(etk::fs::removeDirectories(pathRandom), true);
|
EXPECT_EQ(etk::fs::removeDirectories(pathRandom), true);
|
||||||
EXPECT_EQ(etk::fs::exist(pathRandom), false);
|
EXPECT_EQ(etk::fs::exist(pathRandom), false);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
TEST(TestFileSystem, touch) {
|
TEST(TestFileSystem, touch) {
|
||||||
etk::Path pathRandom = etk::fs::getTemporaryRandomPath();
|
etk::Path pathRandom = etk::fs::getTemporaryRandomPath();
|
||||||
etk::Path path = pathRandom / "eee" / "kjlk" / "kjhkjh.txt";
|
etk::Path path = pathRandom / "eee" / "kjlk" / "kjhkjh.txt";
|
||||||
TEST_DEBUG("path tmp: " << path);
|
TEST_DEBUG("path tmp: " << path);
|
||||||
EXPECT_EQ(etk::fs::exist(path), false);
|
EXPECT_EQ(etk::fs::exist(path), false);
|
||||||
|
// Touch a file in a unexisting path
|
||||||
EXPECT_EQ(etk::fs::touch(path), false);
|
EXPECT_EQ(etk::fs::touch(path), false);
|
||||||
EXPECT_EQ(etk::fs::makeDirectories(path.getParent()), true);
|
EXPECT_EQ(etk::fs::makeDirectories(path.getParent()), true);
|
||||||
EXPECT_EQ(etk::fs::exist(path), false);
|
EXPECT_EQ(etk::fs::exist(path), false);
|
||||||
|
// Touch a file in an existing path
|
||||||
EXPECT_EQ(etk::fs::touch(path), true);
|
EXPECT_EQ(etk::fs::touch(path), true);
|
||||||
EXPECT_EQ(etk::fs::exist(path), true);
|
EXPECT_EQ(etk::fs::exist(path), true);
|
||||||
uint64_t touch1 = etk::fs::getModifyTime(path);
|
uint64_t touch1 = etk::fs::getModifyTime(path);
|
||||||
|
|
||||||
|
usleep(1000000);
|
||||||
|
// Tich a file already existing
|
||||||
EXPECT_EQ(etk::fs::touch(path), true);
|
EXPECT_EQ(etk::fs::touch(path), true);
|
||||||
EXPECT_EQ(etk::fs::exist(path), true);
|
EXPECT_EQ(etk::fs::exist(path), true);
|
||||||
uint64_t touch2 = etk::fs::getModifyTime(path);
|
uint64_t touch2 = etk::fs::getModifyTime(path);
|
||||||
EXPECT_NE(touch1, touch2);
|
EXPECT_NE(touch1, touch2);
|
||||||
/*
|
|
||||||
EXPECT_EQ(etk::fs::removeDirectories(pathRandom), true);
|
EXPECT_EQ(etk::fs::removeDirectories(pathRandom), true);
|
||||||
EXPECT_EQ(etk::fs::exist(pathRandom), false);
|
EXPECT_EQ(etk::fs::exist(pathRandom), false);
|
||||||
EXPECT_EQ(etk::fs::exist(path), false);
|
EXPECT_EQ(etk::fs::exist(path), false);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
TEST(TestFileSystem, move_file) {
|
TEST(TestFileSystem, move_file) {
|
||||||
etk::Path pathRandom = etk::fs::getTemporaryRandomPath();
|
etk::Path pathRandom = etk::fs::getTemporaryRandomPath();
|
||||||
etk::Path path1 = pathRandom / "eee1.txt";
|
etk::Path path1 = pathRandom / "eee1.txt";
|
||||||
etk::Path path2 = pathRandom / "eee2.mov";
|
etk::Path path2 = pathRandom / "eee2.mov";
|
||||||
EXPECT_EQ(etk::fs::exist(path1), false);
|
EXPECT_EQ(etk::fs::exist(path1), false);
|
||||||
EXPECT_EQ(etk::fs::exist(path2), 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::touch(path1), true);
|
||||||
EXPECT_EQ(etk::fs::exist(path1), true);
|
EXPECT_EQ(etk::fs::exist(path1), true);
|
||||||
EXPECT_EQ(etk::fs::exist(path2), false);
|
EXPECT_EQ(etk::fs::exist(path2), false);
|
||||||
EXPECT_EQ(etk::fs::move(path1, path2), true);
|
EXPECT_EQ(etk::fs::move(path1, path2), true);
|
||||||
EXPECT_EQ(etk::fs::exist(path1), false);
|
EXPECT_EQ(etk::fs::exist(path1), false);
|
||||||
EXPECT_EQ(etk::fs::exist(path2), true);
|
EXPECT_EQ(etk::fs::exist(path2), true);
|
||||||
|
/*
|
||||||
EXPECT_EQ(etk::fs::removeDirectories(pathRandom), true);
|
EXPECT_EQ(etk::fs::removeDirectories(pathRandom), true);
|
||||||
EXPECT_EQ(etk::fs::exist(pathRandom), false);
|
EXPECT_EQ(etk::fs::exist(pathRandom), false);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
*/
|
|
Loading…
x
Reference in New Issue
Block a user