From c0793664f9319ad7f2f99fdb0d7d76c6cd012ae1 Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 31 Dec 2018 13:58:23 +0100 Subject: [PATCH] A bit of refactoring --- src/main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d4e0e54..3c53ea0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,6 +40,7 @@ using std::cerr; using std::endl; using std::chrono::system_clock; using std::chrono::hours; +using std::chrono::duration_cast; string compiler = "g++"; fs::path cache_dir; @@ -101,15 +102,13 @@ void read_settings() void cleanup() { - system_clock::time_point now = system_clock::now(); for (const fs::directory_entry &entry : fs::recursive_directory_iterator(cache_dir)) { if (fs::is_regular_file(entry)) { - auto diff = now - fs::last_write_time(entry); - if (std::chrono::duration_cast(diff).count() - > clean_after_hours) + auto diff = system_clock::now() - fs::last_write_time(entry); + if (duration_cast(diff).count() > clean_after_hours) { fs::path current_path = entry.path(); std::error_code e;