[DEBUG] correction of the read write access in the buffer system
This commit is contained in:
parent
841f23a2db
commit
450fc0532d
@ -128,8 +128,7 @@ BufferText::BufferText(etk::FSNode &fileName) : Buffer(fileName)
|
||||
APPL_WARNING("File can not be open in read mode : " << myFile);
|
||||
SetModify(true);
|
||||
} else {
|
||||
// TODO : Old methode to file access :
|
||||
//m_EdnBuf.DumpFrom(myFile);
|
||||
m_EdnBuf.DumpFrom(myFile);
|
||||
myFile.FileClose();
|
||||
SetModify(false);
|
||||
}
|
||||
@ -157,8 +156,7 @@ void BufferText::Save(void)
|
||||
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);
|
||||
m_EdnBuf.DumpIn(myFile);
|
||||
myFile.FileClose();
|
||||
SetModify(false);
|
||||
}
|
||||
|
@ -89,10 +89,10 @@ EdnBuf::~EdnBuf(void)
|
||||
* @return true if OK / false if an error occured
|
||||
*
|
||||
*/
|
||||
bool EdnBuf::DumpIn(FILE *myFile)
|
||||
bool EdnBuf::DumpIn(etk::FSNode &file)
|
||||
{
|
||||
// write Data
|
||||
return m_data.DumpIn(myFile);
|
||||
return m_data.DumpIn(file);
|
||||
}
|
||||
|
||||
|
||||
@ -104,9 +104,9 @@ bool EdnBuf::DumpIn(FILE *myFile)
|
||||
* @return true if OK / false if an error occured
|
||||
*
|
||||
*/
|
||||
bool EdnBuf::DumpFrom(FILE *myFile)
|
||||
bool EdnBuf::DumpFrom(etk::FSNode &file)
|
||||
{
|
||||
if (true == m_data.DumpFrom(myFile) ) {
|
||||
if (true == m_data.DumpFrom(file) ) {
|
||||
// set no selection
|
||||
UpdateSelection(0, 0, m_data.Size() );
|
||||
// generate HighLight
|
||||
|
@ -78,8 +78,8 @@ class EdnBuf {
|
||||
void SetAll( etk::Vector<int8_t> &text);
|
||||
void GetRange( int32_t start, int32_t end, etk::Vector<int8_t> &output);
|
||||
void GetRange( int32_t start, int32_t end, etk::UString &output);
|
||||
bool DumpIn( FILE *myFile);
|
||||
bool DumpFrom( FILE *myFile);
|
||||
bool DumpIn( etk::FSNode &file);
|
||||
bool DumpFrom( etk::FSNode &file);
|
||||
// replace with operator [] ...
|
||||
int8_t operator[] (int32_t);
|
||||
int32_t Insert( int32_t pos, etk::Vector<int8_t> &insertText);
|
||||
|
@ -114,12 +114,12 @@ static int32_t getFileSize(FILE *myFile)
|
||||
* @return true if OK / false if an error occured
|
||||
*
|
||||
*/
|
||||
bool EdnVectorBuf::DumpIn(FILE *myFile)
|
||||
bool EdnVectorBuf::DumpIn(etk::FSNode &file)
|
||||
{
|
||||
bool ret = true;
|
||||
// write Data
|
||||
(void)fwrite(m_data, sizeof(int8_t), m_gapStart, myFile);
|
||||
(void)fwrite(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd, myFile);
|
||||
(void)file.FileWrite(m_data, sizeof(int8_t), m_gapStart);
|
||||
(void)file.FileWrite(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -132,19 +132,19 @@ bool EdnVectorBuf::DumpIn(FILE *myFile)
|
||||
* @return true if OK / false if an error occured
|
||||
*
|
||||
*/
|
||||
bool EdnVectorBuf::DumpFrom(FILE *myFile)
|
||||
bool EdnVectorBuf::DumpFrom(etk::FSNode &file)
|
||||
{
|
||||
bool ret = true;
|
||||
int32_t length = getFileSize(myFile);
|
||||
uint32_t length = file.FileSize();
|
||||
// error case ...
|
||||
if (length < 0) {
|
||||
length = 0;
|
||||
if (length > 2000000000) {
|
||||
return false;
|
||||
}
|
||||
// allocate the current buffer :
|
||||
ChangeAllocation(length + GAP_SIZE_MIN);
|
||||
|
||||
// insert Data
|
||||
int32_t nbReadData = fread(&m_data[GAP_SIZE_MIN], sizeof(int8_t), length, myFile);
|
||||
int32_t nbReadData = file.FileRead(&m_data[GAP_SIZE_MIN], sizeof(int8_t), length);
|
||||
APPL_INFO("load data : filesize=" << length << ", readData=" << nbReadData);
|
||||
// check ERROR
|
||||
if (nbReadData != length) {
|
||||
|
@ -27,6 +27,7 @@
|
||||
#define __EDN_VECTOR_BUF_H__
|
||||
|
||||
#include <etk/Vector.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "EdnVectorBuf"
|
||||
@ -265,8 +266,8 @@ class EdnVectorBuf
|
||||
EdnVectorBuf(const EdnVectorBuf & Evb);
|
||||
~EdnVectorBuf();
|
||||
|
||||
bool DumpIn( FILE *myFile);
|
||||
bool DumpFrom( FILE *myFile);
|
||||
bool DumpIn( etk::FSNode &file);
|
||||
bool DumpFrom( etk::FSNode &file);
|
||||
|
||||
EdnVectorBuf & operator=( const EdnVectorBuf & Evb);
|
||||
int8_t operator[] (int32_t pos);
|
||||
|
Loading…
x
Reference in New Issue
Block a user