summaryrefslogtreecommitdiff
path: root/ext/fs/lib.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-05-04 14:28:42 -0400
committerGitHub <noreply@github.com>2023-05-04 14:28:42 -0400
commit5270c43e412cc636cd9923182169d166d181f78a (patch)
tree640c90a70f7dd7bc91f5e942e1eaa5a7914ae46b /ext/fs/lib.rs
parent4b645676d62fd595ecac47e24be1b83a3ba636c6 (diff)
refactor(ext/fs): boxed deno_fs::FileSystem (#18945)
1. Boxed `File` and `FileSystem` to allow more easily passing this through the CLI code (as shown within this pr). 2. `StdFileResource` is now `FileResource`. `FileResource` now contains an `Rc<dyn File>`.
Diffstat (limited to 'ext/fs/lib.rs')
-rw-r--r--ext/fs/lib.rs135
1 files changed, 65 insertions, 70 deletions
diff --git a/ext/fs/lib.rs b/ext/fs/lib.rs
index 464d84ade..4fdf6b3f1 100644
--- a/ext/fs/lib.rs
+++ b/ext/fs/lib.rs
@@ -4,25 +4,21 @@ mod interface;
mod ops;
mod std_fs;
-pub use crate::interface::File;
pub use crate::interface::FileSystem;
pub use crate::interface::FsDirEntry;
-pub use crate::interface::FsError;
pub use crate::interface::FsFileType;
-pub use crate::interface::FsResult;
-pub use crate::interface::FsStat;
pub use crate::interface::OpenOptions;
use crate::ops::*;
-pub use crate::std_fs::StdFs;
+pub use crate::std_fs::RealFs;
use deno_core::error::AnyError;
use deno_core::OpState;
-use deno_core::Resource;
use std::cell::RefCell;
use std::convert::From;
use std::path::Path;
use std::rc::Rc;
+use std::sync::Arc;
pub trait FsPermissions {
fn check_read(&mut self, p: &Path, api_name: &str) -> Result<(), AnyError>;
@@ -87,78 +83,77 @@ pub(crate) fn check_unstable2(state: &Rc<RefCell<OpState>>, api_name: &str) {
deno_core::extension!(deno_fs,
deps = [ deno_web ],
- parameters = [Fs: FileSystem, P: FsPermissions],
- bounds = [Fs::File: Resource],
+ parameters = [P: FsPermissions],
ops = [
- op_cwd<Fs, P>,
- op_umask<Fs>,
- op_chdir<Fs, P>,
+ op_cwd<P>,
+ op_umask,
+ op_chdir<P>,
- op_open_sync<Fs, P>,
- op_open_async<Fs, P>,
- op_mkdir_sync<Fs, P>,
- op_mkdir_async<Fs, P>,
- op_chmod_sync<Fs, P>,
- op_chmod_async<Fs, P>,
- op_chown_sync<Fs, P>,
- op_chown_async<Fs, P>,
- op_remove_sync<Fs, P>,
- op_remove_async<Fs, P>,
- op_copy_file_sync<Fs, P>,
- op_copy_file_async<Fs, P>,
- op_stat_sync<Fs, P>,
- op_stat_async<Fs, P>,
- op_lstat_sync<Fs, P>,
- op_lstat_async<Fs, P>,
- op_realpath_sync<Fs, P>,
- op_realpath_async<Fs, P>,
- op_read_dir_sync<Fs, P>,
- op_read_dir_async<Fs, P>,
- op_rename_sync<Fs, P>,
- op_rename_async<Fs, P>,
- op_link_sync<Fs, P>,
- op_link_async<Fs, P>,
- op_symlink_sync<Fs, P>,
- op_symlink_async<Fs, P>,
- op_read_link_sync<Fs, P>,
- op_read_link_async<Fs, P>,
- op_truncate_sync<Fs, P>,
- op_truncate_async<Fs, P>,
- op_utime_sync<Fs, P>,
- op_utime_async<Fs, P>,
- op_make_temp_dir_sync<Fs, P>,
- op_make_temp_dir_async<Fs, P>,
- op_make_temp_file_sync<Fs, P>,
- op_make_temp_file_async<Fs, P>,
- op_write_file_sync<Fs, P>,
- op_write_file_async<Fs, P>,
- op_read_file_sync<Fs, P>,
- op_read_file_async<Fs, P>,
- op_read_file_text_sync<Fs, P>,
- op_read_file_text_async<Fs, P>,
+ op_open_sync<P>,
+ op_open_async<P>,
+ op_mkdir_sync<P>,
+ op_mkdir_async<P>,
+ op_chmod_sync<P>,
+ op_chmod_async<P>,
+ op_chown_sync<P>,
+ op_chown_async<P>,
+ op_remove_sync<P>,
+ op_remove_async<P>,
+ op_copy_file_sync<P>,
+ op_copy_file_async<P>,
+ op_stat_sync<P>,
+ op_stat_async<P>,
+ op_lstat_sync<P>,
+ op_lstat_async<P>,
+ op_realpath_sync<P>,
+ op_realpath_async<P>,
+ op_read_dir_sync<P>,
+ op_read_dir_async<P>,
+ op_rename_sync<P>,
+ op_rename_async<P>,
+ op_link_sync<P>,
+ op_link_async<P>,
+ op_symlink_sync<P>,
+ op_symlink_async<P>,
+ op_read_link_sync<P>,
+ op_read_link_async<P>,
+ op_truncate_sync<P>,
+ op_truncate_async<P>,
+ op_utime_sync<P>,
+ op_utime_async<P>,
+ op_make_temp_dir_sync<P>,
+ op_make_temp_dir_async<P>,
+ op_make_temp_file_sync<P>,
+ op_make_temp_file_async<P>,
+ op_write_file_sync<P>,
+ op_write_file_async<P>,
+ op_read_file_sync<P>,
+ op_read_file_async<P>,
+ op_read_file_text_sync<P>,
+ op_read_file_text_async<P>,
- op_seek_sync<Fs>,
- op_seek_async<Fs>,
- op_fdatasync_sync<Fs>,
- op_fdatasync_async<Fs>,
- op_fsync_sync<Fs>,
- op_fsync_async<Fs>,
- op_fstat_sync<Fs>,
- op_fstat_async<Fs>,
- op_flock_sync<Fs>,
- op_flock_async<Fs>,
- op_funlock_sync<Fs>,
- op_funlock_async<Fs>,
- op_ftruncate_sync<Fs>,
- op_ftruncate_async<Fs>,
- op_futime_sync<Fs>,
- op_futime_async<Fs>,
+ op_seek_sync,
+ op_seek_async,
+ op_fdatasync_sync,
+ op_fdatasync_async,
+ op_fsync_sync,
+ op_fsync_async,
+ op_fstat_sync,
+ op_fstat_async,
+ op_flock_sync,
+ op_flock_async,
+ op_funlock_sync,
+ op_funlock_async,
+ op_ftruncate_sync,
+ op_ftruncate_async,
+ op_futime_sync,
+ op_futime_async,
],
esm = [ "30_fs.js" ],
options = {
unstable: bool,
- fs: Fs,
+ fs: Arc<dyn FileSystem>,
},
state = |state, options| {
state.put(UnstableChecker { unstable: options.unstable });