mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Refactor rename_without_overwriting to use tokio::task::spawn_blocking
This commit is contained in:
parent
f72a6fae6e
commit
485e4d6974
1 changed files with 5 additions and 2 deletions
|
|
@ -54,8 +54,11 @@ pub async fn rename_without_overwriting(
|
|||
.map_err(|_| io::Error::new(io::ErrorKind::InvalidInput, "invalid path"))?;
|
||||
let new = U16CString::from_os_str(new.as_ref().as_os_str())
|
||||
.map_err(|_| io::Error::new(io::ErrorKind::InvalidInput, "invalid path"))?;
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let result = unsafe { MoveFileExW(old.as_ptr(), new.as_ptr(), 0) };
|
||||
if result != 0 { Ok(()) } else { Err(io::Error::last_os_error()) }
|
||||
})
|
||||
.await?
|
||||
}
|
||||
|
||||
pub async fn symlink_realpath(path: &Path) -> Result<PathBuf> {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue