Fix crash/exception of file size absence.
Again, due to broken symlink.
This commit is contained in:
@@ -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 ) } );
|
||||
|
||||
Reference in New Issue
Block a user