37 LOGF(info,
"Translate: %s -> %s",
src,
dst);
41 std::filesystem::path(
src).extension());
43 std::filesystem::path(
dst).extension());
45 std::chrono::time_point currentTime = std::chrono::high_resolution_clock::now();
46 std::chrono::time_point endTime = std::chrono::high_resolution_clock::now();
48 srcSerializer->fromFile(vEvent,
src);
49 endTime = std::chrono::high_resolution_clock::now();
52 vEvent = vEvent.
limit(limit);
55 currentTime = std::chrono::high_resolution_clock::now();
56 dstSerializer->toFile(vEvent,
dst);
57 endTime = std::chrono::high_resolution_clock::now();
66 std::vector<std::string> supported = {
".json",
".root",
".eve"};
67 auto ext1 = srcFolder.substr(srcFolder.rfind(
'.'));
68 auto ext2 = dstFolder.substr(dstFolder.rfind(
'.'));
70 if (supported.end() == std::find(supported.begin(), supported.end(), ext1)) {
71 LOGF(error,
"source folder should end with source extension: /path-to-folder/.ext1 ");
74 if (supported.end() == std::find(supported.begin(), supported.end(), ext2)) {
75 LOGF(error,
"destination folder should end with destination extension: /path-to-folder/.ext2 ");
78 auto src = srcFolder.substr(0, srcFolder.size() - std::string(ext1).size());
79 auto dst = dstFolder.substr(0, dstFolder.size() - std::string(ext2).size());
82 LOGF(error,
"source folder same as destination folder ");
85 if (!std::filesystem::is_directory(
src)) {
86 LOGF(error,
"source folder do not exist ");
89 if (!std::filesystem::is_directory(
dst)) {
90 LOGF(error,
"destination folder do not exist ");
93 std::vector<std::string> vExt1 = {ext1};
95 std::vector<std::string> vExt2 = {ext2};
99 for (
auto& e : destinationList) {
100 auto match = e.substr(0, e.size() - ext2.size()) + ext1;
101 if (sourceList.end() == std::find(sourceList.begin(), sourceList.end(),
match)) {
102 auto path = std::filesystem::path(
dst +
"" + e);
103 std::filesystem::remove(
path);
108 for (
auto& e : sourceList) {
109 auto match = e.substr(0, e.size() - ext1.size()) + ext2;
110 if (destinationList.end() == std::find(destinationList.begin(), destinationList.end(),
match)) {
127 struct sigaction sigIntHandler {
130 sigemptyset(&sigIntHandler.sa_mask);
131 sigIntHandler.sa_flags = 0;
133 sigaction(SIGINT, &sigIntHandler,
nullptr);
134 LOGF(info,
"Welcome in O2 event conversion tool");
140 if (argc == 4 and std::string(argv[1]) == std::string(
"-l")) {
144 if (argc == 4 and std::string(argv[1]) == std::string(
"-f")) {
148 if (argc == 4 and std::string(argv[1]) == std::string(
"-c")) {
150 std::this_thread::sleep_for(2000ms);
155 LOGF(error,
"two filename required, second should point to not existent file");