Skip to content

Commit

Permalink
fixing bug in etage constructor
Browse files Browse the repository at this point in the history
struct stat was used even when stat() system call returned an error
  • Loading branch information
Edrusb committed Dec 9, 2023
1 parent 25adea6 commit f8b2b05
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/libdar/etage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,16 @@ namespace libdar
{
struct stat info;
int val = stat(ret->d_name, &info);
bool isdir = true;

if(val != 0)
{
ui.message(tools_printf(gettext("Cannot determine whether %s is a directory or not, assuming it is not a directory"), ret->d_name));
// isdir is set to true; at least it gives the user the possibility to try open this as if it was a directory, eventually the system will report an error
}
else
isdir = (info.st_mode & S_IFMT) == S_IFDIR || (info.st_mode & S_IFMT) == S_IFLNK;

bool isdir = (info.st_mode & S_IFMT) == S_IFDIR || (info.st_mode & S_IFMT) == S_IFLNK;
fichier.push_back(cell(string(ret->d_name), isdir));
}
else
Expand Down

0 comments on commit f8b2b05

Please sign in to comment.