diff options
Diffstat (limited to 'runtime/ops')
-rw-r--r-- | runtime/ops/fs.rs | 60 | ||||
-rw-r--r-- | runtime/ops/io.rs | 2 | ||||
-rw-r--r-- | runtime/ops/os/mod.rs | 6 | ||||
-rw-r--r-- | runtime/ops/signal.rs | 8 |
4 files changed, 38 insertions, 38 deletions
diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs index b661c6ea8..ec60eed62 100644 --- a/runtime/ops/fs.rs +++ b/runtime/ops/fs.rs @@ -530,13 +530,13 @@ fn op_umask(state: &mut OpState, mask: Option<u32>) -> Result<u32, AnyError> { } #[op] -fn op_chdir(state: &mut OpState, directory: &str) -> Result<(), AnyError> { +fn op_chdir(state: &mut OpState, directory: String) -> Result<(), AnyError> { let d = PathBuf::from(&directory); state .borrow_mut::<Permissions>() .read .check(&d, Some("Deno.chdir()"))?; - set_current_dir(d).map_err(|err| { + set_current_dir(&d).map_err(|err| { Error::new(err.kind(), format!("{}, chdir '{}'", err, directory)) })?; Ok(()) @@ -609,10 +609,10 @@ async fn op_mkdir_async( #[op] fn op_chmod_sync( state: &mut OpState, - path: &str, + path: String, mode: u32, ) -> Result<(), AnyError> { - let path = Path::new(path); + let path = Path::new(&path); let mode = mode & 0o777; state @@ -667,11 +667,11 @@ fn raw_chmod(path: &Path, _raw_mode: u32) -> Result<(), AnyError> { #[op] fn op_chown_sync( state: &mut OpState, - path: &str, + path: String, #[cfg_attr(windows, allow(unused_variables))] uid: Option<u32>, #[cfg_attr(windows, allow(unused_variables))] gid: Option<u32>, ) -> Result<(), AnyError> { - let path = Path::new(path).to_path_buf(); + let path = Path::new(&path).to_path_buf(); state .borrow_mut::<Permissions>() .write @@ -740,10 +740,10 @@ async fn op_chown_async( #[op] fn op_remove_sync( state: &mut OpState, - path: &str, + path: String, recursive: bool, ) -> Result<(), AnyError> { - let path = PathBuf::from(path); + let path = PathBuf::from(&path); state .borrow_mut::<Permissions>() @@ -841,11 +841,11 @@ async fn op_remove_async( #[op] fn op_copy_file_sync( state: &mut OpState, - from: &str, - to: &str, + from: String, + to: String, ) -> Result<(), AnyError> { - let from_path = PathBuf::from(from); - let to_path = PathBuf::from(to); + let from_path = PathBuf::from(&from); + let to_path = PathBuf::from(&to); let permissions = state.borrow_mut::<Permissions>(); permissions @@ -1103,11 +1103,11 @@ pub struct StatArgs { #[op] fn op_stat_sync( state: &mut OpState, - path: &str, + path: String, lstat: bool, out_buf: &mut [u32], ) -> Result<(), AnyError> { - let path = PathBuf::from(path); + let path = PathBuf::from(&path); state .borrow_mut::<Permissions>() .read @@ -1319,11 +1319,11 @@ async fn op_read_dir_async( #[op] fn op_rename_sync( state: &mut OpState, - oldpath: &str, - newpath: &str, + oldpath: String, + newpath: String, ) -> Result<(), AnyError> { - let oldpath = PathBuf::from(oldpath); - let newpath = PathBuf::from(newpath); + let oldpath = PathBuf::from(&oldpath); + let newpath = PathBuf::from(&newpath); let permissions = state.borrow_mut::<Permissions>(); permissions @@ -1388,11 +1388,11 @@ async fn op_rename_async( #[op] fn op_link_sync( state: &mut OpState, - oldpath: &str, - newpath: &str, + oldpath: String, + newpath: String, ) -> Result<(), AnyError> { - let oldpath = PathBuf::from(oldpath); - let newpath = PathBuf::from(newpath); + let oldpath = PathBuf::from(&oldpath); + let newpath = PathBuf::from(&newpath); let permissions = state.borrow_mut::<Permissions>(); permissions.read.check(&oldpath, Some("Deno.linkSync()"))?; @@ -1455,12 +1455,12 @@ async fn op_link_async( #[op] fn op_symlink_sync( state: &mut OpState, - oldpath: &str, - newpath: &str, + oldpath: String, + newpath: String, _type: Option<String>, ) -> Result<(), AnyError> { - let oldpath = PathBuf::from(oldpath); - let newpath = PathBuf::from(newpath); + let oldpath = PathBuf::from(&oldpath); + let newpath = PathBuf::from(&newpath); state .borrow_mut::<Permissions>() @@ -1675,10 +1675,10 @@ async fn op_ftruncate_async( #[op] fn op_truncate_sync( state: &mut OpState, - path: &str, + path: String, len: u64, ) -> Result<(), AnyError> { - let path = PathBuf::from(path); + let path = PathBuf::from(&path); state .borrow_mut::<Permissions>() @@ -1955,13 +1955,13 @@ async fn op_futime_async( #[op] fn op_utime_sync( state: &mut OpState, - path: &str, + path: String, atime_secs: i64, atime_nanos: u32, mtime_secs: i64, mtime_nanos: u32, ) -> Result<(), AnyError> { - let path = PathBuf::from(path); + let path = PathBuf::from(&path); let atime = filetime::FileTime::from_unix_time(atime_secs, atime_nanos); let mtime = filetime::FileTime::from_unix_time(mtime_secs, mtime_nanos); diff --git a/runtime/ops/io.rs b/runtime/ops/io.rs index d8a1af69e..646a540bc 100644 --- a/runtime/ops/io.rs +++ b/runtime/ops/io.rs @@ -670,7 +670,7 @@ impl Resource for StdFileResource { #[op] pub fn op_print( state: &mut OpState, - msg: &str, + msg: String, is_err: bool, ) -> Result<(), AnyError> { let rid = if is_err { 2 } else { 1 }; diff --git a/runtime/ops/os/mod.rs b/runtime/ops/os/mod.rs index 844fbaecc..b93935955 100644 --- a/runtime/ops/os/mod.rs +++ b/runtime/ops/os/mod.rs @@ -78,10 +78,10 @@ fn op_exec_path(state: &mut OpState) -> Result<String, AnyError> { #[op] fn op_set_env( state: &mut OpState, - key: &str, - value: &str, + key: String, + value: String, ) -> Result<(), AnyError> { - state.borrow_mut::<Permissions>().env.check(key)?; + state.borrow_mut::<Permissions>().env.check(&key)?; if key.is_empty() { return Err(type_error("Key is an empty string.")); } diff --git a/runtime/ops/signal.rs b/runtime/ops/signal.rs index 66530a838..95c166787 100644 --- a/runtime/ops/signal.rs +++ b/runtime/ops/signal.rs @@ -453,9 +453,9 @@ pub fn signal_int_to_str(s: libc::c_int) -> Result<&'static str, AnyError> { #[op] fn op_signal_bind( state: &mut OpState, - sig: &str, + sig: String, ) -> Result<ResourceId, AnyError> { - let signo = signal_str_to_int(sig)?; + let signo = signal_str_to_int(&sig)?; if signal_hook_registry::FORBIDDEN.contains(&signo) { return Err(type_error(format!( "Binding to signal '{}' is not allowed", @@ -474,9 +474,9 @@ fn op_signal_bind( #[op] fn op_signal_bind( state: &mut OpState, - sig: &str, + sig: String, ) -> Result<ResourceId, AnyError> { - let signo = signal_str_to_int(sig)?; + let signo = signal_str_to_int(&sig)?; let resource = SignalStreamResource { signal: AsyncRefCell::new(match signo { // SIGINT |