Skip to content

Commit

Permalink
Simplify stat_path function by consolidating symlink handling into a …
Browse files Browse the repository at this point in the history
…single return statement
  • Loading branch information
emcrisostomo committed Jan 1, 2025
1 parent 07cb12f commit d65e350
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions libfswatch/src/libfswatch/c++/path_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,7 @@ namespace fsw

bool stat_path(const std::string& path, struct stat& fd_stat, bool follow_symlink)
{
if (follow_symlink)
{
if (lstat(path.c_str(), &fd_stat) == 0)
return true;
}
else
{
if (stat(path.c_str(), &fd_stat) == 0)
return true;
}

fsw_logf_perror(_("Cannot stat %s"), path.c_str());
return false;
return follow_symlink ? lstat_path(path, fd_stat) : stat_path(path, fd_stat);
}

bool stat_path(const std::string& path, struct stat& fd_stat)
Expand Down

0 comments on commit d65e350

Please sign in to comment.