summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2017-12-28 14:51:05 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-01-17 06:20:00 +0800
commitda7804f25914fe5a460db01c2e234dafc3649dfc (patch)
treef1c406ac7f0fc8487ffd00a8d7363d8b65f3373c /src
parent57d7638af3dab44129d6008f356b9b1598d72d51 (diff)
downloadnode-new-da7804f25914fe5a460db01c2e234dafc3649dfc.tar.gz
fs: throw fs.lstat{Sync} errors in JS
PR-URL: https://github.com/nodejs/node/pull/17914 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_file.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index 7054338c07..9ca94550d2 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -563,6 +563,7 @@ static void Stat(const FunctionCallbackInfo<Value>& args) {
static void LStat(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
+ Local<Context> context = env->context();
CHECK_GE(args.Length(), 1);
@@ -573,10 +574,14 @@ static void LStat(const FunctionCallbackInfo<Value>& args) {
CHECK_EQ(args.Length(), 2);
AsyncCall(env, args, "lstat", UTF8, AfterStat,
uv_fs_lstat, *path);
- } else { // lstat(path)
- SYNC_CALL(lstat, *path, *path)
- FillStatsArray(env->fs_stats_field_array(),
- static_cast<const uv_stat_t*>(SYNC_REQ.ptr));
+ } else { // lstat(path, undefined, ctx)
+ CHECK_EQ(args.Length(), 3);
+ fs_req_wrap req_wrap;
+ int err = SyncCall(env, args[2], &req_wrap, "lstat", uv_fs_lstat, *path);
+ if (err == 0) {
+ FillStatsArray(env->fs_stats_field_array(),
+ static_cast<const uv_stat_t*>(req_wrap.req.ptr));
+ }
}
}