]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMCMakeListsFile.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / modelCDMCMakeListsFile.cpp
index 2b9cb2af8817fcf03bbef22ec0a6b78d797a5c27..dfbb99958af7655d8cfb22f3c34a8125dd205a00 100644 (file)
@@ -34,6 +34,8 @@
 
 #include "modelCDMCMakeListsFile.h"
 
+#include <fstream>
+
 #include<creaWx.h>
 #include<wx/dir.h>
 
@@ -43,14 +45,18 @@ modelCDMCMakeListsFile::modelCDMCMakeListsFile()
 {
 }
 
-modelCDMCMakeListsFile::modelCDMCMakeListsFile(const std::string& path,
-    const int& level)
+modelCDMCMakeListsFile::modelCDMCMakeListsFile(const std::string& path, const std::string& name, const int& level)
 {
   this->children.clear();
   this->level = level;
   this->type = wxDIR_FILES;
-  this->name = "CMakeFileLists.txt";
+  this->name = name;
   this->path = path;
+
+  std::ifstream in(path.c_str(), std::ifstream::in | std::ifstream::binary);
+  in.seekg(0, std::ifstream::end);
+  this->length = in.tellg();
+  in.close();
 }
 
 modelCDMCMakeListsFile::~modelCDMCMakeListsFile()
@@ -71,6 +77,15 @@ bool modelCDMCMakeListsFile::OpenFile(std::string*& result)
 
 const bool modelCDMCMakeListsFile::Refresh(std::string*& result)
 {
-  //TODO: implement method
+  std::ifstream in((this->path).c_str());
+  if(!in.is_open())
+    {
+      in.close();
+      return false;
+    }
+  std::ifstream in2(path.c_str(), std::ifstream::in | std::ifstream::binary);
+  in2.seekg(0, std::ifstream::end);
+  this->length = in2.tellg();
+  in2.close();
   return true;
 }