diff --git a/base/src/directory_ex.cpp b/base/src/directory_ex.cpp index 9e79b9ba9b0e6c6bb381ac3e683dfc3eeaf82c10..650a4e241ec346b2242c79703d353a1f832e0c04 100644 --- a/base/src/directory_ex.cpp +++ b/base/src/directory_ex.cpp @@ -204,6 +204,8 @@ bool ForceRemoveDirectory(const string& path) return false; } + struct stat unused; + while (true) { struct dirent *ptr = readdir(dir); if (ptr == nullptr) { @@ -218,7 +220,7 @@ bool ForceRemoveDirectory(const string& path) if (ptr->d_type == DT_DIR) { ret = ForceRemoveDirectory(subPath); } else { - if (faccessat(AT_FDCWD, subPath.c_str(), F_OK, AT_SYMLINK_NOFOLLOW) == 0) { + if (lstat(subPath.c_str(), &unused) == 0) { if (remove(subPath.c_str()) != 0) { closedir(dir); return false; @@ -229,13 +231,13 @@ bool ForceRemoveDirectory(const string& path) closedir(dir); string currentPath = ExcludeTrailingPathDelimiter(path); - if (faccessat(AT_FDCWD, currentPath.c_str(), F_OK, AT_SYMLINK_NOFOLLOW) == 0) { + if (lstat(currentPath.c_str(), &unused) == 0) { if (remove(currentPath.c_str()) != 0) { return false; } } - return ret && (faccessat(AT_FDCWD, path.c_str(), F_OK, AT_SYMLINK_NOFOLLOW) != 0); + return ret && (lstat(path.c_str(), &unused) != 0); } bool RemoveFile(const string& fileName)