@@ -64,8 +64,11 @@ using v8::HandleScope;
64
64
using v8::Int32;
65
65
using v8::Integer;
66
66
using v8::Isolate;
67
+ using v8::JustVoid;
67
68
using v8::Local;
69
+ using v8::Maybe;
68
70
using v8::MaybeLocal;
71
+ using v8::Nothing;
69
72
using v8::Number;
70
73
using v8::Object;
71
74
using v8::ObjectTemplate;
@@ -1949,9 +1952,9 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
1949
1952
}
1950
1953
}
1951
1954
1952
- static inline bool CheckOpenPermissions (Environment* env,
1953
- const BufferValue& path,
1954
- int flags) {
1955
+ static inline Maybe< void > CheckOpenPermissions (Environment* env,
1956
+ const BufferValue& path,
1957
+ int flags) {
1955
1958
// These flags capture the intention of the open() call.
1956
1959
const int rwflags = flags & (UV_FS_O_RDONLY | UV_FS_O_WRONLY | UV_FS_O_RDWR);
1957
1960
@@ -1965,13 +1968,19 @@ static inline bool CheckOpenPermissions(Environment* env,
1965
1968
auto pathView = path.ToStringView ();
1966
1969
if (rwflags != UV_FS_O_WRONLY) {
1967
1970
THROW_IF_INSUFFICIENT_PERMISSIONS (
1968
- env, permission::PermissionScope::kFileSystemRead , pathView, false );
1971
+ env,
1972
+ permission::PermissionScope::kFileSystemRead ,
1973
+ pathView,
1974
+ Nothing<void >());
1969
1975
}
1970
1976
if (rwflags != UV_FS_O_RDONLY || write_as_side_effect) {
1971
1977
THROW_IF_INSUFFICIENT_PERMISSIONS (
1972
- env, permission::PermissionScope::kFileSystemWrite , pathView, false );
1978
+ env,
1979
+ permission::PermissionScope::kFileSystemWrite ,
1980
+ pathView,
1981
+ Nothing<void >());
1973
1982
}
1974
- return true ;
1983
+ return JustVoid () ;
1975
1984
}
1976
1985
1977
1986
static void Open (const FunctionCallbackInfo<Value>& args) {
@@ -1989,7 +1998,7 @@ static void Open(const FunctionCallbackInfo<Value>& args) {
1989
1998
CHECK (args[2 ]->IsInt32 ());
1990
1999
const int mode = args[2 ].As <Int32>()->Value ();
1991
2000
1992
- if (! CheckOpenPermissions (env, path, flags)) return ;
2001
+ if (CheckOpenPermissions (env, path, flags). IsNothing ( )) return ;
1993
2002
1994
2003
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
1995
2004
if (req_wrap_async != nullptr ) { // open(path, flags, mode, req)
@@ -2027,7 +2036,7 @@ static void OpenFileHandle(const FunctionCallbackInfo<Value>& args) {
2027
2036
CHECK (args[2 ]->IsInt32 ());
2028
2037
const int mode = args[2 ].As <Int32>()->Value ();
2029
2038
2030
- if (! CheckOpenPermissions (env, path, flags)) return ;
2039
+ if (CheckOpenPermissions (env, path, flags). IsNothing ( )) return ;
2031
2040
2032
2041
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2033
2042
if (req_wrap_async != nullptr ) { // openFileHandle(path, flags, mode, req)
0 commit comments