Skip to content

Commit fb97e85

Browse files
committed
Expect a zero return status from stat() on success rather than non-zero
1 parent a36712e commit fb97e85

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/fs.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace blt {
1616
namespace fs {
1717

1818
using std::string;
19+
using std::to_string;
1920
using std::stringstream;
2021
using std::vector;
2122
using std::ifstream;
@@ -29,7 +30,6 @@ namespace blt {
2930
vector<string> result;
3031

3132
DIR* directory = opendir(path.c_str());
32-
log::log("open dir: " + path, log::LOG_INFO);
3333

3434
if (directory)
3535
{
@@ -80,7 +80,7 @@ namespace blt {
8080
{
8181
struct stat fileInfo;
8282

83-
if (stat(path.c_str(), &fileInfo))
83+
if (stat(path.c_str(), &fileInfo) == 0)
8484
{
8585
return S_ISDIR(fileInfo.st_mode);
8686
}
@@ -121,6 +121,7 @@ namespace blt {
121121
parent = path.substr(0, finalSlash);
122122
}
123123

124+
124125
if (path_is_dir(parent))
125126
{
126127
return true;

0 commit comments

Comments
 (0)