mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-01 06:42:22 +02:00
Add method for reading latest file
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "BufferUtils.hpp"
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user