[DEV] update to etk::FSNode

This commit is contained in:
Edouard DUPIN 2012-11-01 10:47:36 +01:00
parent eac1f8f594
commit 8fdeb39b5a
16 changed files with 93 additions and 90 deletions

View File

@ -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 );
}
/**

View File

@ -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
};

View File

@ -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 ...");

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);

View File

@ -28,6 +28,7 @@
#include <tinyXML/tinyxml.h>
#include <ewol/eObject/EObject.h>
#include <ewol/eObject/EObjectManager.h>
#include <etk/os/FSNode.h>
#define PFX "ColorizeManager "
@ -143,17 +144,17 @@ void classColorManager::LoadFile(const char * xmlFilename)
// allocate the document in the stack
TiXmlDocument XmlDocument;
// open the curent File
etk::File fileName(xmlFilename, etk::FILE_TYPE_DATA);
etk::FSNode fileName(etk::UString("DATA:") + xmlFilename);
if (false == fileName.Exist()) {
APPL_ERROR("File Does not exist : " << fileName);
return;
}
int32_t fileSize = fileName.Size();
int32_t fileSize = fileName.FileSize();
if (0==fileSize) {
APPL_ERROR("This file is empty : " << fileName);
return;
}
if (false == fileName.fOpenRead()) {
if (false == fileName.FileOpenRead()) {
APPL_ERROR("Can not open the file : " << fileName);
return;
}
@ -165,9 +166,9 @@ void classColorManager::LoadFile(const char * xmlFilename)
}
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file :
fileName.fRead(fileBuffer, 1, fileSize);
fileName.FileRead(fileBuffer, 1, fileSize);
// close the file:
fileName.fClose();
fileName.FileClose();
// load the XML from the memory
XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);

View File

@ -46,7 +46,7 @@ static void SortElementList(etk::Vector<appl::dataBufferStruct *> &list)
for(int32_t jjj=0; jjj<list.Size(); jjj++) {
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
if (list[jjj]!=NULL) {
if (tmpList[iii]->m_bufferName.GetShortFilename() > list[jjj]->m_bufferName.GetShortFilename()) {
if (tmpList[iii]->m_bufferName.GetNameFile() > list[jjj]->m_bufferName.GetNameFile()) {
findPos = jjj+1;
}
}
@ -103,7 +103,7 @@ void BufferView::OnReceiveMessage(ewol::EObject * CallerObject, const char * eve
for (int32_t iii=0; iii<nbBufferOpen; iii++) {
if (BufferManager::Exist(iii)) {
bool isModify = BufferManager::Get(iii)->IsModify();
etk::File name = BufferManager::Get(iii)->GetFileName();
etk::FSNode name = BufferManager::Get(iii)->GetFileName();
appl::dataBufferStruct* tmpElement = new appl::dataBufferStruct(name, iii, isModify);
if (NULL != tmpElement) {
m_list.PushBack(tmpElement);
@ -164,7 +164,7 @@ bool BufferView::GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToW
if( raw>=0
&& raw<m_list.Size()
&& NULL != m_list[raw]) {
myTextToWrite = m_list[raw]->m_bufferName.GetShortFilename();
myTextToWrite = m_list[raw]->m_bufferName.GetNameFile();
if (true == m_list[raw]->m_isModify) {
selectFG = COLOR_LIST_TEXT_MODIFY;

View File

@ -36,10 +36,10 @@ namespace appl
class dataBufferStruct
{
public:
etk::File m_bufferName;
uint32_t m_bufferID;
bool m_isModify;
dataBufferStruct(etk::File& bufferName, int32_t bufferID, bool isModify) :
etk::FSNode m_bufferName;
uint32_t m_bufferID;
bool m_isModify;
dataBufferStruct(etk::FSNode& bufferName, int32_t bufferID, bool isModify) :
m_bufferName(bufferName),
m_bufferID(bufferID),
m_isModify(isModify)

View File

@ -302,8 +302,8 @@ void MainWindows::OnReceiveMessage(ewol::EObject * CallerObject, const char * ev
if (BufferManager::GetSelected()!=-1) {
Buffer * myBuffer = BufferManager::Get(BufferManager::GetSelected());
if (NULL!=myBuffer) {
etk::File tmpFile = myBuffer->GetFileName();
tmpWidget->SetFolder(tmpFile.GetFolder());
etk::FSNode tmpFile = myBuffer->GetFileName();
tmpWidget->SetFolder(tmpFile.GetNameFolder());
}
}
PopUpWidgetPush(tmpWidget);
@ -335,9 +335,9 @@ void MainWindows::OnReceiveMessage(ewol::EObject * CallerObject, const char * ev
etk::UString folder = "/home/";
etk::UString fileName = "";
if (true == myBuffer->HaveName()) {
etk::File tmpName = myBuffer->GetFileName();
folder = tmpName.GetFolder();
fileName = tmpName.GetShortFilename();
etk::FSNode tmpName = myBuffer->GetFileName();
folder = tmpName.GetNameFolder();
fileName = tmpName.GetNameFile();
}
tmpWidget->SetFolder(folder);
tmpWidget->SetFileName(fileName);
@ -358,9 +358,9 @@ void MainWindows::OnReceiveMessage(ewol::EObject * CallerObject, const char * ev
// the buffer change we need to update the widget string
Buffer* tmpBuffer = BufferManager::Get(BufferManager::GetSelected());
if (NULL != tmpBuffer) {
etk::File compleateName = tmpBuffer->GetFileName();
etk::FSNode compleateName = tmpBuffer->GetFileName();
bool isModify = tmpBuffer->IsModify();
etk::UString directName = compleateName.GetCompleateName();
etk::UString directName = compleateName.GetName();
if (true == isModify) {
directName += " *";
}

View File

@ -49,17 +49,17 @@ Highlight::Highlight(etk::UString &xmlFilename)
{
TiXmlDocument XmlDocument;
etk::File fileName(xmlFilename, etk::FILE_TYPE_DATA);
etk::FSNode fileName(etk::UString("DATA:") + xmlFilename);
if (false == fileName.Exist()) {
APPL_ERROR("File Does not exist : " << fileName);
return;
}
int32_t fileSize = fileName.Size();
int32_t fileSize = fileName.FileSize();
if (0==fileSize) {
APPL_ERROR("This file is empty : " << fileName);
return;
}
if (false == fileName.fOpenRead()) {
if (false == fileName.FileOpenRead()) {
APPL_ERROR("Can not open the file : " << fileName);
return;
}
@ -71,9 +71,9 @@ Highlight::Highlight(etk::UString &xmlFilename)
}
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file :
fileName.fRead(fileBuffer, 1, fileSize);
fileName.FileRead(fileBuffer, 1, fileSize);
// close the file:
fileName.fClose();
fileName.FileClose();
// load the XML from the memory
bool loadError = XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
if (false == loadError) {
@ -191,15 +191,15 @@ bool Highlight::HasExtention(etk::UString &ext)
return false;
}
bool Highlight::FileNameCompatible(etk::File &fileName)
bool Highlight::FileNameCompatible(etk::FSNode &fileName)
{
int32_t i;
etk::UString extention;
if (true == fileName.HasExtention() ) {
if (true == fileName.FileHasExtention() ) {
extention = "*.";
extention += fileName.GetExtention();
extention += fileName.FileGetExtention();
} else {
extention = fileName.GetShortFilename();
extention = fileName.GetNameFile();
}
APPL_DEBUG(" try to find : in \"" << fileName << "\" extention:\"" << extention << "\" ");

View File

@ -42,7 +42,7 @@ extern "C" {
} colorInformation_ts;
}
#include <etk/os/File.h>
#include <etk/os/FSNode.h>
#include <HighlightPattern.h>
#include <Colorize.h>
#include <EdnVectorBuf.h>
@ -54,7 +54,7 @@ class Highlight {
Highlight(etk::UString &xmlFilename);
~Highlight(void);
bool HasExtention(etk::UString &ext);
bool FileNameCompatible(etk::File &fileName);
bool FileNameCompatible(etk::FSNode &fileName);
void Display(void);
void ReloadColor(void);
void Parse(int32_t start,

View File

@ -89,7 +89,7 @@ class localClassHighlightManager: public ewol::EObject
*/
}
Highlight* Get(etk::File &fileName)
Highlight* Get(etk::FSNode &fileName)
{
int32_t i;
for (i=0; i<listHighlight.Size(); i++) {
@ -100,7 +100,7 @@ class localClassHighlightManager: public ewol::EObject
return NULL;
}
bool Exist(etk::File &fileName)
bool Exist(etk::FSNode &fileName)
{
if (NULL != Get(fileName) ) {
return true;
@ -201,7 +201,7 @@ void HighlightManager::loadLanguages(void)
localManager->loadLanguages();
}
Highlight* HighlightManager::Get(etk::File &fileName)
Highlight* HighlightManager::Get(etk::FSNode &fileName)
{
if (NULL == localManager) {
return NULL;
@ -209,7 +209,7 @@ Highlight* HighlightManager::Get(etk::File &fileName)
return localManager->Get(fileName);
}
bool HighlightManager::Exist(etk::File &fileName)
bool HighlightManager::Exist(etk::FSNode &fileName)
{
if (NULL == localManager) {
return false;

View File

@ -36,8 +36,8 @@ namespace HighlightManager{
void Init(void);
void UnInit(void);
void loadLanguages(void);
Highlight* Get(etk::File &fileName);
bool Exist(etk::File &fileName);
Highlight* Get(etk::FSNode &fileName);
bool Exist(etk::FSNode &fileName);
};

View File

@ -31,7 +31,7 @@
#include <ewol/widget/meta/FileChooser.h>
#include <appl/Gui/TagFileSelection.h>
// TODO : The line ID is no more stored in the file system (FSNode) ...
#undef __class__
#define __class__ "CTagsManager"
@ -73,7 +73,7 @@ class CTagsManager: public ewol::EObject
tagFile * m_ctagFile;
// history system
int32_t m_historyPos;
etk::Vector<etk::File*> m_historyList;
etk::Vector<etk::FSNode*> m_historyList;
void RegisterHistory(void);
};
@ -151,9 +151,9 @@ void CTagsManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * e
} else if( eventId == ednEventPopUpCtagsLoadFile
|| eventId == ednMsgCtagsLoadFile) {
// open the new one :
etk::File tmpFilename = data;
m_tagFilename = tmpFilename.GetShortFilename();
m_tagFolderBase = tmpFilename.GetFolder();
etk::FSNode tmpFilename = data;
m_tagFilename = tmpFilename.GetNameFile();
m_tagFolderBase = tmpFilename.GetNameFolder();
APPL_DEBUG("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " ");
LoadTagFile();
} else if (eventId == ednMsgGuiCtags) {
@ -176,8 +176,8 @@ void CTagsManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * e
} else if (data == "Back") {
if (m_historyList.Size() > 0) {
int32_t id = m_historyList.Size()-1;
SendMultiCast(ednMsgOpenFile, m_historyList[id]->GetCompleateName() );
SendMultiCast(ednMsgGuiGotoLine, m_historyList[id]->GetLineNumber());
SendMultiCast(ednMsgOpenFile, m_historyList[id]->GetName() );
SendMultiCast(ednMsgGuiGotoLine, 0);// TODO : m_historyList[id]->GetLineNumber());
// Remove element ....
delete(m_historyList[id]);
m_historyList[id]=NULL;
@ -229,9 +229,9 @@ void CTagsManager::RegisterHistory(void)
int32_t currentSelected = BufferManager::GetSelected();
Buffer* tmpBuf = BufferManager::Get(currentSelected);
if (NULL != tmpBuf) {
etk::File * bufferFilename = new etk::File();
etk::FSNode * bufferFilename = new etk::FSNode();
*bufferFilename = tmpBuf->GetFileName();
bufferFilename->SetLineNumber(tmpBuf->GetCurrentLine());
// TODO : bufferFilename->SetLineNumber(tmpBuf->GetCurrentLine());
m_historyList.PushBack(bufferFilename);
}
}
@ -254,7 +254,7 @@ void CTagsManager::JumpTo(void)
// For all tags : Save in an internal Structure :
etk::UString tmpFile(m_tagFolderBase + "/" + entry.file);
etk::File myfile(tmpFile);
etk::FSNode myfile(tmpFile);
int32_t lineID = entry.address.lineNumber;
PrintTag(&entry, true);
@ -264,13 +264,13 @@ void CTagsManager::JumpTo(void)
if (NULL == tmpWidget) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
tmpWidget->AddCtagsNewItem(myfile.GetCompleateName(), lineID);
tmpWidget->AddCtagsNewItem(myfile.GetName(), lineID);
do {
tmpFile = m_tagFolderBase + "/" + entry.file;
myfile = tmpFile;
lineID = entry.address.lineNumber;
PrintTag(&entry, true);
tmpWidget->AddCtagsNewItem(myfile.GetCompleateName(), lineID);
tmpWidget->AddCtagsNewItem(myfile.GetName(), lineID);
} while (tagsFindNext (m_ctagFile, &entry) == TagSuccess);
PopUpWidgetPush(tmpWidget);
tmpWidget->RegisterOnEvent(this, applEventctagsSelection);
@ -278,7 +278,7 @@ void CTagsManager::JumpTo(void)
} else {
RegisterHistory();
APPL_INFO(" OPEN the TAG file Destination : " << tmpFile );
SendMultiCast(ednMsgOpenFile, myfile.GetCompleateName());
SendMultiCast(ednMsgOpenFile, myfile.GetName());
SendMultiCast(ednMsgGuiGotoLine, lineID - 1);
}
} else {

View File

@ -31,7 +31,7 @@
#include <appl/Debug.h>
#include <appl/global.h>
#include <etk/os/File.h>
#include <etk/os/FSNode.h>
#include <etk/tool.h>
#include <Gui/MainWindows.h>
#include <BufferManager.h>
@ -154,9 +154,9 @@ void APP_Init(void)
}
etk::File APP_Icon(void)
etk::FSNode APP_Icon(void)
{
etk::File bitmapFile("iconEdn.bmp", etk::FILE_TYPE_DATA);
etk::FSNode bitmapFile("DATA:iconEdn.bmp");
return bitmapFile;
}