My Project 1.0
Holistic Fusion: A Generic Framework for Multimodal Sensor Fusion
Loading...
Searching...
No Matches
input_output.h
Go to the documentation of this file.
1/*
2Copyright 2024 by Julian Nubert, Robotic Systems Lab, ETH Zurich.
3All rights reserved.
4This file is released under the "BSD-3-Clause License".
5Please see the LICENSE file that has been included as part of this package.
6 */
7
8#ifndef GMSF_INPUT_OUTPUT_H
9#define GMSF_INPUT_OUTPUT_H
10
11// C++
12#include <filesystem>
13#include <iostream>
14#include <string>
15
16// Workspace
18
19namespace holistic_fusion {
20
21// Utility
22inline std::string getLatestSubdirectory(const std::string& directoryPath) {
23 std::filesystem::path latestDir;
24 std::filesystem::file_time_type latestTime = std::filesystem::file_time_type::min();
25
26 REGULAR_COUT << " Looking for latest directory in " << directoryPath << std::endl;
27
28 for (const auto& entry : std::filesystem::directory_iterator(directoryPath)) {
29 if (entry.is_directory()) {
30 const std::filesystem::file_time_type currentLastWriteTime = entry.last_write_time();
31 if (currentLastWriteTime > latestTime) {
32 latestTime = currentLastWriteTime;
33 latestDir = entry.path();
34 }
35 }
36 }
37
38 return latestDir.empty() ? "" : latestDir.filename().string();
39}
40
41} // namespace holistic_fusion
42
43#endif // GMSF_INPUT_OUTPUT_H
#define REGULAR_COUT
std::string getLatestSubdirectory(const std::string &directoryPath)