Handle error returns from lstat.
This commit is contained in:
parent
9df2cfb328
commit
1bdcb33f75
|
@ -865,8 +865,8 @@ long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec )
|
|||
std::string entry_path = dir_path + '/' + dir_entry->d_name;
|
||||
struct stat entry_stat;
|
||||
|
||||
wxCRT_Lstat( entry_path.c_str(), &entry_stat );
|
||||
|
||||
if( wxCRT_Lstat( entry_path.c_str(), &entry_stat ) == 0 )
|
||||
{
|
||||
// Timestamp the source file, not the symlink
|
||||
if( S_ISLNK( entry_stat.st_mode ) ) // wxFILE_EXISTS_SYMLINK
|
||||
{
|
||||
|
@ -875,16 +875,31 @@ long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec )
|
|||
|
||||
if( pathLen > 0 )
|
||||
{
|
||||
struct stat linked_stat;
|
||||
buffer[ pathLen ] = '\0';
|
||||
entry_path = dir_path + buffer;
|
||||
|
||||
wxCRT_Lstat( entry_path.c_str(), &entry_stat );
|
||||
if( wxCRT_Lstat( entry_path.c_str(), &linked_stat ) == 0 )
|
||||
{
|
||||
entry_stat = linked_stat;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we couldn't lstat the linked file we'll have to just use
|
||||
// the symbolic link info
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( S_ISREG( entry_stat.st_mode ) ) // wxFileExists()
|
||||
timestamp += entry_stat.st_mtime * 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we couldn't lstat the file itself all we can do is use the name
|
||||
timestamp += (signed) std::hash<std::string>{}( std::string( dir_entry->d_name ) );
|
||||
}
|
||||
}
|
||||
|
||||
closedir( dir );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue