mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
refactor(runtime): factor out FsPermissions for fs ops (#18012)
This will help us with moving fs ops to a separate extension crate.
This commit is contained in:
parent
58ec963bf1
commit
19bb23b60a
4 changed files with 353 additions and 190 deletions
File diff suppressed because it is too large
Load diff
|
@ -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 {
|
||||
|
|
|
@ -425,7 +425,7 @@ impl WebWorker {
|
|||
),
|
||||
// Extensions providing Deno.* features
|
||||
ops::fs_events::init(),
|
||||
ops::fs::init(),
|
||||
ops::fs::init::<PermissionsContainer>(),
|
||||
ops::io::init(),
|
||||
ops::io::init_stdio(options.stdio),
|
||||
deno_tls::init(),
|
||||
|
|
|
@ -256,7 +256,7 @@ impl MainWorker {
|
|||
),
|
||||
ops::spawn::init(),
|
||||
ops::fs_events::init(),
|
||||
ops::fs::init(),
|
||||
ops::fs::init::<PermissionsContainer>(),
|
||||
ops::io::init(),
|
||||
ops::io::init_stdio(options.stdio),
|
||||
deno_tls::init(),
|
||||
|
|
Loading…
Reference in a new issue