| Directory: | ./ |
|---|---|
| File: | src/iostream.cpp |
| Date: | 2022-06-29 13:58:11 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 5 | 13 | 38.5% |
| Branches: | 5 | 30 | 16.7% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * @file iostream.cpp | ||
| 3 | * @author Maximilien Naveau (maximilien.naveau@gmail.com) | ||
| 4 | * license License BSD-3-Clause | ||
| 5 | * @copyright Copyright (c) 2019, New York University and Max Planck | ||
| 6 | * Gesellschaft. | ||
| 7 | * @date 2019-05-22 | ||
| 8 | * | ||
| 9 | * @brief implement some cross platform utilities to create folder or detect the | ||
| 10 | * home folder, etc. | ||
| 11 | */ | ||
| 12 | #include <sstream> | ||
| 13 | |||
| 14 | #include "real_time_tools/iostream.hpp" | ||
| 15 | #include "real_time_tools/timer.hpp" | ||
| 16 | |||
| 17 | namespace real_time_tools | ||
| 18 | { | ||
| 19 | ✗ | std::string get_log_dir(std::string app_name) | |
| 20 | { | ||
| 21 | ✗ | std::string log_dir; | |
| 22 | |||
| 23 | ✗ | std::string home_dir = real_time_tools::get_home_dir(); | |
| 24 | ✗ | std::string date_dir = real_time_tools::Timer::get_current_date_str() + "/"; | |
| 25 | |||
| 26 | ✗ | log_dir = home_dir + app_name + "/" + date_dir; | |
| 27 | |||
| 28 | ✗ | real_time_tools::create_directory(home_dir + app_name); | |
| 29 | ✗ | real_time_tools::create_directory(log_dir); | |
| 30 | |||
| 31 | ✗ | return log_dir; | |
| 32 | } | ||
| 33 | |||
| 34 | 1 | bool create_directory(std::string path) | |
| 35 | { | ||
| 36 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | return boost::filesystem::create_directory(path); |
| 37 | } | ||
| 38 | |||
| 39 | 1 | std::string get_home_dir() | |
| 40 | { | ||
| 41 |
2/4✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
1 | return std::string(getenv("HOME")) + "/"; |
| 42 | } | ||
| 43 | |||
| 44 |
2/4✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
|
42 | } // namespace real_time_tools |
| 45 |