Return OutOfMemoryError and update docs
This commit is contained in:
parent
0dfe2ae3fb
commit
3cb53df1fe
2 changed files with 3 additions and 3 deletions
|
@ -2446,7 +2446,7 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
|
||||||
/// # Platform-specific behavior
|
/// # Platform-specific behavior
|
||||||
///
|
///
|
||||||
/// This function currently corresponds to the `rename` function on Unix
|
/// This function currently corresponds to the `rename` function on Unix
|
||||||
/// and the `SetFileInformationByHandle` function on Windows.
|
/// and the `MoveFileExW` or `SetFileInformationByHandle` function on Windows.
|
||||||
///
|
///
|
||||||
/// Because of this, the behavior when both `from` and `to` exist differs. On
|
/// Because of this, the behavior when both `from` and `to` exist differs. On
|
||||||
/// Unix, if `from` is a directory, `to` must also be an (empty) directory. If
|
/// Unix, if `from` is a directory, `to` must also be an (empty) directory. If
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::api::{self, WinError, set_file_information_by_handle};
|
use super::api::{self, WinError, set_file_information_by_handle};
|
||||||
use super::{IoResult, to_u16s};
|
use super::{IoResult, to_u16s};
|
||||||
use crate::alloc::{Layout, alloc, dealloc, handle_alloc_error};
|
use crate::alloc::{Layout, alloc, dealloc};
|
||||||
use crate::borrow::Cow;
|
use crate::borrow::Cow;
|
||||||
use crate::ffi::{OsStr, OsString, c_void};
|
use crate::ffi::{OsStr, OsString, c_void};
|
||||||
use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom};
|
use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom};
|
||||||
|
@ -1269,7 +1269,7 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
file_rename_info = alloc(layout).cast::<c::FILE_RENAME_INFO>();
|
file_rename_info = alloc(layout).cast::<c::FILE_RENAME_INFO>();
|
||||||
if file_rename_info.is_null() {
|
if file_rename_info.is_null() {
|
||||||
handle_alloc_error(layout);
|
return Err(io::ErrorKind::OutOfMemory.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
(&raw mut (*file_rename_info).Anonymous).write(c::FILE_RENAME_INFO_0 {
|
(&raw mut (*file_rename_info).Anonymous).write(c::FILE_RENAME_INFO_0 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue