Skip to content

Commit f5e486e

Browse files
committed
Fix test-fs-error-messages.js
1 parent 7272dbd commit f5e486e

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

deps/uv/src/unix/fs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
305305
DIR* dir = opendir(path);
306306
if (!dir) {
307307
uv_err_new(loop, errno);
308+
req->result = -1;
308309
return -1;
309310
}
310311

@@ -333,6 +334,7 @@ int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
333334
r = closedir(dir);
334335
if (r) {
335336
uv_err_new(loop, errno);
337+
req->result = -1;
336338
return -1;
337339
}
338340
}

src/node_file.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,14 @@ static void After(uv_fs_t *req) {
8686
if (req->result == -1) {
8787
// If the request doesn't have a path parameter set.
8888

89-
// XXX if (!req->arg0) {
89+
if (!req->path) {
9090
argv[0] = ErrnoException(req->errorno);
91-
// XXX } else {
92-
// XXX argv[0] = ErrnoException(req->errorno, NULL, "", static_cast<const char*>(req->arg0));
93-
// XXX}
91+
} else {
92+
argv[0] = ErrnoException(req->errorno,
93+
NULL,
94+
"",
95+
static_cast<const char*>(req->path));
96+
}
9497
} else {
9598
// error value is empty or null for non-error.
9699
argv[0] = Local<Value>::New(Null());
@@ -214,7 +217,7 @@ struct fs_req_wrap {
214217
#define SYNC_CALL(func, path, ...) \
215218
fs_req_wrap req_wrap; \
216219
uv_fs_##func(uv_default_loop(), &req_wrap.req, __VA_ARGS__, NULL); \
217-
if (req_wrap.req.result == -1) { \
220+
if (req_wrap.req.result < 0) { \
218221
return ThrowException( \
219222
ErrnoException(req_wrap.req.errorno, #func, "", path)); \
220223
}
@@ -334,7 +337,7 @@ static Handle<Value> Stat(const Arguments& args) {
334337
if (args[1]->IsFunction()) {
335338
ASYNC_CALL(stat, args[1], *path)
336339
} else {
337-
SYNC_CALL(stat, 0, *path)
340+
SYNC_CALL(stat, *path, *path)
338341
return scope.Close(BuildStatsObject((NODE_STAT_STRUCT*)SYNC_REQ.ptr));
339342
}
340343
}

0 commit comments

Comments
 (0)