We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
S_ISDIR
1 parent 1f7c2a9 commit fca38b2Copy full SHA for fca38b2
3 files changed
src/node_file.cc
@@ -1054,7 +1054,7 @@ static void InternalModuleStat(const FunctionCallbackInfo<Value>& args) {
1054
int rc = uv_fs_stat(env->event_loop(), &req, *path, nullptr);
1055
if (rc == 0) {
1056
const uv_stat_t* const s = static_cast<const uv_stat_t*>(req.ptr);
1057
- rc = !!(s->st_mode & S_IFDIR);
+ rc = S_ISDIR(s->st_mode);
1058
}
1059
uv_fs_req_cleanup(&req);
1060
@@ -2982,7 +2982,7 @@ BindingData::FilePathIsFileReturnType BindingData::FilePathIsFile(
2982
2983
2984
2985
2986
2987
2988
src/permission/fs_permission.cc
@@ -21,7 +21,7 @@ std::string WildcardIfDir(const std::string& res) noexcept {
21
int rc = uv_fs_stat(nullptr, &req, res.c_str(), nullptr);
22
23
24
- if (s->st_mode & S_IFDIR) {
+ if ((s->st_mode & S_IFMT) == S_IFDIR) {
25
// add wildcard when directory
26
if (res.back() == node::kPathSeparator) {
27
return res + "*";
test/parallel/test-fs-readdir-recursive.js
@@ -0,0 +1,14 @@
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
+}));
0 commit comments