src: use `S_ISDIR` to check if the file is a directory · nodejs/node@fca38b2 · GitHub
Skip to content

Commit fca38b2

Browse files
theanarkhtargos
authored andcommitted
src: use S_ISDIR to check if the file is a directory
PR-URL: #52164 Fixes: #52159 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 1f7c2a9 commit fca38b2

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/node_file.cc

Lines changed: 2 additions & 2 deletions

src/permission/fs_permission.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ std::string WildcardIfDir(const std::string& res) noexcept {
2121
int rc = uv_fs_stat(nullptr, &req, res.c_str(), nullptr);
2222
if (rc == 0) {
2323
const uv_stat_t* const s = static_cast<const uv_stat_t*>(req.ptr);
24-
if (s->st_mode & S_IFDIR) {
24+
if ((s->st_mode & S_IFMT) == S_IFDIR) {
2525
// add wildcard when directory
2626
if (res.back() == node::kPathSeparator) {
2727
return res + "*";
Lines changed: 14 additions & 0 deletions

0 commit comments

Comments
 (0)