@@ -1406,16 +1406,15 @@ static void ReadLink(const FunctionCallbackInfo<Value>& args) {
14061406 const char * link_path = static_cast <const char *>(req_wrap_sync.req .ptr );
14071407
14081408 Local<Value> error;
1409- MaybeLocal<Value> rc = StringBytes::Encode (isolate,
1410- link_path,
1411- encoding,
1412- &error);
1413- if (rc.IsEmpty ()) {
1409+ Local<Value> ret;
1410+ if (!StringBytes::Encode (isolate, link_path, encoding, &error)
1411+ .ToLocal (&ret)) {
1412+ DCHECK (!error.IsEmpty ());
14141413 env->isolate ()->ThrowException (error);
14151414 return ;
14161415 }
14171416
1418- args.GetReturnValue ().Set (rc. ToLocalChecked () );
1417+ args.GetReturnValue ().Set (ret );
14191418 }
14201419}
14211420
@@ -1817,15 +1816,16 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
18171816 }
18181817 if (!req_wrap_sync.continuation_data ()->first_path ().empty ()) {
18191818 Local<Value> error;
1819+ Local<Value> ret;
18201820 std::string first_path (req_wrap_sync.continuation_data ()->first_path ());
1821- MaybeLocal<Value> path = StringBytes::Encode (env-> isolate (),
1822- first_path.c_str (),
1823- UTF8, &error);
1824- if (path .IsEmpty ()) {
1821+ if (! StringBytes::Encode (
1822+ env-> isolate (), first_path.c_str (), UTF8, &error)
1823+ . ToLocal (&ret)) {
1824+ DCHECK (!error .IsEmpty ());
18251825 env->isolate ()->ThrowException (error);
18261826 return ;
18271827 }
1828- args.GetReturnValue ().Set (path. ToLocalChecked () );
1828+ args.GetReturnValue ().Set (ret );
18291829 }
18301830 } else {
18311831 SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_mkdir, *path, mode);
@@ -1866,16 +1866,15 @@ static void RealPath(const FunctionCallbackInfo<Value>& args) {
18661866 const char * link_path = static_cast <const char *>(req_wrap_sync.req .ptr );
18671867
18681868 Local<Value> error;
1869- MaybeLocal<Value> rc = StringBytes::Encode (isolate,
1870- link_path,
1871- encoding,
1872- &error);
1873- if (rc.IsEmpty ()) {
1869+ Local<Value> ret;
1870+ if (!StringBytes::Encode (isolate, link_path, encoding, &error)
1871+ .ToLocal (&ret)) {
1872+ DCHECK (!error.IsEmpty ());
18741873 env->isolate ()->ThrowException (error);
18751874 return ;
18761875 }
18771876
1878- args.GetReturnValue ().Set (rc. ToLocalChecked () );
1877+ args.GetReturnValue ().Set (ret );
18791878 }
18801879}
18811880
@@ -1962,17 +1961,15 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
19621961 }
19631962
19641963 Local<Value> error;
1965- MaybeLocal<Value> filename = StringBytes::Encode (isolate,
1966- ent.name ,
1967- encoding,
1968- &error);
1969-
1970- if (filename.IsEmpty ()) {
1964+ Local<Value> fn;
1965+ if (!StringBytes::Encode (isolate, ent.name , encoding, &error)
1966+ .ToLocal (&fn)) {
1967+ DCHECK (!error.IsEmpty ());
19711968 isolate->ThrowException (error);
19721969 return ;
19731970 }
19741971
1975- name_v.push_back (filename. ToLocalChecked () );
1972+ name_v.push_back (fn );
19761973
19771974 if (with_types) {
19781975 type_v.emplace_back (Integer::New (isolate, ent.type ));
@@ -2993,13 +2990,14 @@ static void Mkdtemp(const FunctionCallbackInfo<Value>& args) {
29932990 return ;
29942991 }
29952992 Local<Value> error;
2996- MaybeLocal<Value> rc =
2997- StringBytes::Encode (isolate, req_wrap_sync.req .path , encoding, &error);
2998- if (rc.IsEmpty ()) {
2993+ Local<Value> ret;
2994+ if (!StringBytes::Encode (isolate, req_wrap_sync.req .path , encoding, &error)
2995+ .ToLocal (&ret)) {
2996+ DCHECK (!error.IsEmpty ());
29992997 env->isolate ()->ThrowException (error);
30002998 return ;
30012999 }
3002- args.GetReturnValue ().Set (rc. ToLocalChecked () );
3000+ args.GetReturnValue ().Set (ret );
30033001 }
30043002}
30053003
@@ -3311,9 +3309,11 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
33113309 for (int i = 0 ; i < legacy_main_extensions_with_main_end; i++) {
33123310 file_path = *initial_file_path + std::string (legacy_main_extensions[i]);
33133311 // TODO(anonrig): Remove this when ToNamespacedPath supports std::string
3314- Local<Value> local_file_path =
3315- Buffer::Copy (env->isolate (), file_path.c_str (), file_path.size ())
3316- .ToLocalChecked ();
3312+ Local<Value> local_file_path;
3313+ if (!Buffer::Copy (env->isolate (), file_path.c_str (), file_path.size ())
3314+ .ToLocal (&local_file_path)) {
3315+ return ;
3316+ }
33173317 BufferValue buff_file_path (isolate, local_file_path);
33183318 ToNamespacedPath (env, &buff_file_path);
33193319
@@ -3346,9 +3346,11 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
33463346 i++) {
33473347 file_path = *initial_file_path + std::string (legacy_main_extensions[i]);
33483348 // TODO(anonrig): Remove this when ToNamespacedPath supports std::string
3349- Local<Value> local_file_path =
3350- Buffer::Copy (env->isolate (), file_path.c_str (), file_path.size ())
3351- .ToLocalChecked ();
3349+ Local<Value> local_file_path;
3350+ if (!Buffer::Copy (env->isolate (), file_path.c_str (), file_path.size ())
3351+ .ToLocal (&local_file_path)) {
3352+ return ;
3353+ }
33523354 BufferValue buff_file_path (isolate, local_file_path);
33533355 ToNamespacedPath (env, &buff_file_path);
33543356
0 commit comments