From ddcefd584eb74623db302c12154802f26f1081a5 Mon Sep 17 00:00:00 2001 From: Andrej Babic Date: Mon, 20 Apr 2020 17:47:55 +0200 Subject: [PATCH] Add method for reading latest file --- core-buffer/include/BufferUtils.hpp | 2 ++ core-buffer/src/BufferUtils.cpp | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/core-buffer/include/BufferUtils.hpp b/core-buffer/include/BufferUtils.hpp index 10f022d..aa1ef2b 100644 --- a/core-buffer/include/BufferUtils.hpp +++ b/core-buffer/include/BufferUtils.hpp @@ -19,6 +19,8 @@ namespace BufferUtils void update_latest_file( const std::string& latest_filename, const std::string& filename_to_write); + + std::string get_latest_file(const std::string& latest_filename); } #endif //BUFFER_UTILS_HPP diff --git a/core-buffer/src/BufferUtils.cpp b/core-buffer/src/BufferUtils.cpp index 5647e32..679abd4 100644 --- a/core-buffer/src/BufferUtils.cpp +++ b/core-buffer/src/BufferUtils.cpp @@ -1,5 +1,6 @@ #include "BufferUtils.hpp" #include +#include using namespace std; @@ -50,4 +51,16 @@ void BufferUtils::update_latest_file( auto str_latest_command = latest_command.str(); system(str_latest_command.c_str()); -} \ No newline at end of file +} + +string BufferUtils::get_latest_file(const string& latest_filename) +{ + std::ifstream latest_input_file; + latest_input_file.open(latest_filename); + + std::stringstream strStream; + strStream << latest_input_file.rdbuf(); + std::string filename = strStream.str(); + + return filename.substr(0, filename.size()-1); +}