X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=blobdiff_plain;f=source%2Fcore%2Ffunctions.cpp;h=217fd0a41ed180da62d3a9619112d7b29d49f114;hp=8a779942ea45c9c581eeeb0933880a9c6c210219;hb=415985b3f67878c2e3cee785a0b1cb36f4eff901;hpb=227446df961ead723c8f2b04ea53d99c770a438f diff --git a/source/core/functions.cpp b/source/core/functions.cpp index 8a77994..217fd0a 100644 --- a/source/core/functions.cpp +++ b/source/core/functions.cpp @@ -30,6 +30,8 @@ #include #include +#include +#include using namespace anna; @@ -1612,3 +1614,18 @@ std::string functions::decodeBase64(const std::string & encodedString) { return ret; } +bool functions::getContentFromFile(const std::string &pathfile, std::string &content) throw(anna::RuntimeException) { + + std::ifstream inFile(pathfile.c_str(), std::ifstream::in); + if(!inFile.good()) { + throw RuntimeException(anna::functions::asString("Unable to open file '%s'", pathfile.c_str()), ANNA_FILE_LOCATION); + } + + std::stringstream strStream; + strStream << inFile.rdbuf(); //read the file + content = strStream.str(); // holds the content of the file + inFile.close(); + + return true; +} +