]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMCMakeListsFile.cpp
Feature #1711 CreaDevManager application implementation
[crea.git] / lib / creaDevManagerLib / modelCDMCMakeListsFile.cpp
index 7cdcc6381d1c022f76aabf7124d8b1957711c20e..2dc48b478d29cdaac5926dc1655e42bcad209e79 100644 (file)
 
 #include "modelCDMCMakeListsFile.h"
 
+#include <fstream>
+
+#include<creaWx.h>
+#include<wx/dir.h>
+
+#include "CDMUtilities.h"
+
 modelCDMCMakeListsFile::modelCDMCMakeListsFile()
 {
 }
 
-modelCDMCMakeListsFile::modelCDMCMakeListsFile(const std::string& path,
-    const int& level)
+modelCDMCMakeListsFile::modelCDMCMakeListsFile(modelCDMIProjectTreeNode* parent, const std::string& path, const std::string& name, const int& level)
 {
+  std::cout << "creating cmakelist file: " + path + "\n";
+  this->parent = parent;
+  this->children.clear();
+  this->level = level;
+  this->type = wxDIR_FILES;
+  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()
@@ -49,12 +67,28 @@ modelCDMCMakeListsFile::~modelCDMCMakeListsFile()
 
 bool modelCDMCMakeListsFile::OpenFile(std::string*& result)
 {
-  //TODO: implement method
-  return true;
+
+  if (!CDMUtilities::openTextEditor(this->path))
+    return true;
+  else
+    {
+      result = new std::string("Couldn't open CMakeLists file.");
+      return false;
+    }
 }
 
 const bool modelCDMCMakeListsFile::Refresh(std::string*& result)
 {
-  //TODO: implement method
+  //std::cout << "refreshing cmakelists" << std::endl;
+  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;
 }