From 64812713c7bfa87ab1f3368cf58cca7d6d996007 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 5 Apr 2013 23:20:18 +0200 Subject: [PATCH] [DEV] add the remove capacity of FSNode --- etk/os/FSNode.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/etk/os/FSNode.cpp b/etk/os/FSNode.cpp index f947559..888e6e2 100644 --- a/etk/os/FSNode.cpp +++ b/etk/os/FSNode.cpp @@ -874,9 +874,24 @@ bool etk::FSNode::Touch(void) } bool etk::FSNode::Remove(void) { - // TODO : ... - return false; + if (GetNodeType()==etk::FSN_FOLDER) { + // remove the folder + if( 0!=rmdir(m_systemFileName.c_str()) ) { + if (ENOTEMPTY == errno) { + TK_ERROR("The Directory is not empty..."); + } + return false; + } + } else { + if( 0!=unlink(m_systemFileName.c_str()) ) { + return false; + } + } + // update internal time and properties ... + UpdateFileSystemProperty(); + return true; } + uint64_t etk::FSNode::TimeCreated(void) const { return m_timeCreate; @@ -1292,6 +1307,7 @@ bool etk::FSNode::FileOpenWrite(void) TK_CRITICAL("File Already open : " << *this); return true; } + FSNODE_LOCAL_mkPath(GetNameFolder().c_str() , 0777); m_PointerFile=fopen(m_systemFileName.c_str(),"wb"); if(NULL == m_PointerFile) { TK_ERROR("Can not find the file " << *this);