[DEV] update to etk::FSNode
This commit is contained in:
@@ -51,7 +51,7 @@ Buffer::Buffer()
|
||||
EWOL_DEBUG("Create buffer try name : \"" << mString << "\"");
|
||||
SetFileName(mString);
|
||||
m_haveName = false;
|
||||
EWOL_DEBUG("Create buffer with name : \"" << m_fileName.GetCompleateName() << "\"");
|
||||
EWOL_DEBUG("Create buffer with name : " << m_fileName );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,12 +62,12 @@ Buffer::Buffer()
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Buffer::Buffer(etk::File &newName)
|
||||
Buffer::Buffer(etk::FSNode &newName)
|
||||
{
|
||||
m_fileModify = false;
|
||||
EWOL_DEBUG("Create buffer try name : \"" << newName << "\"");
|
||||
SetFileName(newName);
|
||||
EWOL_DEBUG("Create buffer with name : \"" << m_fileName.GetCompleateName() << "\"");
|
||||
EWOL_DEBUG("Create buffer with name : " << m_fileName );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#define __BUFFER_H__
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <etk/os/File.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <etk/unicode.h>
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
@@ -50,15 +50,15 @@ typedef struct{
|
||||
class Buffer {
|
||||
public:
|
||||
Buffer(void);
|
||||
Buffer(etk::File &newName);
|
||||
Buffer(etk::FSNode &newName);
|
||||
virtual ~Buffer(void);
|
||||
|
||||
etk::File GetFileName(void)
|
||||
etk::FSNode GetFileName(void)
|
||||
{
|
||||
return m_fileName;
|
||||
};
|
||||
|
||||
void SetFileName(etk::File &newName)
|
||||
void SetFileName(etk::FSNode &newName)
|
||||
{
|
||||
m_fileName = newName;
|
||||
m_haveName = true;
|
||||
@@ -67,7 +67,7 @@ class Buffer {
|
||||
|
||||
void SetFileName(etk::UString &newName)
|
||||
{
|
||||
m_fileName.SetCompleateName(newName, etk::FILE_TYPE_DIRECT);
|
||||
m_fileName.SetName(newName);
|
||||
m_haveName = true;
|
||||
NameChange();
|
||||
};
|
||||
@@ -139,7 +139,7 @@ class Buffer {
|
||||
protected:
|
||||
bool m_fileModify; //!<
|
||||
// naming
|
||||
etk::File m_fileName; //!< filename of the curent buffer
|
||||
etk::FSNode m_fileName; //!< filename of the curent buffer
|
||||
bool m_haveName; //!< to know if the file have a name or NOT
|
||||
};
|
||||
|
||||
|
@@ -63,15 +63,15 @@ class classBufferManager: public ewol::EObject
|
||||
// create a buffer with no element
|
||||
int32_t Create(void);
|
||||
// open curent filename
|
||||
int32_t Open(etk::File &myFile);
|
||||
int32_t Open(etk::FSNode &myFile);
|
||||
bool Remove(int32_t BufferID);
|
||||
public:
|
||||
int32_t GetSelected(void) { return m_idSelected;};
|
||||
//void SetSelected(int32_t id) {m_idSelected = id;};
|
||||
Buffer * Get(int32_t BufferID);
|
||||
bool Exist(int32_t BufferID);
|
||||
bool Exist(etk::File &myFile);
|
||||
int32_t GetId(etk::File &myFile);
|
||||
bool Exist(etk::FSNode &myFile);
|
||||
int32_t GetId(etk::FSNode &myFile);
|
||||
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
|
||||
uint32_t Size(void);
|
||||
uint32_t SizeOpen(void);
|
||||
@@ -165,7 +165,7 @@ void classBufferManager::OnReceiveMessage(ewol::EObject * CallerObject, const ch
|
||||
}
|
||||
} else if (eventId == ednMsgOpenFile) {
|
||||
if (data != "" ) {
|
||||
etk::File myFile(data, etk::FILE_TYPE_DIRECT);
|
||||
etk::FSNode myFile(data);
|
||||
APPL_DEBUG("request open file = \"" <<data << "\" ?= \"" << myFile << "\"");
|
||||
int32_t newOne = Open(myFile);
|
||||
if (-1 != newOne) {
|
||||
@@ -343,7 +343,7 @@ int32_t classBufferManager::Create(void)
|
||||
* @todo : check if this file is not curently open and return the old ID
|
||||
*
|
||||
*/
|
||||
int32_t classBufferManager::Open(etk::File &myFile)
|
||||
int32_t classBufferManager::Open(etk::FSNode &myFile)
|
||||
{
|
||||
if (false == Exist(myFile)) {
|
||||
// allocate a new Buffer
|
||||
@@ -396,7 +396,7 @@ bool classBufferManager::Exist(int32_t BufferID)
|
||||
}
|
||||
|
||||
|
||||
bool classBufferManager::Exist(etk::File &myFile )
|
||||
bool classBufferManager::Exist(etk::FSNode &myFile )
|
||||
{
|
||||
if (-1 == GetId(myFile)) {
|
||||
return false;
|
||||
@@ -405,7 +405,7 @@ bool classBufferManager::Exist(etk::File &myFile )
|
||||
}
|
||||
|
||||
|
||||
int32_t classBufferManager::GetId(etk::File &myFile)
|
||||
int32_t classBufferManager::GetId(etk::FSNode &myFile)
|
||||
{
|
||||
int32_t iii;
|
||||
// check if the Buffer existed
|
||||
@@ -561,7 +561,7 @@ bool BufferManager::Exist(int32_t BufferID)
|
||||
return localManager->Exist(BufferID);
|
||||
}
|
||||
|
||||
bool BufferManager::Exist(etk::File &myFile)
|
||||
bool BufferManager::Exist(etk::FSNode &myFile)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
@@ -570,7 +570,7 @@ bool BufferManager::Exist(etk::File &myFile)
|
||||
return localManager->Exist(myFile);
|
||||
}
|
||||
|
||||
int32_t BufferManager::GetId(etk::File &myFile)
|
||||
int32_t BufferManager::GetId(etk::FSNode &myFile)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
|
@@ -39,8 +39,8 @@ namespace BufferManager
|
||||
int32_t GetSelected(void);
|
||||
Buffer * Get(int32_t BufferID);
|
||||
bool Exist(int32_t BufferID);
|
||||
bool Exist(etk::File &myFile);
|
||||
int32_t GetId(etk::File &myFile);
|
||||
bool Exist(etk::FSNode &myFile);
|
||||
int32_t GetId(etk::FSNode &myFile);
|
||||
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
|
||||
uint32_t Size(void);
|
||||
uint32_t SizeOpen(void);
|
||||
|
@@ -117,20 +117,22 @@ BufferText::BufferText()
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
BufferText::BufferText(etk::File &fileName) : Buffer(fileName)
|
||||
BufferText::BufferText(etk::FSNode &fileName) : Buffer(fileName)
|
||||
{
|
||||
BasicInit();
|
||||
NameChange();
|
||||
APPL_INFO("Add Data from file(" << GetFileName() << ")");
|
||||
FILE * myFile = NULL;
|
||||
// try to open the file. if not existed, new file
|
||||
|
||||
myFile = fopen(fileName.GetCompleateName().c_str(), "r");
|
||||
if (NULL != myFile) {
|
||||
m_EdnBuf.DumpFrom(myFile);
|
||||
// close the input file
|
||||
fclose(myFile);
|
||||
SetModify(false);
|
||||
etk::FSNode myFile(fileName);
|
||||
if (true == myFile.Exist()) {
|
||||
if (false == myFile.FileOpenRead()) {
|
||||
APPL_WARNING("File can not be open in read mode : " << myFile);
|
||||
SetModify(true);
|
||||
} else {
|
||||
// TODO : Old methode to file access :
|
||||
//m_EdnBuf.DumpFrom(myFile);
|
||||
myFile.FileClose();
|
||||
SetModify(false);
|
||||
}
|
||||
} else {
|
||||
// fichier inexistant... creation d'un nouveaux
|
||||
APPL_WARNING("No File ==> created a new one(" << GetFileName() << ")");
|
||||
@@ -151,14 +153,14 @@ BufferText::BufferText(etk::File &fileName) : Buffer(fileName)
|
||||
void BufferText::Save(void)
|
||||
{
|
||||
APPL_INFO("Save File : \"" << GetFileName() << "\"" );
|
||||
FILE * myFile = NULL;
|
||||
myFile = fopen(GetFileName().GetCompleateName().c_str(), "w");
|
||||
if (NULL != myFile) {
|
||||
m_EdnBuf.DumpIn(myFile);
|
||||
fclose(myFile);
|
||||
SetModify(false);
|
||||
} else {
|
||||
etk::FSNode myFile(GetFileName());
|
||||
if (false == myFile.FileOpenWrite()) {
|
||||
APPL_ERROR("Can not open in writing the specify file");
|
||||
} else {
|
||||
// TODO : Old methode to file access :
|
||||
//m_EdnBuf.DumpIn(myFile);
|
||||
myFile.FileClose();
|
||||
SetModify(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ class CharElement
|
||||
class BufferText : public Buffer {
|
||||
public:
|
||||
BufferText(void);
|
||||
BufferText(etk::File &fileName);
|
||||
BufferText(etk::FSNode &fileName);
|
||||
virtual ~BufferText(void);
|
||||
void Save(void);
|
||||
|
||||
|
Reference in New Issue
Block a user