2019-07-26 16:54:25 -05:00
|
|
|
// run-pass
|
|
|
|
|
2018-09-17 04:18:35 -05:00
|
|
|
#![allow(unused_must_use)]
|
|
|
|
#![allow(unused_imports)]
|
2013-08-28 14:27:10 -05:00
|
|
|
// This test can't be a unit test in std,
|
2013-10-11 08:55:37 -05:00
|
|
|
// because it needs TempDir, which is in extra
|
2013-08-28 14:27:10 -05:00
|
|
|
|
2015-04-22 17:20:57 -05:00
|
|
|
// ignore-cross-compile
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2018-01-22 09:29:24 -06:00
|
|
|
use std::env;
|
2014-11-25 15:28:35 -06:00
|
|
|
use std::ffi::CString;
|
std: Stabilize library APIs for 1.5
This commit stabilizes and deprecates library APIs whose FCP has closed in the
last cycle, specifically:
Stabilized APIs:
* `fs::canonicalize`
* `Path::{metadata, symlink_metadata, canonicalize, read_link, read_dir, exists,
is_file, is_dir}` - all moved to inherent methods from the `PathExt` trait.
* `Formatter::fill`
* `Formatter::width`
* `Formatter::precision`
* `Formatter::sign_plus`
* `Formatter::sign_minus`
* `Formatter::alternate`
* `Formatter::sign_aware_zero_pad`
* `string::ParseError`
* `Utf8Error::valid_up_to`
* `Iterator::{cmp, partial_cmp, eq, ne, lt, le, gt, ge}`
* `<[T]>::split_{first,last}{,_mut}`
* `Condvar::wait_timeout` - note that `wait_timeout_ms` is not yet deprecated
but will be once 1.5 is released.
* `str::{R,}MatchIndices`
* `str::{r,}match_indices`
* `char::from_u32_unchecked`
* `VecDeque::insert`
* `VecDeque::shrink_to_fit`
* `VecDeque::as_slices`
* `VecDeque::as_mut_slices`
* `VecDeque::swap_remove_front` - (renamed from `swap_front_remove`)
* `VecDeque::swap_remove_back` - (renamed from `swap_back_remove`)
* `Vec::resize`
* `str::slice_mut_unchecked`
* `FileTypeExt`
* `FileTypeExt::{is_block_device, is_char_device, is_fifo, is_socket}`
* `BinaryHeap::from` - `from_vec` deprecated in favor of this
* `BinaryHeap::into_vec` - plus a `Into` impl
* `BinaryHeap::into_sorted_vec`
Deprecated APIs
* `slice::ref_slice`
* `slice::mut_ref_slice`
* `iter::{range_inclusive, RangeInclusive}`
* `std::dynamic_lib`
Closes #27706
Closes #27725
cc #27726 (align not stabilized yet)
Closes #27734
Closes #27737
Closes #27742
Closes #27743
Closes #27772
Closes #27774
Closes #27777
Closes #27781
cc #27788 (a few remaining methods though)
Closes #27790
Closes #27793
Closes #27796
Closes #27810
cc #28147 (not all parts stabilized)
2015-10-22 18:28:45 -05:00
|
|
|
use std::fs::{self, File};
|
2018-01-22 09:29:24 -06:00
|
|
|
use std::path::PathBuf;
|
2013-08-28 14:27:10 -05:00
|
|
|
|
|
|
|
fn rename_directory() {
|
2018-01-22 09:29:24 -06:00
|
|
|
let tmpdir = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap());
|
2015-03-17 15:33:26 -05:00
|
|
|
let old_path = tmpdir.join("foo/bar/baz");
|
|
|
|
fs::create_dir_all(&old_path).unwrap();
|
|
|
|
let test_file = &old_path.join("temp.txt");
|
|
|
|
|
|
|
|
File::create(test_file).unwrap();
|
|
|
|
|
|
|
|
let new_path = tmpdir.join("quux/blat");
|
|
|
|
fs::create_dir_all(&new_path).unwrap();
|
|
|
|
fs::rename(&old_path, &new_path.join("newdir"));
|
|
|
|
assert!(new_path.join("newdir").is_dir());
|
|
|
|
assert!(new_path.join("newdir/temp.txt").exists());
|
2013-08-28 14:27:10 -05:00
|
|
|
}
|
|
|
|
|
2014-01-03 17:30:54 -06:00
|
|
|
pub fn main() { rename_directory() }
|