[DEV] build but not work
This commit is contained in:
parent
ea53e1db72
commit
44655d7f78
@ -10,10 +10,9 @@
|
||||
#include <etk/debug.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
|
||||
static const etk::ArchiveContent g_error;
|
||||
ETK_DECLARE_TYPE(etk::Archive);
|
||||
|
||||
const etk::String& etk::Archive::getName(size_t _id) const {
|
||||
etk::Path etk::Archive::getName(size_t _id) const {
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
size_t id = 0;
|
||||
for (auto &it : m_content) {
|
||||
@ -22,11 +21,10 @@ const etk::String& etk::Archive::getName(size_t _id) const {
|
||||
}
|
||||
++id;
|
||||
}
|
||||
static const etk::String error("");
|
||||
return error;
|
||||
return "";
|
||||
}
|
||||
|
||||
const etk::ArchiveContent& etk::Archive::getContent(size_t _id) const {
|
||||
ememory::SharedPtr<etk::ArchiveContent> etk::Archive::getContent(size_t _id) const {
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
size_t id = 0;
|
||||
for (auto &it : m_content) {
|
||||
@ -35,20 +33,20 @@ const etk::ArchiveContent& etk::Archive::getContent(size_t _id) const {
|
||||
}
|
||||
++id;
|
||||
}
|
||||
return g_error;
|
||||
return null;
|
||||
}
|
||||
|
||||
const etk::ArchiveContent& etk::Archive::getContent(const etk::String& _key) const {
|
||||
ememory::SharedPtr<etk::ArchiveContent> etk::Archive::getContent(const etk::Path& _key) const {
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
auto it = m_content.find(_key);
|
||||
if (it == m_content.end()) {
|
||||
return g_error;
|
||||
return null;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
||||
bool etk::Archive::exist(const etk::String& _key) const {
|
||||
bool etk::Archive::exist(const etk::Path& _key) const {
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
return m_content.find(_key) != m_content.end();
|
||||
}
|
||||
@ -56,19 +54,19 @@ bool etk::Archive::exist(const etk::String& _key) const {
|
||||
void etk::Archive::display() {
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
for (auto &it : m_content) {
|
||||
int32_t size = it.second.getTheoricSize();
|
||||
int32_t sizeR = it.second.size();
|
||||
int32_t size = it.second->getTheoricSize();
|
||||
int32_t sizeR = it.second->size();
|
||||
TK_INFO(" element : " << it.first << " size=" << size << " allocated=" << sizeR);
|
||||
}
|
||||
}
|
||||
|
||||
etk::Archive* etk::Archive::load(const etk::String& _fileName) {
|
||||
etk::Archive* output=null;
|
||||
etk::String tmpName = _fileName.toLower();
|
||||
ememory::SharedPtr<etk::Archive> etk::Archive::load(const etk::Path& _fileName) {
|
||||
ememory::SharedPtr<etk::Archive> output;
|
||||
etk::String extention = _fileName.getExtention().toLower();
|
||||
// select the corect Loader :
|
||||
if( tmpName.endWith(".zip") == true
|
||||
|| tmpName.endWith(".apk") == true ) {
|
||||
output = ETK_NEW(etk::archive::Zip, _fileName);
|
||||
if( extention == "zip"
|
||||
|| extention == ".apk") {
|
||||
output = ememory::makeShared<etk::archive::Zip>(_fileName);
|
||||
if (output == null) {
|
||||
TK_ERROR("An error occured when load archive : " << _fileName);
|
||||
}
|
||||
@ -78,9 +76,9 @@ etk::Archive* etk::Archive::load(const etk::String& _fileName) {
|
||||
return output;
|
||||
}
|
||||
|
||||
etk::Archive* etk::Archive::loadPackage(const etk::String& _fileName) {
|
||||
etk::Archive* output=null;
|
||||
FILE* file = fopen(_fileName.c_str(), "rb");
|
||||
ememory::SharedPtr<etk::Archive> etk::Archive::loadPackage(const etk::Path& _fileName) {
|
||||
ememory::SharedPtr<etk::Archive> output;
|
||||
FILE* file = fopen(_fileName.getNative().c_str(), "rb");
|
||||
if (file == null) {
|
||||
TK_ERROR("Can not open file : '" << _fileName);
|
||||
return null;
|
||||
@ -104,39 +102,39 @@ etk::Archive* etk::Archive::loadPackage(const etk::String& _fileName) {
|
||||
}
|
||||
fclose(file);
|
||||
file = null;
|
||||
output = ETK_NEW(etk::archive::Zip, _fileName, position);
|
||||
if (null==output) {
|
||||
output = ememory::makeShared<etk::archive::Zip>(_fileName, position);
|
||||
if (output == null) {
|
||||
TK_ERROR("An error occured when load archive : " << _fileName);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
void etk::Archive::open(const etk::String& _key) {
|
||||
void etk::Archive::open(const etk::Path& _key) {
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
auto it = m_content.find(_key);
|
||||
if (it == m_content.end()) {
|
||||
TK_ERROR("Try open an unexistant file : '" << _key << "'");
|
||||
return;
|
||||
}
|
||||
if (it->second.getNumberOfRef()==-1) {
|
||||
if (it->second->getNumberOfRef()==-1) {
|
||||
loadFile(it);
|
||||
it->second.increaseRef();
|
||||
it->second->increaseRef();
|
||||
}
|
||||
it->second.increaseRef();
|
||||
it->second->increaseRef();
|
||||
}
|
||||
|
||||
void etk::Archive::close(const etk::String& _key) {
|
||||
void etk::Archive::close(const etk::Path& _key) {
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
auto it = m_content.find(_key);
|
||||
if (it == m_content.end()) {
|
||||
TK_ERROR("Try close an unexistant file : '" << _key << "'");
|
||||
return;
|
||||
}
|
||||
if (it->second.getNumberOfRef()==0){
|
||||
if (it->second->getNumberOfRef()==0){
|
||||
TK_ERROR("Try close one more time the file : '" << _key << "'");
|
||||
} else {
|
||||
it->second.decreaseRef();
|
||||
it->second->decreaseRef();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,16 +3,15 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef ETK_BUILD_MINIZIP
|
||||
|
||||
#include <etk/types.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <etk/Map.hpp>
|
||||
#include <ethread/Mutex.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/fileSystem/Path.hpp>
|
||||
|
||||
namespace etk {
|
||||
/**
|
||||
@ -96,7 +95,7 @@ namespace etk {
|
||||
* @brief Contructor of the archive element
|
||||
* @param[in] _fileName Zip file name (or .apk for android)
|
||||
*/
|
||||
Archive(const etk::String& _fileName) :
|
||||
Archive(const etk::Path& _fileName) :
|
||||
m_fileName(_fileName) {
|
||||
|
||||
};
|
||||
@ -105,17 +104,17 @@ namespace etk {
|
||||
*/
|
||||
virtual ~Archive() = default;
|
||||
protected:
|
||||
etk::String m_fileName; //!< File name when it came from an file
|
||||
etk::Path m_fileName; //!< File name when it came from an file
|
||||
public:
|
||||
/**
|
||||
* @brief Get the current file name.
|
||||
* @return the requested file name.
|
||||
*/
|
||||
const etk::String& getFileName() {
|
||||
const etk::Path& getFileName() {
|
||||
return m_fileName;
|
||||
};
|
||||
protected:
|
||||
etk::Map<etk::String, ArchiveContent> m_content; //!< list of element of the zip file
|
||||
etk::Map<etk::Path, ememory::SharedPtr<ArchiveContent>> m_content; //!< list of element of the zip file
|
||||
public:
|
||||
/**
|
||||
* @brief Get the number of elements
|
||||
@ -129,35 +128,35 @@ namespace etk {
|
||||
* @param[in] _id id of the element (must be < Size())
|
||||
* @return FileName of the requested id
|
||||
*/
|
||||
const etk::String& getName(size_t _id) const;
|
||||
etk::Path getName(size_t _id) const;
|
||||
/**
|
||||
* @brief Get the File name of the ID
|
||||
* @param[in] _id id of the element (must be < Size())
|
||||
* @return the archive content
|
||||
*/
|
||||
const ArchiveContent& getContent(size_t _id) const;
|
||||
ememory::SharedPtr<ArchiveContent> getContent(size_t _id) const;
|
||||
/**
|
||||
* @brief Get the File name of the ID
|
||||
* @param[in] _key name of the file
|
||||
* @return FileName of the requested id
|
||||
*/
|
||||
const ArchiveContent& getContent(const etk::String& _key) const;
|
||||
ememory::SharedPtr<ArchiveContent> getContent(const etk::Path& _key) const;
|
||||
/**
|
||||
* @brief Check if a file exist
|
||||
* @param[in] _key Name of the file
|
||||
* @return true if the file is present
|
||||
*/
|
||||
bool exist(const etk::String& _key) const;
|
||||
bool exist(const etk::Path& _key) const;
|
||||
/**
|
||||
* @brief Load the specific file in the memory
|
||||
* @param[in] _key Name of the file
|
||||
*/
|
||||
void open(const etk::String& _key);
|
||||
void open(const etk::Path& _key);
|
||||
/**
|
||||
* @brief Un-Load the specific file from the memory
|
||||
* @param[in] _key Name of the file
|
||||
*/
|
||||
void close(const etk::String& _key);
|
||||
void close(const etk::Path& _key);
|
||||
/**
|
||||
* @brief Display all Element in the archive
|
||||
*/
|
||||
@ -167,20 +166,20 @@ namespace etk {
|
||||
* @brief Request the load in memory of the concerned file.
|
||||
* @param[in] _it Iterator on the element.
|
||||
*/
|
||||
virtual void loadFile(const etk::Map<etk::String, ArchiveContent>::Iterator& _it) { };
|
||||
virtual void loadFile(const etk::Map<etk::Path, ememory::SharedPtr<ArchiveContent>>::Iterator& _it) { };
|
||||
public:
|
||||
/**
|
||||
* @brief Load an Achive with a specific name.
|
||||
* @param[in] _fileName File name of the specific archive.
|
||||
* @return A pointer an the specified archive, the user might delete it.
|
||||
*/
|
||||
static Archive* load(const etk::String& _fileName);
|
||||
static ememory::SharedPtr<Archive> load(const etk::Path& _fileName);
|
||||
/**
|
||||
* @brief Load an Achive with a specific name in package mode ==> this mean the data is associated with the basic binary.
|
||||
* @param[in] _fileName File name of the specific archive.
|
||||
* @return A pointer an the specified archive, the user might delete it.
|
||||
*/
|
||||
static Archive* loadPackage(const etk::String& _fileName);
|
||||
static ememory::SharedPtr<Archive> loadPackage(const etk::Path& _fileName);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
@ -13,11 +13,11 @@
|
||||
|
||||
ETK_DECLARE_TYPE(etk::archive::Zip);
|
||||
|
||||
etk::archive::Zip::Zip(const etk::String& _fileName, uint64_t _offset) :
|
||||
etk::archive::Zip::Zip(const etk::Path& _fileName, uint64_t _offset) :
|
||||
etk::Archive(_fileName),
|
||||
m_ctx(null) {
|
||||
/* Open the zip file */
|
||||
m_ctx = unzOpenOffset(m_fileName.c_str(), _offset);
|
||||
m_ctx = unzOpenOffset(m_fileName.getNative().c_str(), _offset);
|
||||
if(!m_ctx) {
|
||||
TK_ERROR("Unable to open the zip file '" << m_fileName << "' offset=" << _offset);
|
||||
return;
|
||||
@ -41,7 +41,7 @@ etk::archive::Zip::Zip(const etk::String& _fileName, uint64_t _offset) :
|
||||
// find directory ...
|
||||
} else {
|
||||
TK_INFO("find file : " << tmpFileName);
|
||||
m_content.set(tmpFileName, etk::ArchiveContent(tmpFileInfo.uncompressed_size));
|
||||
m_content.set(etk::Path(tmpFileName), ememory::makeShared<etk::ArchiveContent>(tmpFileInfo.uncompressed_size));
|
||||
}
|
||||
/* Go the the next entry listed in the zip file. */
|
||||
if((iii+1) < m_info.number_entry) {
|
||||
@ -60,7 +60,7 @@ etk::archive::Zip::~Zip() {
|
||||
};
|
||||
}
|
||||
|
||||
void etk::archive::Zip::loadFile(const etk::Map<etk::String, ArchiveContent>::Iterator& it) {
|
||||
void etk::archive::Zip::loadFile(const etk::Map<etk::Path, ememory::SharedPtr<ArchiveContent>>::Iterator& it) {
|
||||
TK_VERBOSE("Real load file : '" << it->first << "'");
|
||||
|
||||
unzGoToFirstFile(m_ctx);
|
||||
@ -74,7 +74,7 @@ void etk::archive::Zip::loadFile(const etk::Map<etk::String, ArchiveContent>::It
|
||||
TK_ERROR("Could not read file info from the zip file '" << m_fileName << "'");
|
||||
return;
|
||||
}
|
||||
if (it->first == tmpFileName ) {
|
||||
if (it->first == etk::Path(tmpFileName) ) {
|
||||
// Entry is a file, so extract it.
|
||||
if(unzOpenCurrentFile(m_ctx) != UNZ_OK) {
|
||||
TK_ERROR("Could not open file '" << it->first << "' into the zip file '" << m_fileName << "'");
|
||||
@ -82,17 +82,17 @@ void etk::archive::Zip::loadFile(const etk::Map<etk::String, ArchiveContent>::It
|
||||
}
|
||||
int error = UNZ_OK;
|
||||
// request the resize of the data :
|
||||
it->second.getDataVector().resize(it->second.getTheoricSize(), 0);
|
||||
void* data = it->second.data();
|
||||
it->second->getDataVector().resize(it->second->getTheoricSize(), 0);
|
||||
void* data = it->second->data();
|
||||
if(data == null) {
|
||||
TK_ERROR("Allocation error...");
|
||||
return;
|
||||
}
|
||||
/* read the file */
|
||||
do {
|
||||
error = unzReadCurrentFile(m_ctx, data, it->second.getTheoricSize());
|
||||
error = unzReadCurrentFile(m_ctx, data, it->second->getTheoricSize());
|
||||
if (error < 0) {
|
||||
TK_ERROR("Could not read file '" << tmpFileName << "' into the zip file '" << m_fileName << "': " << error);
|
||||
TK_ERROR("Could not read file '" << tmpFileName << "' into the zip file '" << m_fileName << "': " << error);
|
||||
unzCloseCurrentFile(m_ctx);
|
||||
return;
|
||||
}
|
||||
@ -103,7 +103,6 @@ void etk::archive::Zip::loadFile(const etk::Map<etk::String, ArchiveContent>::It
|
||||
return;
|
||||
}
|
||||
unzCloseCurrentFile(m_ctx);
|
||||
|
||||
/* Go the the next entry listed in the zip file. */
|
||||
if((iii+1) < m_info.number_entry) {
|
||||
if (unzGoToNextFile(m_ctx) != UNZ_OK) {
|
||||
|
@ -28,13 +28,13 @@
|
||||
* @param[in] _fileName File to parse (.zip / .apk)
|
||||
* @param[in] _offset Offset in the file where to start the parsing of the "zip"
|
||||
*/
|
||||
Zip(const etk::String& _fileName, uint64_t _offset = 0LL);
|
||||
Zip(const etk::Path& _fileName, uint64_t _offset = 0LL);
|
||||
/**
|
||||
* @brief basic destructor
|
||||
*/
|
||||
virtual ~Zip();
|
||||
protected:
|
||||
void loadFile(const etk::Map<etk::String, ArchiveContent>::Iterator& _it) override;
|
||||
void loadFile(const etk::Map<etk::Path, ememory::SharedPtr<ArchiveContent>>::Iterator& _it) override;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -113,23 +113,23 @@ static etk::String simplifyPath(etk::String _input) {
|
||||
}
|
||||
|
||||
static etk::String convertToWindows(etk::String _path) {
|
||||
_path.replace("/", "\\");
|
||||
if ( _path.size() > 3
|
||||
if ( _path.size() >= 3
|
||||
&& _path[0] == '/'
|
||||
&& _path[2] == '/') {
|
||||
_path[0] = _path[1];
|
||||
_path[0] = ':';
|
||||
_path[1] = ':';
|
||||
}
|
||||
_path.replace("/", "\\");
|
||||
return _path;
|
||||
}
|
||||
|
||||
static etk::String convertToUnix(etk::String _path) {
|
||||
_path.replace("\\", "/");
|
||||
if ( _path.size() > 3
|
||||
if ( _path.size() >= 3
|
||||
&& _path[1] == ':'
|
||||
&& _path[2] == '/') {
|
||||
#ifndef __TARGET_OS__Windows
|
||||
TK_WARNING("Path name have a windows form: '" << _path << "' c:/ but not a windwos platform");
|
||||
TK_DEBUG("Path name have a windows form: '" << _path << "' c:/ but not a windwos platform");
|
||||
#endif
|
||||
if ( _path[0] >= 'A'
|
||||
&& _path[0] <= 'Z') {
|
||||
@ -152,10 +152,18 @@ static etk::String parsePath(etk::String _path) {
|
||||
}
|
||||
|
||||
|
||||
etk::Path::Path() {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
etk::Path::Path(const etk::String& _value) {
|
||||
m_data = parsePath(_value);
|
||||
}
|
||||
|
||||
etk::Path::Path(const char * _value) {
|
||||
m_data = parsePath(_value);
|
||||
}
|
||||
|
||||
etk::String etk::Path::getString() const {
|
||||
return m_data;
|
||||
}
|
||||
@ -234,6 +242,27 @@ bool etk::Path::isAbsolute() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
etk::String etk::Path::getFileName() const {
|
||||
size_t pos = m_data.rfind('/');
|
||||
if (pos == etk::String::npos) {
|
||||
return m_data;
|
||||
}
|
||||
return m_data.extract(pos);
|
||||
}
|
||||
|
||||
etk::String etk::Path::getExtention() const {
|
||||
etk::String fileName = getFileName();
|
||||
size_t pos = fileName.rfind('.');
|
||||
if (pos == etk::String::npos) {
|
||||
return "";
|
||||
}
|
||||
if (pos == 0) {
|
||||
// a simple name started with a .
|
||||
return "";
|
||||
}
|
||||
return fileName.extract(pos);
|
||||
}
|
||||
|
||||
void etk::Path::parent() {
|
||||
size_t pos = m_data.rfind('/');
|
||||
if (pos == etk::String::npos) {
|
||||
@ -315,8 +344,35 @@ etk::Path& etk::Path::operator+= (const etk::Path & _element) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
etk::Path& etk::Path::operator= (const etk::String & _element) {
|
||||
m_data = parsePath(_element);
|
||||
return *this;
|
||||
}
|
||||
|
||||
etk::Path& etk::Path::operator= (const char* _element) {
|
||||
m_data = parsePath(_element);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
etk::Stream& etk::operator <<(etk::Stream &_os, const etk::Path &_obj) {
|
||||
_os << _obj.getString();
|
||||
return _os;
|
||||
}
|
||||
|
||||
bool etk::operator> (const Path& _left, const Path& _right) {
|
||||
return _left.getString() > _right.getString();
|
||||
}
|
||||
|
||||
bool etk::operator>= (const Path& _left, const Path& _right) {
|
||||
return _left.getString() >= _right.getString();
|
||||
}
|
||||
|
||||
bool etk::operator< (const Path& _left, const Path& _right) {
|
||||
return _left.getString() < _right.getString();
|
||||
}
|
||||
|
||||
bool etk::operator<= (const Path& _left, const Path& _right) {
|
||||
return _left.getString() <= _right.getString();
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,11 @@ namespace etk {
|
||||
* @param[in] _value Element basic path
|
||||
*/
|
||||
Path(const etk::String& _value);
|
||||
/**
|
||||
* @brief Contructor with basic path.
|
||||
* @param[in] _value Element basic path
|
||||
*/
|
||||
Path(const char * _value);
|
||||
/**
|
||||
* @brief Get the set path (by the user)
|
||||
* - /home/userXXX/aaa/bbb/###
|
||||
@ -95,6 +100,18 @@ namespace etk {
|
||||
* @return false The path is not absolute.
|
||||
*/
|
||||
bool isAbsolute() const;
|
||||
/**
|
||||
* @brief Get the filename name of the Path (last element name after the last '/'
|
||||
* @return "" No file found.
|
||||
* @return * Name of the file.
|
||||
*/
|
||||
etk::String getFileName() const;
|
||||
/**
|
||||
* @brief Get the filename extention if it exist
|
||||
* @return "" No extention found.
|
||||
* @return * extention of the file.
|
||||
*/
|
||||
etk::String getExtention() const;
|
||||
/**
|
||||
* @brief remove the last child element of the path.
|
||||
*/
|
||||
@ -140,7 +157,16 @@ namespace etk {
|
||||
Path operator+ (const etk::Path & _element) const;
|
||||
//! @preivious
|
||||
Path& operator+= (const etk::Path & _element);
|
||||
/**
|
||||
* @breif asignmendt operator:
|
||||
*/
|
||||
Path& operator= (const etk::String & _element);
|
||||
Path& operator= (const char* _element);
|
||||
};
|
||||
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
|
||||
etk::Stream& operator <<(etk::Stream &_os, const etk::Path &_obj);
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/io/File.hpp>
|
||||
#include <etk/debug.hpp>
|
||||
#include <etk/fileSystem/fileSystem.hpp>
|
||||
|
||||
|
||||
etk::io::File::File() {
|
||||
// nothing to do.
|
||||
@ -16,28 +18,28 @@ etk::io::File::File(const etk::Path& _path):
|
||||
|
||||
}
|
||||
|
||||
etk::io::File::File() {
|
||||
etk::io::File::~File() {
|
||||
if (m_pointer != null) {
|
||||
TK_ERROR("Missing to close the file : \"" << *this << "\"");
|
||||
TK_ERROR("Missing to close the file : '" << m_path << "'S");
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
bool etk::io::File::open(etk::io::OpenMode _mode) {
|
||||
if (m_pointer != null) {
|
||||
TK_CRITICAL("File Already open : " << *this);
|
||||
TK_CRITICAL("File Already open : " << m_path);
|
||||
return true;
|
||||
}
|
||||
TK_VERBOSE(" Read file : " << m_path);
|
||||
switch (_mode) {
|
||||
case etk::io::OpenMode::Read:
|
||||
m_pointer = fopen(m_path.c_str(),"rb");
|
||||
m_pointer = fopen(m_path.getNative().c_str(),"rb");
|
||||
break;
|
||||
case etk::io::OpenMode::Write:
|
||||
m_pointer = fopen(m_path.c_str(),"wb");
|
||||
m_pointer = fopen(m_path.getNative().c_str(),"wb");
|
||||
break;
|
||||
case etk::io::OpenMode::Append:
|
||||
m_pointer = fopen(m_path.c_str(),"ab");
|
||||
m_pointer = fopen(m_path.getNative().c_str(),"ab");
|
||||
break;
|
||||
}
|
||||
if(m_pointer == null) {
|
||||
@ -53,7 +55,7 @@ bool etk::io::File::isOpen() {
|
||||
|
||||
bool etk::io::File::close() {
|
||||
if (m_pointer == null) {
|
||||
TK_CRITICAL("File Already closed : " << *this);
|
||||
TK_CRITICAL("File Already closed : " << m_path);
|
||||
return false;
|
||||
}
|
||||
fclose(m_pointer);
|
||||
@ -68,10 +70,10 @@ uint64_t etk::io::File::size() {
|
||||
bool etk::io::File::seek(uint64_t _offset, enum etk::io::SeekMode _origin) {
|
||||
int originFS = 0;
|
||||
switch(_origin) {
|
||||
case etk::seekNode_end:
|
||||
case etk::io::SeekMode::End:
|
||||
originFS = SEEK_END;
|
||||
break;
|
||||
case etk::seekNode_current:
|
||||
case etk::io::SeekMode::Current:
|
||||
originFS = SEEK_CUR;
|
||||
break;
|
||||
default:
|
||||
@ -100,7 +102,7 @@ int64_t etk::io::File::tell() {
|
||||
|
||||
int64_t etk::io::File::read(void* _data, int64_t _blockSize, int64_t _nbBlock) {
|
||||
if (m_pointer == null) {
|
||||
TK_ERROR("Can not read in a file that is not open : " << *this);
|
||||
TK_ERROR("Can not read in a file that is not open : " << m_path);
|
||||
return 0;
|
||||
}
|
||||
return fread(_data, _blockSize, _nbBlock, m_pointer);
|
||||
@ -108,7 +110,7 @@ int64_t etk::io::File::read(void* _data, int64_t _blockSize, int64_t _nbBlock) {
|
||||
|
||||
int64_t etk::io::File::write(const void* _data, int64_t _blockSize, int64_t _nbBlock) {
|
||||
if (m_pointer == null) {
|
||||
TK_ERROR("Can not write in a file that is not open : " << *this);
|
||||
TK_ERROR("Can not write in a file that is not open : " << m_path);
|
||||
return 0;
|
||||
}
|
||||
return fwrite(_data, _blockSize, _nbBlock, m_pointer);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/io/Interface.hpp>
|
||||
#include <etk/io/File.hpp>
|
||||
#include <etk/fileSystem/Path.hpp>
|
||||
|
||||
namespace etk {
|
||||
namespace io {
|
||||
@ -17,7 +18,7 @@ namespace etk {
|
||||
class File: public etk::io::Interface {
|
||||
private:
|
||||
etk::Path m_path; //!< Path to access in this interface
|
||||
FILE * m_PointerFile = null; //!< Generic file accesss.
|
||||
FILE * m_pointer = null; //!< Generic file accesss.
|
||||
public:
|
||||
File();
|
||||
File(const etk::Path& _path);
|
||||
|
@ -3,8 +3,6 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/io/Interface.hpp>
|
||||
|
||||
@ -32,14 +30,14 @@ bool etk::io::Interface::gets(etk::String& _output) {
|
||||
}
|
||||
|
||||
bool etk::io::Interface::put(char _input) {
|
||||
if (fileWrite(&_input, 1, 1) == 1) {
|
||||
if (write(&_input, 1, 1) == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool etk::io::Interface::puts(const etk::String& _input) {
|
||||
if (fileWrite((void*)_input.c_str(), 1, _input.size()) == (int64_t)_input.size()) {
|
||||
if (write((void*)_input.c_str(), 1, _input.size()) == (int64_t)_input.size()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/io/SeekMode.hpp>
|
||||
#include <etk/io/OpenMode.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/String.hpp>
|
||||
|
||||
namespace etk {
|
||||
namespace io {
|
||||
@ -16,7 +18,10 @@ namespace etk {
|
||||
*/
|
||||
class Interface {
|
||||
public:
|
||||
virtual ~Interface();
|
||||
/**
|
||||
* @brief Virtualize destructor.
|
||||
*/
|
||||
virtual ~Interface() = default;
|
||||
/**
|
||||
* @brief Open the file in Read mode
|
||||
* @param[in] _mode Mode to open the IO
|
||||
|
@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Stream.hpp>
|
||||
|
||||
namespace etk {
|
||||
namespace io {
|
||||
@ -17,7 +18,7 @@ namespace etk {
|
||||
Write, //!< request File open in write
|
||||
Append, //!< request File open in append
|
||||
};
|
||||
//! @not_in_doc
|
||||
etk::Stream& operator <<(etk::Stream &_os, const enum etk::io::OpenMode &_obj);
|
||||
}
|
||||
//! @not_in_doc
|
||||
etk::Stream& operator <<(etk::Stream &_os, const enum etk::io::OpenMode &_obj);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Stream.hpp>
|
||||
|
||||
namespace etk {
|
||||
namespace io {
|
||||
@ -17,7 +18,7 @@ namespace etk {
|
||||
End, //!< request seek position start at the END of the file
|
||||
Current, //!< request seek position start at the CURRENT position in the file
|
||||
};
|
||||
//! @not_in_doc
|
||||
etk::Stream& operator <<(etk::Stream &_os, const enum etk::io::SeekMode &_obj);
|
||||
}
|
||||
//! @not_in_doc
|
||||
etk::Stream& operator <<(etk::Stream &_os, const enum etk::io::SeekMode &_obj);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ etk::io::ZipFile::ZipFile(const etk::Path& _path, ememory::SharedPtr<etk::Archiv
|
||||
|
||||
bool etk::io::ZipFile::open(etk::io::OpenMode _mode) {
|
||||
if (m_content != null) {
|
||||
TK_CRITICAL("File Already open : " << *this);
|
||||
TK_CRITICAL("File Already open : " << m_path);
|
||||
return true;
|
||||
}
|
||||
if (m_archive == null) {
|
||||
@ -54,7 +54,7 @@ bool etk::io::ZipFile::isOpen() {
|
||||
|
||||
bool etk::io::ZipFile::close() {
|
||||
if (m_content == null) {
|
||||
TK_CRITICAL("File Already closed : " << *this);
|
||||
TK_CRITICAL("File Already closed : " << m_path);
|
||||
return false;
|
||||
}
|
||||
m_archive->close(m_path);
|
||||
@ -65,23 +65,23 @@ bool etk::io::ZipFile::close() {
|
||||
|
||||
uint64_t etk::io::ZipFile::size() {
|
||||
if (m_content == null) {
|
||||
TK_CRITICAL("Can not access to the size: " << *this);
|
||||
TK_CRITICAL("Can not access to the size: " << m_path);
|
||||
return false;
|
||||
}
|
||||
return m_content->getTheoricSize()
|
||||
return m_content->getTheoricSize();
|
||||
}
|
||||
|
||||
|
||||
bool etk::io::ZipFile::seek(uint64_t _offset, enum etk::io::SeekMode _origin) {
|
||||
if (null == m_content) {
|
||||
if (m_content == null) {
|
||||
return false;
|
||||
}
|
||||
int32_t positionEnd = 0;
|
||||
switch(_origin) {
|
||||
case etk::seekNode_end:
|
||||
case etk::io::SeekMode::End:
|
||||
positionEnd = m_content->size();
|
||||
break;
|
||||
case etk::seekNode_current:
|
||||
case etk::io::SeekMode::Current:
|
||||
positionEnd = m_offset;
|
||||
break;
|
||||
default:
|
||||
@ -103,7 +103,7 @@ void etk::io::ZipFile::flush() {
|
||||
}
|
||||
|
||||
int64_t etk::io::ZipFile::tell() {
|
||||
if (null == m_content) {
|
||||
if (m_content == null) {
|
||||
return 0;
|
||||
}
|
||||
return m_offset;
|
||||
@ -125,6 +125,6 @@ int64_t etk::io::ZipFile::read(void* _data, int64_t _blockSize, int64_t _nbBlock
|
||||
}
|
||||
|
||||
int64_t etk::io::ZipFile::write(const void* _data, int64_t _blockSize, int64_t _nbBlock) {
|
||||
TK_CRITICAL("Can not write on data inside APK : " << *this);
|
||||
TK_CRITICAL("Can not write on data inside APK : " << m_path);
|
||||
return 0;
|
||||
}
|
||||
|
@ -7,6 +7,9 @@
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/io/Interface.hpp>
|
||||
#include <etk/fileSystem/Path.hpp>
|
||||
#include <ememory/SharedPtr.hpp>
|
||||
#include <etk/archive/Archive.hpp>
|
||||
|
||||
namespace etk {
|
||||
namespace io {
|
||||
@ -22,14 +25,13 @@ namespace etk {
|
||||
public:
|
||||
ZipFile(ememory::SharedPtr<etk::Archive> _archive);
|
||||
ZipFile(const etk::Path& _path, ememory::SharedPtr<etk::Archive> _archive);
|
||||
ETK_CONSTRUCTOR_COPY_DELETE(File);
|
||||
ETK_CONSTRUCTOR_MOVE_DEFAULT(File);
|
||||
ETK_CONSTRUCTOR_COPY_DELETE(ZipFile);
|
||||
ETK_CONSTRUCTOR_MOVE_DEFAULT(ZipFile);
|
||||
public:
|
||||
bool open(etk::io::OpenMode _mode) override;
|
||||
bool isOpen() override;
|
||||
bool close() override;
|
||||
uint64_t size() override;
|
||||
char* gets(char* _elementLine, int64_t _maxData) override;
|
||||
bool seek(uint64_t _offset, enum etk::io::SeekMode _origin) override;
|
||||
int64_t tell() override;
|
||||
void flush() override;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <etk/Map.hpp>
|
||||
#include <ethread/Mutex.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
#include <etk/theme/theme.hpp>
|
||||
#ifdef __TARGET_OS__Windows
|
||||
#include <tchar.h>
|
||||
#include <windows.h>
|
||||
@ -2237,52 +2238,6 @@ void etk::FSNode::fileFlush() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO : Add an INIT to reset all allocated parameter :
|
||||
static etk::Map<etk::String, etk::String> g_listTheme;
|
||||
|
||||
void etk::theme::setName(const etk::String& _refName, const etk::String& _folderName) {
|
||||
TK_WARNING("Change theme : '" << _refName << "' : '" << _folderName << "'");
|
||||
g_listTheme.set(_refName, _folderName);
|
||||
}
|
||||
|
||||
etk::String etk::theme::getName(const etk::String& _refName) {
|
||||
auto it = g_listTheme.find(_refName);
|
||||
if (it != g_listTheme.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return _refName;
|
||||
}
|
||||
|
||||
// get the list of all the theme folder availlable in the user Home/appl
|
||||
etk::Vector<etk::String> etk::theme::list() {
|
||||
etk::Vector<etk::String> keys;
|
||||
for (auto &it : g_listTheme) {
|
||||
keys.pushBack(it.first);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
static etk::Map<etk::String, etk::String> g_listThemeDefault;
|
||||
void etk::theme::setNameDefault(const etk::String& _refName, const etk::String& _folderName) {
|
||||
auto it = g_listThemeDefault.find(_refName);
|
||||
if (it != g_listThemeDefault.end()) {
|
||||
it->second = _folderName;
|
||||
return;
|
||||
}
|
||||
g_listThemeDefault.set(_refName, _folderName);
|
||||
}
|
||||
|
||||
etk::String etk::theme::getNameDefault(const etk::String& _refName) {
|
||||
auto it = g_listThemeDefault.find(_refName);
|
||||
if (it != g_listThemeDefault.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return "default";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
*
|
||||
* Simple direct wrapper on the FileSystem node access :
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
//http://developer.android.com/guide/topics/data/data-storage.html
|
||||
|
||||
|
||||
/*
|
||||
#ifdef __TARGET_OS__Android
|
||||
#define HAVE_ZIP_DATA
|
||||
#endif
|
||||
@ -29,7 +29,7 @@
|
||||
#ifdef __TARGET_OS__Web
|
||||
#define HAVE_ZIP_DATA
|
||||
#endif
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_ZIP_DATA
|
||||
namespace etk {
|
||||
|
@ -4,7 +4,10 @@
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/filesystem/theme.hpp>
|
||||
#include <etk/theme/theme.hpp>
|
||||
#include <etk/Map.hpp>
|
||||
#include <etk/debug.hpp>
|
||||
|
||||
|
||||
static etk::Map<etk::String, etk::String>& getTheme() {
|
||||
static etk::Map<etk::String, etk::String> g_listTheme;
|
||||
|
@ -5,6 +5,8 @@
|
||||
*/
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/String.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -31,7 +31,8 @@ def configure(target, my_module):
|
||||
'test/testPath.cpp',
|
||||
'test/testPermissions.cpp',
|
||||
'test/testTheme.cpp',
|
||||
"""
|
||||
])
|
||||
"""
|
||||
'test/ConstructDestruct.cpp',
|
||||
'test/testColor.cpp',
|
||||
'test/testFunction.cpp',
|
||||
@ -53,8 +54,7 @@ def configure(target, my_module):
|
||||
'test/testTrait.cpp',
|
||||
'test/testThrow.cpp',
|
||||
'test/testUTF8.cpp',
|
||||
"""
|
||||
])
|
||||
"""
|
||||
my_module.add_depend([
|
||||
'etk',
|
||||
'etest',
|
||||
|
@ -40,7 +40,9 @@ def configure(target, my_module):
|
||||
'etk/fileSystem/Type.cpp',
|
||||
'etk/io/OpenMode.cpp',
|
||||
'etk/io/SeekMode.cpp',
|
||||
'etk/io/Interface.cpp',
|
||||
'etk/io/File.cpp',
|
||||
'etk/io/ZipFile.cpp',
|
||||
'etk/theme/theme.cpp',
|
||||
'etk/math/Matrix2x2.cpp',
|
||||
'etk/math/Matrix2x3.cpp',
|
||||
@ -69,6 +71,11 @@ def configure(target, my_module):
|
||||
'etk/fileSystem/Path.hpp',
|
||||
'etk/fileSystem/Permissions.hpp',
|
||||
'etk/fileSystem/Type.hpp',
|
||||
'etk/io/OpenMode.hpp',
|
||||
'etk/io/SeekMode.hpp',
|
||||
'etk/io/Interface.hpp',
|
||||
'etk/io/File.hpp',
|
||||
'etk/io/ZipFile.hpp',
|
||||
'etk/theme/theme.hpp',
|
||||
'etk/math/Matrix2x2.hpp',
|
||||
'etk/math/Matrix2x3.hpp',
|
||||
|
@ -8,12 +8,13 @@
|
||||
|
||||
#include <etest/etest.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etk/fileSystem/filesystem.hpp>
|
||||
#include <etk/fileSystem/fileSystem.hpp>
|
||||
|
||||
TEST(TestFileSystem, checkHomePath) {
|
||||
EXPECT_EQ(etk::fileSystem::getHomePath(), "/home/heero");
|
||||
etk::String basicPath = getenv("HOME");
|
||||
EXPECT_EQ(etk::fileSystem::getHomePath(), basicPath);
|
||||
}
|
||||
|
||||
/*
|
||||
TEST(TestEtkFSNode, checkHomePath) {
|
||||
etk::String homePath = etk::FSNodeGetHomePath();
|
||||
EXPECT_EQ(homePath, "/home/heero");
|
||||
@ -28,4 +29,6 @@ TEST(TestEtkFSNode, checkHomePath) {
|
||||
etk::FSNode myNodeTest3("~/filePresent.txt");
|
||||
EXPECT_EQ(myNodeTest3.getNameFile(), "filePresent.txt");
|
||||
EXPECT_EQ(myNodeTest3.getFileSystemName(), homePath + "/filePresent.txt");
|
||||
EXPECT_EQ(myNodeTest3.getNameFolder(), "/home/heero");
|
||||
EXPECT_EQ(myNodeTest3.getNameFolder(), "/home/heero");
|
||||
}
|
||||
*/
|
@ -13,59 +13,82 @@
|
||||
TEST(TestPath, defaultContructor) {
|
||||
etk::Path path;
|
||||
EXPECT_EQ(path.getString(), "");
|
||||
EXPECT_EQ(path.isRelative(), true);
|
||||
EXPECT_EQ(path.isRelative(), false);
|
||||
EXPECT_EQ(path.isAbsolute(), false);
|
||||
}
|
||||
|
||||
TEST(TestPath, basic_relatif) {
|
||||
etk::Path path("hello");
|
||||
EXPECT_EQ(path.getSring(), "hello");
|
||||
EXPECT_EQ(path.getString(), "hello");
|
||||
EXPECT_EQ(path.isRelative(), true);
|
||||
EXPECT_EQ(path.isAbsolute(), false);
|
||||
}
|
||||
|
||||
TEST(TestPath, basic_relatif_2) {
|
||||
etk::Path path("hello/plouf");
|
||||
EXPECT_EQ(path.getSring(), "hello/plouf");
|
||||
EXPECT_EQ(path.getString(), "hello/plouf");
|
||||
EXPECT_EQ(path.isRelative(), true);
|
||||
EXPECT_EQ(path.isAbsolute(), false);
|
||||
}
|
||||
|
||||
TEST(TestPath, basic_relatif_2_windows) {
|
||||
etk::Path path("hello\\plouf");
|
||||
EXPECT_EQ(path.getSring(), "hello/plouf");
|
||||
EXPECT_EQ(path.getString(), "hello/plouf");
|
||||
EXPECT_EQ(path.isRelative(), true);
|
||||
EXPECT_EQ(path.isAbsolute(), false);
|
||||
}
|
||||
|
||||
TEST(TestPath, basic_absolute) {
|
||||
etk::Path path("/");
|
||||
EXPECT_EQ(path.getSring(), "/");
|
||||
EXPECT_EQ(path.getSringWindows(), "\\");
|
||||
EXPECT_EQ(path.getString(), "/");
|
||||
EXPECT_EQ(path.getStringWindows(), "\\");
|
||||
EXPECT_EQ(path.isRelative(), false);
|
||||
EXPECT_EQ(path.isAbsolute(), true);
|
||||
}
|
||||
|
||||
TEST(TestPath, basic_absolute_windows) {
|
||||
etk::Path path("k:\\");
|
||||
EXPECT_EQ(path.getSring(), "/k/");
|
||||
EXPECT_EQ(path.getSringWindows(), "k:\\");
|
||||
EXPECT_EQ(path.getString(), "/k/");
|
||||
EXPECT_EQ(path.getStringWindows(), "k:\\");
|
||||
EXPECT_EQ(path.isRelative(), false);
|
||||
EXPECT_EQ(path.isAbsolute(), true);
|
||||
}
|
||||
|
||||
TEST(TestPath, basic_absolute_2) {
|
||||
etk::Path path("/home/heero/hello/plouf");
|
||||
EXPECT_EQ(path.getSring(), "/home/heero/hello/plouf");
|
||||
EXPECT_EQ(path.getSringWindows(), "\\home\\heero\\hello\\plouf");
|
||||
EXPECT_EQ(path.getString(), "/home/heero/hello/plouf");
|
||||
EXPECT_EQ(path.getStringWindows(), "\\home\\heero\\hello\\plouf");
|
||||
EXPECT_EQ(path.isRelative(), false);
|
||||
EXPECT_EQ(path.isAbsolute(), true);
|
||||
}
|
||||
|
||||
TEST(TestPath, basic_absolute_2_windows) {
|
||||
etk::Path path("G:\\hello\\plouf");
|
||||
EXPECT_EQ(path.getSring(), "/g/hello/plouf");
|
||||
EXPECT_EQ(path.getSringWindows(), "g:\\hello\\plouf");
|
||||
EXPECT_EQ(path.getString(), "/g/hello/plouf");
|
||||
EXPECT_EQ(path.getStringWindows(), "g:\\hello\\plouf");
|
||||
EXPECT_EQ(path.isRelative(), false);
|
||||
EXPECT_EQ(path.isAbsolute(), true);
|
||||
}
|
||||
|
||||
TEST(TestPath, assignation) {
|
||||
etk::Path path;
|
||||
EXPECT_EQ(path.getString(), "");
|
||||
path = "/home/plouf";
|
||||
EXPECT_EQ(path.getString(), "/home/plouf");
|
||||
path = "rastapopoulos";
|
||||
EXPECT_EQ(path.getString(), "rastapopoulos");
|
||||
path = etk::Path("/home/plouf");
|
||||
EXPECT_EQ(path.getString(), "/home/plouf");
|
||||
path = etk::Path("rastapopoulos");
|
||||
EXPECT_EQ(path.getString(), "rastapopoulos");
|
||||
}
|
||||
|
||||
|
||||
TEST(TestPath, simplification) {
|
||||
etk::Path path("/home/../plouf");
|
||||
EXPECT_EQ(path.getString(), "/plouf");
|
||||
path = "/home/plouf/../";
|
||||
EXPECT_EQ(path.getString(), "/home");
|
||||
path = "/home/plouf/plaf/./././pluf/plouc/../../../mioch/narn/miasm/../";
|
||||
EXPECT_EQ(path.getString(), "/home/plouf/mioch/narn");
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <etk/fileSystem/Permissions.hpp>
|
||||
|
||||
TEST(TestPermission, defaultContructor) {
|
||||
etk::filesystem::Permissions permission;
|
||||
etk::fileSystem::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::filesystem::Permissions permission(o777);
|
||||
etk::fileSystem::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::filesystem::Permissions permission(o700);
|
||||
etk::fileSystem::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::filesystem::Permissions permission(o070);
|
||||
etk::fileSystem::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::filesystem::Permissions permission(o007);
|
||||
etk::fileSystem::Permissions permission(0007);
|
||||
EXPECT_EQ(permission.isUserReadable(), false);
|
||||
EXPECT_EQ(permission.isUserWritable(), false);
|
||||
EXPECT_EQ(permission.isUserRunable(), false);
|
||||
|
@ -13,28 +13,28 @@
|
||||
TEST(TestTheme, init_uninit) {
|
||||
etk::theme::init();
|
||||
etk::theme::setName("AAA", "aaa");
|
||||
EXPECT_EQ(etk::theme::getDefaultName("AAA"), "");
|
||||
EXPECT_EQ(etk::theme::getNameDefault("AAA"), "");
|
||||
EXPECT_EQ(etk::theme::getName("AAA"), "aaa");
|
||||
etk::theme::unInit()
|
||||
EXPECT_EQ(etk::theme::getDefaultName("AAA"), "");
|
||||
etk::theme::unInit();
|
||||
EXPECT_EQ(etk::theme::getNameDefault("AAA"), "");
|
||||
EXPECT_EQ(etk::theme::getName("AAA"), "");
|
||||
}
|
||||
|
||||
TEST(TestTheme, set) {
|
||||
etk::theme::init();
|
||||
etk::theme::setDefaultName("AAA", "aaa");
|
||||
EXPECT_EQ(etk::theme::getDefaultName("AAA"), "aaa");
|
||||
etk::theme::setNameDefault("AAA", "aaa");
|
||||
EXPECT_EQ(etk::theme::getNameDefault("AAA"), "aaa");
|
||||
EXPECT_EQ(etk::theme::getName("AAA"), "aaa");
|
||||
etk::theme::unInit()
|
||||
EXPECT_EQ(etk::theme::getDefaultName("AAA"), "");
|
||||
etk::theme::unInit();
|
||||
EXPECT_EQ(etk::theme::getNameDefault("AAA"), "");
|
||||
EXPECT_EQ(etk::theme::getName("AAA"), "");
|
||||
}
|
||||
|
||||
TEST(TestTheme, set2) {
|
||||
etk::theme::init();
|
||||
etk::theme::setDefaultName("AAA", "aaa");
|
||||
etk::theme::setNameDefault("AAA", "aaa");
|
||||
etk::theme::setName("AAA", "bbb");
|
||||
EXPECT_EQ(etk::theme::getDefaultName("AAA"), "aaa");
|
||||
EXPECT_EQ(etk::theme::getNameDefault("AAA"), "aaa");
|
||||
EXPECT_EQ(etk::theme::getName("AAA"), "bbb");
|
||||
etk::theme::unInit()
|
||||
etk::theme::unInit();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user