Fix crash/exception of file size absence.

Again, due to broken symlink.
This commit is contained in:
2026-10-31 18:12:36 -04:00
parent 3c190cbb17
commit 05c2885d18
+13 -1
View File
@@ -38,7 +38,19 @@ getEntries( const std::filesystem::path where )
const auto time_since_midnight= day - time; 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 ) }; 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() ), 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(), time_of_day.hours().count(), time_of_day.minutes().count(),
entry.is_directory(), is_exe( entry ) } ); entry.is_directory(), is_exe( entry ) } );