diff --git a/core-buffer/include/BufferUtils.hpp b/core-buffer/include/BufferUtils.hpp index 4ec03d4..d1e07eb 100644 --- a/core-buffer/include/BufferUtils.hpp +++ b/core-buffer/include/BufferUtils.hpp @@ -14,6 +14,10 @@ namespace BufferUtils uint64_t pulse_id); std::size_t get_file_frame_index(uint64_t pulse_id); + + void update_latest_file( + const std::string& latest_filename, + const std::string& filename_to_write); } #endif //BUFFER_UTILS_HPP diff --git a/core-buffer/src/BinaryWriter.cpp b/core-buffer/src/BinaryWriter.cpp index 39ecfd2..5c891ea 100644 --- a/core-buffer/src/BinaryWriter.cpp +++ b/core-buffer/src/BinaryWriter.cpp @@ -127,14 +127,8 @@ void BinaryWriter::close_current_file() output_file_fd_ = -1; - // TODO: Ugly hack, please please fix it. - // TODO: This for now works only if the root_folder is absolute path. - stringstream latest_command; - latest_command << "echo " << current_output_filename_; - latest_command << " > " << latest_filename_; - auto str_latest_command = latest_command.str(); - - system(str_latest_command.c_str()); + BufferUtils::update_latest_file( + latest_filename_, current_output_filename_); } current_output_filename_ = ""; diff --git a/core-buffer/src/BufferUtils.cpp b/core-buffer/src/BufferUtils.cpp index 7e5e140..002f552 100644 --- a/core-buffer/src/BufferUtils.cpp +++ b/core-buffer/src/BufferUtils.cpp @@ -32,4 +32,19 @@ size_t BufferUtils::get_file_frame_index(uint64_t pulse_id) file_base *= FILE_MOD; return pulse_id - file_base; +} + +void BufferUtils::update_latest_file( + const std::string& latest_filename, + const std::string& filename_to_write) +{ + // TODO: Ugly hack, please please fix it. + // TODO: This for now works only if the root_folder is absolute path. + + stringstream latest_command; + latest_command << "echo " << filename_to_write; + latest_command << " > " << latest_filename; + auto str_latest_command = latest_command.str(); + + system(str_latest_command.c_str()); } \ No newline at end of file