diff --git a/core-buffer/include/BinaryWriter.hpp b/core-buffer/include/BinaryWriter.hpp index 939ea6c..10f1154 100644 --- a/core-buffer/include/BinaryWriter.hpp +++ b/core-buffer/include/BinaryWriter.hpp @@ -11,6 +11,7 @@ class BinaryWriter { std::string current_filename_; int output_fd_; + std::string latest_filename_; public: BinaryWriter( diff --git a/core-buffer/src/BinaryWriter.cpp b/core-buffer/src/BinaryWriter.cpp index bb9783b..eaeb274 100644 --- a/core-buffer/src/BinaryWriter.cpp +++ b/core-buffer/src/BinaryWriter.cpp @@ -16,7 +16,19 @@ BinaryWriter::BinaryWriter( current_filename_(""), output_fd_(-1) { + latest_filename_ = root_folder + "/" + device_name + "/LATEST"; + #ifdef DEBUG_OUTPUT + using namespace date; + using namespace chrono; + cout << "[" << system_clock::now() << "]"; + cout << "[BinaryWriter::BinaryWriter]"; + cout << " Starting with"; + cout << " device_name " << device_name_; + cout << " root_folder_ " << root_folder_; + cout << " latest_filename_ " << latest_filename_; + cout << endl; + #endif } void BinaryWriter::write(uint64_t pulse_id, const JFFileFormat& buffer) @@ -40,5 +52,13 @@ void BinaryWriter::close_current_file() throw runtime_error(err_msg.str()); } + + // TODO: Ugly hack, please please fix it. + stringstream latest_command; + latest_command << "echo " << current_filename_; + latest_command << " > " << latest_filename_; + auto str_latest_command = latest_command.str(); + + system(str_latest_command.c_str()); } } \ No newline at end of file