diff --git a/etk/os/FSNode.cpp b/etk/os/FSNode.cpp index bbdca2f..715880f 100644 --- a/etk/os/FSNode.cpp +++ b/etk/os/FSNode.cpp @@ -1585,6 +1585,20 @@ char etk::FSNode::fileGet(void) { return data; } +bool etk::FSNode::fileGets(std::string& _output) { + _output.clear(); + char tmp = fileGet(); + while ( tmp != '\0' + && tmp != '\n') { + _output += tmp; + tmp = fileGet(); + } + if (tmp == '\0') { + return false; + } + return true; +} + int64_t etk::FSNode::fileRead(void* _data, int64_t _blockSize, int64_t _nbBlock) { #ifdef __TARGET_OS__Android if( m_type == etk::FSN_TYPE_DATA @@ -1606,6 +1620,20 @@ int64_t etk::FSNode::fileRead(void* _data, int64_t _blockSize, int64_t _nbBlock) return fread(_data, _blockSize, _nbBlock, m_PointerFile); } +bool etk::FSNode::filePut(char _input) { + if (fileWrite(&_input, 1, 1) == 1) { + return true; + } + return false; +} + +bool etk::FSNode::filePuts(const std::string& _input) { + if (fileWrite((void*)_input.c_str(), 1, _input.size()) == (int64_t)_input.size()) { + return true; + } + return false; +} + int64_t etk::FSNode::fileWrite(void * _data, int64_t _blockSize, int64_t _nbBlock) { #ifdef __TARGET_OS__Android if( m_type == etk::FSN_TYPE_DATA diff --git a/etk/os/FSNode.h b/etk/os/FSNode.h index 126f31f..8a1fbef 100644 --- a/etk/os/FSNode.h +++ b/etk/os/FSNode.h @@ -416,6 +416,27 @@ namespace etk { * @return the next element in the file. */ char fileGet(void); + /** + * @brief Get a compleate line in a text file + * @param[out] _output the next element in the file. + * @return true The file is not ended. + * @return false The file is ended. + */ + bool fileGets(std::string& _output); + /** + * @brief Write data on the file + * @param[in] _input data to write. + * @return true Write done corectly. + * @return false ErrorOn write. + */ + bool filePut(char _input); + /** + * @brief Write data on the file + * @param[in] _input data to write. + * @return true Write done corectly. + * @return false ErrorOn write. + */ + bool filePuts(const std::string& _input); /** * @brief Read data from the file * @param[in,out] _data Pointer on the buffer that might be set the data @@ -432,6 +453,7 @@ namespace etk { * @return Number of element written (in block number) */ int64_t fileWrite(void* _data, int64_t _blockSize, int64_t _nbBlock); + /** * @brief Move in the file Position * @param[in] _offset Offset to apply at the file