1717#include " CommonUtils/FileSystemUtils.h"
1818
1919#include < deque>
20- #include < iostream>
2120#include < chrono>
22- #include < cstdio>
2321#include < filesystem>
2422#include < algorithm>
23+ #include < climits>
24+ #include < fmt/core.h>
2525
26- using namespace std ;
2726using namespace o2 ::event_visualisation;
2827
29- using std::cout;
30- using std::endl;
3128using std::chrono::duration_cast;
3229using std::chrono::milliseconds;
33- using std::chrono::seconds;
3430using std::chrono::system_clock;
3531
3632std::deque<std::string> FileProducer::load (const std::string& path)
3733{
38- deque<string> result;
34+ std:: deque<std:: string> result;
3935
4036 for (const auto & entry : std::filesystem::directory_iterator (path)) {
4137 if (entry.path ().extension () == " .json" ) {
@@ -55,15 +51,20 @@ FileProducer::FileProducer(const std::string& path, int filesInFolder, const std
5551
5652std::string FileProducer::newFileName () const
5753{
58- string pholder = " {}" ;
59- string result = this ->mName ;
6054 auto millisec_since_epoch = duration_cast<milliseconds>(system_clock::now ().time_since_epoch ()).count ();
61- string stamp = std::to_string (millisec_since_epoch);
62- result.replace (result.find (pholder), pholder.length (), stamp);
55+
56+ char hostname[_POSIX_HOST_NAME_MAX];
57+ gethostname (hostname, _POSIX_HOST_NAME_MAX);
58+
59+ auto pid = getpid ();
60+
61+ auto result = fmt::format (this ->mName , fmt::arg (" hostname" , hostname), fmt::arg (" pid" , pid), fmt::arg (" timestamp" , millisec_since_epoch));
62+
6363 auto files = this ->load (this ->mPath );
6464 std::sort (files.begin (), files.end ());
65+
6566 while (files.size () >= this ->mFilesInFolder ) {
66- string front = files.front ();
67+ auto front = files.front ();
6768 files.pop_front ();
6869 std::remove ((this ->mPath + " /" + front).c_str ()); // delete file
6970 }
0 commit comments