24#include <forward_list>
26#include <fairlogger/Logger.h>
35 for (
const auto&
entry : std::filesystem::directory_iterator(
path)) {
36 if (std::find(ext.begin(), ext.end(),
entry.path().extension()) != ext.end()) {
40 }
catch (std::filesystem::filesystem_error
const& ex) {
41 LOGF(
error,
"filesystem problem during DirectoryLoader::load: %s", ex.what());
45 [
marker](
const std::string&
a,
const std::string&
b) {
46 return a.substr(a.find_first_of(marker) + 1) < b.substr(b.find_first_of(marker) + 1);
55 std::map<std::string, std::string> fullPath;
58 for (
const auto&
entry : std::filesystem::directory_iterator(
path)) {
59 if (std::find(ext.begin(), ext.end(),
entry.path().extension()) != ext.end()) {
61 fullPath[
entry.path().filename()] =
entry.path();
64 }
catch (std::filesystem::filesystem_error
const& ex) {
65 LOGF(
error,
"filesystem problem during DirectoryLoader::canCreateNextFile: %s", ex.what());
72 [
marker](
const std::string&
a,
const std::string&
b) {
73 return a.substr(a.find_first_of(marker) + 1) > b.substr(b.find_first_of(marker) + 1);
77 unsigned long accumulatedSize = 0L;
78 const std::regex delimiter{
"_"};
80 std::vector<std::string>
c(std::sregex_token_iterator(
file.begin(),
file.end(), delimiter, -1), {});
81 if (std::stoll(
c[1]) < millisec) {
85 accumulatedSize += filesystem::file_size(fullPath[
file]);
86 }
catch (std::filesystem::filesystem_error
const& ex) {
87 LOGF(info,
"problem scanning folder: %s", ex.what());
89 if (accumulatedSize > capacityAllowed) {
101 for (
const auto&
entry : std::filesystem::directory_iterator(
path)) {
102 if (std::find(ext.begin(), ext.end(),
entry.path().extension()) != ext.end()) {
107 }
catch (std::filesystem::filesystem_error
const& ex) {
108 LOGF(
error,
"filesystem problem during DirectoryLoader::load: %s", ex.what());
112 [
marker](
const std::string&
a,
const std::string&
b) {
113 return a.substr(a.find_first_of(marker) + 1) < b.substr(b.find_first_of(marker) + 1);
121 std::vector<std::string> folders;
124 folders.push_back(
location.substr(0,
pos) +
"_PHYSICS");
125 folders.push_back(
location.substr(0,
pos) +
"_COSMICS");
126 folders.push_back(
location.substr(0,
pos) +
"_SYNTHETIC");
135 if (filesInFolder == -1) {
138 const auto items = files.size() - std::min(files.size(), filesInFolder);
139 for (
int i = 0;
i < items;
i++) {
140 std::remove((
path +
"/" + files[
i]).c_str());
144template <
typename TP>
147 using namespace std::chrono;
148 auto sctp = time_point_cast<system_clock::duration>(tp - TP::clock::now() + system_clock::now());
149 return system_clock::to_time_t(sctp);
152int DirectoryLoader::getNumberOfFiles(
const std::string&
path, std::vector<std::string>& ext)
156 for (
const auto&
entry :
std::filesystem::directory_iterator(
path)) {
157 if (std::find(ext.begin(), ext.end(),
entry.path().extension()) != ext.end()) {
161 }
catch (std::filesystem::filesystem_error
const& ex) {
162 LOGF(
error,
"filesystem problem during DirectoryLoader::getNumberOfFiles: %s", ex.what());
166std::string DirectoryLoader::getLatestFile(
const std::string&
path, std::vector<std::string>& ext)
168 std::string oldest_file_name =
"";
169 std::time_t oldest_file_time = LONG_MAX;
170 for (
const auto&
entry :
std::filesystem::directory_iterator(
path)) {
171 if (std::find(ext.begin(), ext.end(),
entry.path().extension()) != ext.end()) {
172 const auto file_time =
entry.last_write_time();
173 if (
const std::time_t
tt =
to_time_t(file_time);
tt < oldest_file_time) {
174 oldest_file_time =
tt;
175 oldest_file_name =
entry.path().filename().string();
179 return oldest_file_name;
185 while (getNumberOfFiles(
path, ext) > remaining) {
186 LOGF(info,
"removing oldest file in folder: %s : %s",
path, getLatestFile(
path, ext));
187 filesystem::remove(
path +
"/" + getLatestFile(
path, ext));
189 }
catch (std::filesystem::filesystem_error
const& ex) {
190 LOGF(
error,
"filesystem problem during DirectoryLoader::removeOldestFiles: %s", ex.what());
std::time_t to_time_t(TP tp)
Loading content of the Folder and returning sorted.
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h configStandalone Internal display display_internal Number of updates the Qt GUI may send ahead of the last one the display has before it waits for the display Opacity of the console background Number of console lines the history is shortened to this when it reaches twice the size Time in seconds an info message fades out after setInfoTime h OpenGL display display Font size Do not use Freetype for font Renderer for event Frontend to use for event ROOT macros used as track filter Console script file
char error[CURL_ERROR_SIZE]
static void removeOldestFiles(const std::string &path, std::vector< std::string > &ext, int remaining)
static bool canCreateNextFile(const std::vector< std::string > &paths, const std::string &marker, const std::vector< std::string > &ext, long long millisec, long capacityAllowed)
static void reduceNumberOfFiles(const std::string &path, const std::deque< std::string > &files, std::size_t filesInFolder)
static std::vector< std::string > allFolders(const std::string &location)
static std::deque< std::string > load(const std::string &path, const std::string &marker, const std::vector< std::string > &ext)
GLboolean GLboolean GLboolean b
GLsizei const GLuint * paths
GLsizei const GLchar *const * path
GLboolean GLboolean GLboolean GLboolean a
static DeploymentMode deploymentMode()