diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-04 19:44:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-05 00:44:59 +0100 |
commit | 19bb23b60a102ff5b0c06e302487a964edd68db1 (patch) | |
tree | a416a8969f9b3cba05fd37099fb84794089c7e77 /runtime/permissions/mod.rs | |
parent | 58ec963bf190cd33cdbc3218be3b8c61189bdcfd (diff) |
refactor(runtime): factor out FsPermissions for fs ops (#18012)
This will help us with moving fs ops to a separate extension crate.
Diffstat (limited to 'runtime/permissions/mod.rs')
-rw-r--r-- | runtime/permissions/mod.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/runtime/permissions/mod.rs b/runtime/permissions/mod.rs index 035c39304..5edfbe8f7 100644 --- a/runtime/permissions/mod.rs +++ b/runtime/permissions/mod.rs @@ -1915,6 +1915,41 @@ impl deno_websocket::WebSocketPermissions for PermissionsContainer { } } +impl crate::ops::fs::FsPermissions for PermissionsContainer { + fn check_read( + &mut self, + path: &Path, + api_name: &str, + ) -> Result<(), AnyError> { + self.0.lock().read.check(path, Some(api_name)) + } + + fn check_read_blind( + &mut self, + path: &Path, + display: &str, + api_name: &str, + ) -> Result<(), AnyError> { + self.0.lock().read.check_blind(path, display, api_name) + } + + fn check_write( + &mut self, + path: &Path, + api_name: &str, + ) -> Result<(), AnyError> { + self.0.lock().write.check(path, Some(api_name)) + } + + fn check_read_all(&mut self, api_name: &str) -> Result<(), AnyError> { + self.0.lock().read.check_all(Some(api_name)) + } + + fn check_write_all(&mut self, api_name: &str) -> Result<(), AnyError> { + self.0.lock().write.check_all(Some(api_name)) + } +} + // NOTE(bartlomieju): for now, NAPI uses `--allow-ffi` flag, but that might // change in the future. impl deno_napi::NapiPermissions for PermissionsContainer { |