Skip to content

Remove only old log files#555

Merged
Grantim merged 4 commits intomasterfrom
Remove_only_old_log_files
Sep 29, 2022
Merged

Remove only old log files#555
Grantim merged 4 commits intomasterfrom
Remove_only_old_log_files

Conversation

@Grantim
Copy link
Contributor

@Grantim Grantim commented Sep 29, 2022

No description provided.

@Grantim Grantim requested a review from Fedr September 29, 2022 09:47
auto now = std::chrono::system_clock::now();
std::time_t nowSinceEpoch = std::chrono::system_clock::to_time_t( now );

for ( auto entry : std::filesystem::directory_iterator( dir, ec ) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not safe way to iterate, since operator ++ can throw

if ( ss.fail() )
continue; // cannot parse time
std::time_t fileDateSinceEpoch = std::mktime( &tm );
auto diffHours = nowSinceEpoch - fileDateSinceEpoch / 3600;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably (nowSinceEpoch - fileDateSinceEpoch) / 3600;?

@Grantim Grantim merged commit a607fb2 into master Sep 29, 2022
@Grantim Grantim deleted the Remove_only_old_log_files branch September 29, 2022 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants