X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FmodelCDMCMakeListsFile.cpp;h=2dc48b478d29cdaac5926dc1655e42bcad209e79;hb=9f11db34cb1acacf545f819d6b552a95835d93bd;hp=768ce80cdd2fb6bf2d1b4d6f81ed57df0c56c1c0;hpb=f0d6beb7af51921d5245cd04e307e69993044dfc;p=crea.git diff --git a/lib/creaDevManagerLib/modelCDMCMakeListsFile.cpp b/lib/creaDevManagerLib/modelCDMCMakeListsFile.cpp index 768ce80..2dc48b4 100644 --- a/lib/creaDevManagerLib/modelCDMCMakeListsFile.cpp +++ b/lib/creaDevManagerLib/modelCDMCMakeListsFile.cpp @@ -34,21 +34,31 @@ #include "modelCDMCMakeListsFile.h" +#include + #include #include +#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 = "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() @@ -57,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; }