mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
src: fixup more ToLocalChecked uses in node_file
PR-URL: https://github.com/nodejs/node/pull/56484 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
1 parent
5aa436f5a1
commit
04f623b283
1 file changed
+36
-34
+36
-34
@@ -1406,16 +1406,15 @@ static void ReadLink(const FunctionCallbackInfo<Value>& args) {
|
||||
const char* link_path = static_cast<const char*>(req_wrap_sync.req.ptr);
|
||||
|
||||
Local<Value> error;
|
||||
MaybeLocal<Value> rc = StringBytes::Encode(isolate,
|
||||
link_path,
|
||||
encoding,
|
||||
&error);
|
||||
if (rc.IsEmpty()) {
|
||||
Local<Value> ret;
|
||||
if (!StringBytes::Encode(isolate, link_path, encoding, &error)
|
||||
.ToLocal(&ret)) {
|
||||
DCHECK(!error.IsEmpty());
|
||||
env->isolate()->ThrowException(error);
|
||||
return;
|
||||
}
|
||||
|
||||
args.GetReturnValue().Set(rc.ToLocalChecked());
|
||||
args.GetReturnValue().Set(ret);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1817,15 +1816,16 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
|
||||
}
|
||||
if (!req_wrap_sync.continuation_data()->first_path().empty()) {
|
||||
Local<Value> error;
|
||||
Local<Value> ret;
|
||||
std::string first_path(req_wrap_sync.continuation_data()->first_path());
|
||||
MaybeLocal<Value> path = StringBytes::Encode(env->isolate(),
|
||||
first_path.c_str(),
|
||||
UTF8, &error);
|
||||
if (path.IsEmpty()) {
|
||||
if (!StringBytes::Encode(
|
||||
env->isolate(), first_path.c_str(), UTF8, &error)
|
||||
.ToLocal(&ret)) {
|
||||
DCHECK(!error.IsEmpty());
|
||||
env->isolate()->ThrowException(error);
|
||||
return;
|
||||
}
|
||||
args.GetReturnValue().Set(path.ToLocalChecked());
|
||||
args.GetReturnValue().Set(ret);
|
||||
}
|
||||
} else {
|
||||
SyncCallAndThrowOnError(env, &req_wrap_sync, uv_fs_mkdir, *path, mode);
|
||||
@@ -1866,16 +1866,15 @@ static void RealPath(const FunctionCallbackInfo<Value>& args) {
|
||||
const char* link_path = static_cast<const char*>(req_wrap_sync.req.ptr);
|
||||
|
||||
Local<Value> error;
|
||||
MaybeLocal<Value> rc = StringBytes::Encode(isolate,
|
||||
link_path,
|
||||
encoding,
|
||||
&error);
|
||||
if (rc.IsEmpty()) {
|
||||
Local<Value> ret;
|
||||
if (!StringBytes::Encode(isolate, link_path, encoding, &error)
|
||||
.ToLocal(&ret)) {
|
||||
DCHECK(!error.IsEmpty());
|
||||
env->isolate()->ThrowException(error);
|
||||
return;
|
||||
}
|
||||
|
||||
args.GetReturnValue().Set(rc.ToLocalChecked());
|
||||
args.GetReturnValue().Set(ret);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1962,17 +1961,15 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
|
||||
}
|
||||
|
||||
Local<Value> error;
|
||||
MaybeLocal<Value> filename = StringBytes::Encode(isolate,
|
||||
ent.name,
|
||||
encoding,
|
||||
&error);
|
||||
|
||||
if (filename.IsEmpty()) {
|
||||
Local<Value> fn;
|
||||
if (!StringBytes::Encode(isolate, ent.name, encoding, &error)
|
||||
.ToLocal(&fn)) {
|
||||
DCHECK(!error.IsEmpty());
|
||||
isolate->ThrowException(error);
|
||||
return;
|
||||
}
|
||||
|
||||
name_v.push_back(filename.ToLocalChecked());
|
||||
name_v.push_back(fn);
|
||||
|
||||
if (with_types) {
|
||||
type_v.emplace_back(Integer::New(isolate, ent.type));
|
||||
@@ -2993,13 +2990,14 @@ static void Mkdtemp(const FunctionCallbackInfo<Value>& args) {
|
||||
return;
|
||||
}
|
||||
Local<Value> error;
|
||||
MaybeLocal<Value> rc =
|
||||
StringBytes::Encode(isolate, req_wrap_sync.req.path, encoding, &error);
|
||||
if (rc.IsEmpty()) {
|
||||
Local<Value> ret;
|
||||
if (!StringBytes::Encode(isolate, req_wrap_sync.req.path, encoding, &error)
|
||||
.ToLocal(&ret)) {
|
||||
DCHECK(!error.IsEmpty());
|
||||
env->isolate()->ThrowException(error);
|
||||
return;
|
||||
}
|
||||
args.GetReturnValue().Set(rc.ToLocalChecked());
|
||||
args.GetReturnValue().Set(ret);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3311,9 +3309,11 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
|
||||
for (int i = 0; i < legacy_main_extensions_with_main_end; i++) {
|
||||
file_path = *initial_file_path + std::string(legacy_main_extensions[i]);
|
||||
// TODO(anonrig): Remove this when ToNamespacedPath supports std::string
|
||||
Local<Value> local_file_path =
|
||||
Buffer::Copy(env->isolate(), file_path.c_str(), file_path.size())
|
||||
.ToLocalChecked();
|
||||
Local<Value> local_file_path;
|
||||
if (!Buffer::Copy(env->isolate(), file_path.c_str(), file_path.size())
|
||||
.ToLocal(&local_file_path)) {
|
||||
return;
|
||||
}
|
||||
BufferValue buff_file_path(isolate, local_file_path);
|
||||
ToNamespacedPath(env, &buff_file_path);
|
||||
|
||||
@@ -3346,9 +3346,11 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
|
||||
i++) {
|
||||
file_path = *initial_file_path + std::string(legacy_main_extensions[i]);
|
||||
// TODO(anonrig): Remove this when ToNamespacedPath supports std::string
|
||||
Local<Value> local_file_path =
|
||||
Buffer::Copy(env->isolate(), file_path.c_str(), file_path.size())
|
||||
.ToLocalChecked();
|
||||
Local<Value> local_file_path;
|
||||
if (!Buffer::Copy(env->isolate(), file_path.c_str(), file_path.size())
|
||||
.ToLocal(&local_file_path)) {
|
||||
return;
|
||||
}
|
||||
BufferValue buff_file_path(isolate, local_file_path);
|
||||
ToNamespacedPath(env, &buff_file_path);
|
||||
|
||||
|
||||
Reference in new issue
Block a user