Skip to content

Commit

Permalink
Fixes IFTODT error while compiling from an android device (#199)
Browse files Browse the repository at this point in the history
Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
  • Loading branch information
ThePotato97 and zeux committed Nov 12, 2021
1 parent b7d26b3 commit d11e827
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions CLI/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ static bool traverseDirectoryRec(const std::string& path, const std::function<vo
joinPaths(buf, path.c_str(), data.d_name);

int type = data.d_type;
int mode = -1;

// we need to stat DT_UNKNOWN to be able to tell the type
if (type == DT_UNKNOWN)
Expand All @@ -153,18 +154,18 @@ static bool traverseDirectoryRec(const std::string& path, const std::function<vo
lstat(buf.c_str(), &st);
#endif

type = IFTODT(st.st_mode);
mode = st.st_mode;
}

if (type == DT_DIR)
if (type == DT_DIR || mode == S_IFDIR)
{
traverseDirectoryRec(buf, callback);
}
else if (type == DT_REG)
else if (type == DT_REG || mode == S_IFREG)
{
callback(buf);
}
else if (type == DT_LNK)
else if (type == DT_LNK || mode == S_IFLNK)
{
// Skip symbolic links to avoid handling cycles
}
Expand Down

0 comments on commit d11e827

Please sign in to comment.