GeezerVison is showing github.com — src: use `S_ISDIR` to check if the file is a directory · nodejs/node@fca38b2
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_file.cc +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1054,7 +1054,7 @@ static void InternalModuleStat(const FunctionCallbackInfo<Value>& args) { |
1054 | 1054 | int rc = uv_fs_stat(env->event_loop(), &req, *path, nullptr); |
1055 | 1055 | if (rc == 0) { |
1056 | 1056 | const uv_stat_t* const s = static_cast<const uv_stat_t*>(req.ptr); |
1057 | | - rc = !!(s->st_mode & S_IFDIR); |
| 1057 | + rc = S_ISDIR(s->st_mode); |
1058 | 1058 | } |
1059 | 1059 | uv_fs_req_cleanup(&req); |
1060 | 1060 |
|
@@ -2982,7 +2982,7 @@ BindingData::FilePathIsFileReturnType BindingData::FilePathIsFile( |
2982 | 2982 |
|
2983 | 2983 | if (rc == 0) { |
2984 | 2984 | const uv_stat_t* const s = static_cast<const uv_stat_t*>(req.ptr); |
2985 | | - rc = !!(s->st_mode & S_IFDIR); |
| 2985 | + rc = S_ISDIR(s->st_mode); |
2986 | 2986 | } |
2987 | 2987 |
|
2988 | 2988 | uv_fs_req_cleanup(&req); |
|
Collapse file
Copy file name to clipboardExpand all lines: src/permission/fs_permission.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,7 +21,7 @@ std::string WildcardIfDir(const std::string& res) noexcept { |
21 | 21 | int rc = uv_fs_stat(nullptr, &req, res.c_str(), nullptr); |
22 | 22 | if (rc == 0) { |
23 | 23 | 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) { |
25 | 25 | // add wildcard when directory |
26 | 26 | if (res.back() == node::kPathSeparator) { |
27 | 27 | return res + "*"; |
|
Collapse file
Copy file name to clipboard +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | +const fs = require('fs'); |
| 4 | +const net = require('net'); |
| 5 | + |
| 6 | +const tmpdir = require('../common/tmpdir'); |
| 7 | +tmpdir.refresh(); |
| 8 | + |
| 9 | +const server = net.createServer().listen(common.PIPE, common.mustCall(() => { |
| 10 | + // The process should not crash |
| 11 | + // See https://github.com/nodejs/node/issues/52159 |
| 12 | + fs.readdirSync(tmpdir.path, { recursive: true }); |
| 13 | + server.close(); |
| 14 | +})); |