mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 19:41:14 -03:00
committed by
Johannes Altmanninger
parent
11dda63f7b
commit
c7aaf4249a
@@ -340,13 +340,12 @@ fn update_metadata(old_file: &File, new_file: &File) {
|
||||
|
||||
/// Renames a file from `old_name` to `new_name`.
|
||||
fn rename(old_name: &wstr, new_name: &wstr) -> std::io::Result<()> {
|
||||
if wrename(old_name, new_name) == -1 {
|
||||
let error_number = errno::errno();
|
||||
if let Err(e) = wrename(old_name, new_name) {
|
||||
flog!(
|
||||
error,
|
||||
wgettext_fmt!("Error when renaming file: %s", error_number.to_string())
|
||||
wgettext_fmt!("Error when renaming file: %s", e.to_string())
|
||||
);
|
||||
return Err(std::io::Error::from(error_number));
|
||||
return Err(e);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -345,10 +345,10 @@ pub fn wbasename(mut path: &wstr) -> &wstr {
|
||||
}
|
||||
|
||||
/// Wide character version of rename.
|
||||
pub fn wrename(old_name: &wstr, new_name: &wstr) -> libc::c_int {
|
||||
let old_narrow = wcs2zstring(old_name);
|
||||
let new_narrow = wcs2zstring(new_name);
|
||||
unsafe { libc::rename(old_narrow.as_ptr(), new_narrow.as_ptr()) }
|
||||
pub fn wrename(old_name: &wstr, new_name: &wstr) -> io::Result<()> {
|
||||
let old_narrow = wcs2osstring(old_name);
|
||||
let new_narrow = wcs2osstring(new_name);
|
||||
fs::rename(old_narrow, new_narrow)
|
||||
}
|
||||
|
||||
pub fn write_to_fd(input: &[u8], fd: RawFd) -> nix::Result<usize> {
|
||||
|
||||
Reference in New Issue
Block a user