diff options
Diffstat (limited to 'runtime/ops/fs.rs')
-rw-r--r-- | runtime/ops/fs.rs | 103 |
1 files changed, 49 insertions, 54 deletions
diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs index e22fe0c5a..a80eeb3ac 100644 --- a/runtime/ops/fs.rs +++ b/runtime/ops/fs.rs @@ -14,7 +14,6 @@ use deno_core::Extension; use deno_core::OpState; use deno_core::RcRef; use deno_core::ResourceId; -use deno_core::ZeroCopyBuf; use deno_crypto::rand::thread_rng; use deno_crypto::rand::Rng; use log::debug; @@ -157,7 +156,7 @@ fn open_helper( fn op_open_sync( state: &mut OpState, args: OpenArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<ResourceId, AnyError> { let (path, open_options) = open_helper(state, args)?; let std_file = open_options.open(path)?; @@ -170,7 +169,7 @@ fn op_open_sync( async fn op_open_async( state: Rc<RefCell<OpState>>, args: OpenArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<ResourceId, AnyError> { let (path, open_options) = open_helper(&mut state.borrow_mut(), args)?; let tokio_file = tokio::fs::OpenOptions::from(open_options) @@ -209,7 +208,7 @@ fn seek_helper(args: SeekArgs) -> Result<(u32, SeekFrom), AnyError> { fn op_seek_sync( state: &mut OpState, args: SeekArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<u64, AnyError> { let (rid, seek_from) = seek_helper(args)?; let pos = StdFileResource::with(state, rid, |r| match r { @@ -224,7 +223,7 @@ fn op_seek_sync( async fn op_seek_async( state: Rc<RefCell<OpState>>, args: SeekArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<u64, AnyError> { let (rid, seek_from) = seek_helper(args)?; @@ -249,7 +248,7 @@ async fn op_seek_async( fn op_fdatasync_sync( state: &mut OpState, rid: ResourceId, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { StdFileResource::with(state, rid, |r| match r { Ok(std_file) => std_file.sync_data().map_err(AnyError::from), @@ -261,7 +260,7 @@ fn op_fdatasync_sync( async fn op_fdatasync_async( state: Rc<RefCell<OpState>>, rid: ResourceId, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let resource = state .borrow_mut() @@ -284,7 +283,7 @@ async fn op_fdatasync_async( fn op_fsync_sync( state: &mut OpState, rid: ResourceId, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { StdFileResource::with(state, rid, |r| match r { Ok(std_file) => std_file.sync_all().map_err(AnyError::from), @@ -296,7 +295,7 @@ fn op_fsync_sync( async fn op_fsync_async( state: Rc<RefCell<OpState>>, rid: ResourceId, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let resource = state .borrow_mut() @@ -319,7 +318,7 @@ async fn op_fsync_async( fn op_fstat_sync( state: &mut OpState, rid: ResourceId, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<FsStat, AnyError> { let metadata = StdFileResource::with(state, rid, |r| match r { Ok(std_file) => std_file.metadata().map_err(AnyError::from), @@ -331,7 +330,7 @@ fn op_fstat_sync( async fn op_fstat_async( state: Rc<RefCell<OpState>>, rid: ResourceId, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<FsStat, AnyError> { let resource = state .borrow_mut() @@ -355,7 +354,7 @@ async fn op_fstat_async( fn op_umask( state: &mut OpState, mask: Option<u32>, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<u32, AnyError> { super::check_unstable(state, "Deno.umask"); // TODO implement umask for Windows @@ -387,7 +386,7 @@ fn op_umask( fn op_chdir( state: &mut OpState, directory: String, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let d = PathBuf::from(&directory); state.borrow_mut::<Permissions>().read.check(&d)?; @@ -406,7 +405,7 @@ pub struct MkdirArgs { fn op_mkdir_sync( state: &mut OpState, args: MkdirArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let path = Path::new(&args.path).to_path_buf(); let mode = args.mode.unwrap_or(0o777) & 0o777; @@ -426,7 +425,7 @@ fn op_mkdir_sync( async fn op_mkdir_async( state: Rc<RefCell<OpState>>, args: MkdirArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let path = Path::new(&args.path).to_path_buf(); let mode = args.mode.unwrap_or(0o777) & 0o777; @@ -462,7 +461,7 @@ pub struct ChmodArgs { fn op_chmod_sync( state: &mut OpState, args: ChmodArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let path = Path::new(&args.path).to_path_buf(); let mode = args.mode & 0o777; @@ -488,7 +487,7 @@ fn op_chmod_sync( async fn op_chmod_async( state: Rc<RefCell<OpState>>, args: ChmodArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let path = Path::new(&args.path).to_path_buf(); let mode = args.mode & 0o777; @@ -530,7 +529,7 @@ pub struct ChownArgs { fn op_chown_sync( state: &mut OpState, args: ChownArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let path = Path::new(&args.path).to_path_buf(); state.borrow_mut::<Permissions>().write.check(&path)?; @@ -558,7 +557,7 @@ fn op_chown_sync( async fn op_chown_async( state: Rc<RefCell<OpState>>, args: ChownArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let path = Path::new(&args.path).to_path_buf(); @@ -600,7 +599,7 @@ pub struct RemoveArgs { fn op_remove_sync( state: &mut OpState, args: RemoveArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let path = PathBuf::from(&args.path); let recursive = args.recursive; @@ -642,7 +641,7 @@ fn op_remove_sync( async fn op_remove_async( state: Rc<RefCell<OpState>>, args: RemoveArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let path = PathBuf::from(&args.path); let recursive = args.recursive; @@ -698,7 +697,7 @@ pub struct CopyFileArgs { fn op_copy_file_sync( state: &mut OpState, args: CopyFileArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let from = PathBuf::from(&args.from); let to = PathBuf::from(&args.to); @@ -723,7 +722,7 @@ fn op_copy_file_sync( async fn op_copy_file_async( state: Rc<RefCell<OpState>>, args: CopyFileArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let from = PathBuf::from(&args.from); let to = PathBuf::from(&args.to); @@ -838,7 +837,7 @@ pub struct StatArgs { fn op_stat_sync( state: &mut OpState, args: StatArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<FsStat, AnyError> { let path = PathBuf::from(&args.path); let lstat = args.lstat; @@ -855,7 +854,7 @@ fn op_stat_sync( async fn op_stat_async( state: Rc<RefCell<OpState>>, args: StatArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<FsStat, AnyError> { let path = PathBuf::from(&args.path); let lstat = args.lstat; @@ -881,7 +880,7 @@ async fn op_stat_async( fn op_realpath_sync( state: &mut OpState, path: String, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<String, AnyError> { let path = PathBuf::from(&path); @@ -902,7 +901,7 @@ fn op_realpath_sync( async fn op_realpath_async( state: Rc<RefCell<OpState>>, path: String, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<String, AnyError> { let path = PathBuf::from(&path); @@ -939,7 +938,7 @@ pub struct DirEntry { fn op_read_dir_sync( state: &mut OpState, path: String, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<Vec<DirEntry>, AnyError> { let path = PathBuf::from(&path); @@ -975,7 +974,7 @@ fn op_read_dir_sync( async fn op_read_dir_async( state: Rc<RefCell<OpState>>, path: String, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<Vec<DirEntry>, AnyError> { let path = PathBuf::from(&path); { @@ -1023,7 +1022,7 @@ pub struct RenameArgs { fn op_rename_sync( state: &mut OpState, args: RenameArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let oldpath = PathBuf::from(&args.oldpath); let newpath = PathBuf::from(&args.newpath); @@ -1040,7 +1039,7 @@ fn op_rename_sync( async fn op_rename_async( state: Rc<RefCell<OpState>>, args: RenameArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let oldpath = PathBuf::from(&args.oldpath); let newpath = PathBuf::from(&args.newpath); @@ -1074,7 +1073,7 @@ pub struct LinkArgs { fn op_link_sync( state: &mut OpState, args: LinkArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let oldpath = PathBuf::from(&args.oldpath); let newpath = PathBuf::from(&args.newpath); @@ -1093,7 +1092,7 @@ fn op_link_sync( async fn op_link_async( state: Rc<RefCell<OpState>>, args: LinkArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let oldpath = PathBuf::from(&args.oldpath); let newpath = PathBuf::from(&args.newpath); @@ -1135,7 +1134,7 @@ pub struct SymlinkOptions { fn op_symlink_sync( state: &mut OpState, args: SymlinkArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let oldpath = PathBuf::from(&args.oldpath); let newpath = PathBuf::from(&args.newpath); @@ -1184,7 +1183,7 @@ fn op_symlink_sync( async fn op_symlink_async( state: Rc<RefCell<OpState>>, args: SymlinkArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let oldpath = PathBuf::from(&args.oldpath); let newpath = PathBuf::from(&args.newpath); @@ -1236,7 +1235,7 @@ async fn op_symlink_async( fn op_read_link_sync( state: &mut OpState, path: String, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<String, AnyError> { let path = PathBuf::from(&path); @@ -1251,7 +1250,7 @@ fn op_read_link_sync( async fn op_read_link_async( state: Rc<RefCell<OpState>>, path: String, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<String, AnyError> { let path = PathBuf::from(&path); { @@ -1278,7 +1277,7 @@ pub struct FtruncateArgs { fn op_ftruncate_sync( state: &mut OpState, args: FtruncateArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let rid = args.rid; let len = args.len as u64; @@ -1292,7 +1291,7 @@ fn op_ftruncate_sync( async fn op_ftruncate_async( state: Rc<RefCell<OpState>>, args: FtruncateArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let rid = args.rid; let len = args.len as u64; @@ -1325,7 +1324,7 @@ pub struct TruncateArgs { fn op_truncate_sync( state: &mut OpState, args: TruncateArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let path = PathBuf::from(&args.path); let len = args.len; @@ -1341,7 +1340,7 @@ fn op_truncate_sync( async fn op_truncate_async( state: Rc<RefCell<OpState>>, args: TruncateArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { let path = PathBuf::from(&args.path); let len = args.len; @@ -1415,7 +1414,7 @@ pub struct MakeTempArgs { fn op_make_temp_dir_sync( state: &mut OpState, args: MakeTempArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<String, AnyError> { let dir = args.dir.map(|s| PathBuf::from(&s)); let prefix = args.prefix.map(String::from); @@ -1444,7 +1443,7 @@ fn op_make_temp_dir_sync( async fn op_make_temp_dir_async( state: Rc<RefCell<OpState>>, args: MakeTempArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<String, AnyError> { let dir = args.dir.map(|s| PathBuf::from(&s)); let prefix = args.prefix.map(String::from); @@ -1478,7 +1477,7 @@ async fn op_make_temp_dir_async( fn op_make_temp_file_sync( state: &mut OpState, args: MakeTempArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<String, AnyError> { let dir = args.dir.map(|s| PathBuf::from(&s)); let prefix = args.prefix.map(String::from); @@ -1507,7 +1506,7 @@ fn op_make_temp_file_sync( async fn op_make_temp_file_async( state: Rc<RefCell<OpState>>, args: MakeTempArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<String, AnyError> { let dir = args.dir.map(|s| PathBuf::from(&s)); let prefix = args.prefix.map(String::from); @@ -1549,7 +1548,7 @@ pub struct FutimeArgs { fn op_futime_sync( state: &mut OpState, args: FutimeArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { super::check_unstable(state, "Deno.futimeSync"); let rid = args.rid; @@ -1572,7 +1571,7 @@ fn op_futime_sync( async fn op_futime_async( state: Rc<RefCell<OpState>>, args: FutimeArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { super::check_unstable2(&state, "Deno.futime"); let rid = args.rid; @@ -1621,7 +1620,7 @@ pub struct UtimeArgs { fn op_utime_sync( state: &mut OpState, args: UtimeArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { super::check_unstable(state, "Deno.utime"); @@ -1637,7 +1636,7 @@ fn op_utime_sync( async fn op_utime_async( state: Rc<RefCell<OpState>>, args: UtimeArgs, - _zero_copy: Option<ZeroCopyBuf>, + _: (), ) -> Result<(), AnyError> { super::check_unstable(&state.borrow(), "Deno.utime"); @@ -1659,11 +1658,7 @@ async fn op_utime_async( .unwrap() } -fn op_cwd( - state: &mut OpState, - _args: (), - _zero_copy: Option<ZeroCopyBuf>, -) -> Result<String, AnyError> { +fn op_cwd(state: &mut OpState, _args: (), _: ()) -> Result<String, AnyError> { let path = current_dir()?; state .borrow_mut::<Permissions>() |