Fixes IFTODT error while compiling from an android device

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
This commit is contained in:
ThePotato 2021-11-11 21:52:59 +00:00
parent a6a2b86c9b
commit 1492cb9116
No known key found for this signature in database
GPG key ID: C2EDDD5A87A67BC6

View file

@ -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)
@ -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
}