diff --git a/cudir.cc b/cudir.cc index 57317b4..1a74dcc 100644 --- a/cudir.cc +++ b/cudir.cc @@ -38,7 +38,19 @@ getEntries( const std::filesystem::path where ) const auto time_since_midnight= day - time; const std::chrono::hh_mm_ss time_of_day{ std::chrono::floor< std::chrono::minutes >( time_since_midnight ) }; - entries.push_back( Entry{ entry.path().filename(), drwx( entry ), entry.is_directory() ? 0 : file_size( entry.path() ), + auto get_file_size= []( auto &path ) + { + try + { + return file_size( path ); + } + catch( const std::filesystem::filesystem_error & ) + { + return 0ul; + } + }; + + entries.push_back( Entry{ entry.path().filename(), drwx( entry ), entry.is_directory() ? 0 : get_file_size( entry.path() ), static_cast< int >( ymd.year() ), static_cast< unsigned >( ymd.month() ), static_cast< unsigned >( ymd.day() ), time_of_day.hours().count(), time_of_day.minutes().count(), entry.is_directory(), is_exe( entry ) } );