mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-04-29 08:42:24 +02:00
Replace slow call with C++17 stdlib
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <filesystem>
|
||||
|
||||
#include "WriterUtils.hpp"
|
||||
#include "date.h"
|
||||
@@ -41,9 +42,20 @@ void WriterUtils::create_destination_folder(const string& output_file)
|
||||
auto file_separator_index = output_file.rfind('/');
|
||||
|
||||
if (file_separator_index != string::npos) {
|
||||
|
||||
string output_folder(output_file.substr(0, file_separator_index));
|
||||
|
||||
string create_folder_command("mkdir -p " + output_folder);
|
||||
system(create_folder_command.c_str());
|
||||
if(!filesystem::create_directories(output_folder)) {
|
||||
stringstream err_msg;
|
||||
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
err_msg << "[" << system_clock::now() << "]";
|
||||
err_msg << "[WriterUtils::create_destination_folder]";
|
||||
err_msg << " Cannot create directory ";
|
||||
err_msg << output_folder << endl;
|
||||
|
||||
throw runtime_error(err_msg.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user