From 34ed4e26a2c08edc50bb797170212daaad048e46 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 28 Aug 2013 12:27:10 -0700 Subject: std: Add a file-renaming function to std::os --- src/libstd/os.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/libstd') diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 07e0b0857a1..91408162788 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1002,6 +1002,18 @@ pub fn remove_file(p: &Path) -> bool { } } +/// Renames an existing file or directory +pub fn rename_file(old: &Path, new: &Path) -> bool { + #[fixed_stack_segment]; #[inline(never)]; + unsafe { + do old.with_c_str |old_buf| { + do new.with_c_str |new_buf| { + libc::rename(old_buf, new_buf) == (0 as c_int) + } + } + } +} + #[cfg(unix)] /// Returns the platform-specific value of errno pub fn errno() -> int { -- cgit 1.4.1-3-g733a5