A bit of refactoring
This commit is contained in:
parent
ed154feec5
commit
c0793664f9
|
@ -40,6 +40,7 @@ using std::cerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::chrono::system_clock;
|
using std::chrono::system_clock;
|
||||||
using std::chrono::hours;
|
using std::chrono::hours;
|
||||||
|
using std::chrono::duration_cast;
|
||||||
|
|
||||||
string compiler = "g++";
|
string compiler = "g++";
|
||||||
fs::path cache_dir;
|
fs::path cache_dir;
|
||||||
|
@ -101,15 +102,13 @@ void read_settings()
|
||||||
|
|
||||||
void cleanup()
|
void cleanup()
|
||||||
{
|
{
|
||||||
system_clock::time_point now = system_clock::now();
|
|
||||||
for (const fs::directory_entry &entry
|
for (const fs::directory_entry &entry
|
||||||
: fs::recursive_directory_iterator(cache_dir))
|
: fs::recursive_directory_iterator(cache_dir))
|
||||||
{
|
{
|
||||||
if (fs::is_regular_file(entry))
|
if (fs::is_regular_file(entry))
|
||||||
{
|
{
|
||||||
auto diff = now - fs::last_write_time(entry);
|
auto diff = system_clock::now() - fs::last_write_time(entry);
|
||||||
if (std::chrono::duration_cast<hours>(diff).count()
|
if (duration_cast<hours>(diff).count() > clean_after_hours)
|
||||||
> clean_after_hours)
|
|
||||||
{
|
{
|
||||||
fs::path current_path = entry.path();
|
fs::path current_path = entry.path();
|
||||||
std::error_code e;
|
std::error_code e;
|
||||||
|
|
Reference in New Issue