1
Fork 0

Add uncontroversial syscall doc aliases to std docs

This commit is contained in:
SabrinaJewson 2024-02-18 14:04:27 +00:00
parent 6f726205a1
commit 6be93ccbee
No known key found for this signature in database
GPG key ID: 3D5438FFA5F05564
3 changed files with 32 additions and 3 deletions

View file

@ -78,7 +78,7 @@ pub fn current_dir() -> io::Result<PathBuf> {
/// assert!(env::set_current_dir(&root).is_ok()); /// assert!(env::set_current_dir(&root).is_ok());
/// println!("Successfully changed working directory to {}!", root.display()); /// println!("Successfully changed working directory to {}!", root.display());
/// ``` /// ```
#[doc(alias = "chdir")] #[doc(alias = "chdir", alias = "SetCurrentDirectory", alias = "SetCurrentDirectoryW")]
#[stable(feature = "env", since = "1.0.0")] #[stable(feature = "env", since = "1.0.0")]
pub fn set_current_dir<P: AsRef<Path>>(path: P) -> io::Result<()> { pub fn set_current_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
os_imp::chdir(path.as_ref()) os_imp::chdir(path.as_ref())
@ -655,6 +655,7 @@ pub fn home_dir() -> Option<PathBuf> {
/// } /// }
/// ``` /// ```
#[must_use] #[must_use]
#[doc(alias = "GetTempPath", alias = "GetTempPath2")]
#[stable(feature = "env", since = "1.0.0")] #[stable(feature = "env", since = "1.0.0")]
pub fn temp_dir() -> PathBuf { pub fn temp_dir() -> PathBuf {
os_imp::temp_dir() os_imp::temp_dir()

View file

@ -656,6 +656,7 @@ impl File {
/// ///
/// Note that this method alters the permissions of the underlying file, /// Note that this method alters the permissions of the underlying file,
/// even though it takes `&self` rather than `&mut self`. /// even though it takes `&self` rather than `&mut self`.
#[doc(alias = "fchmod", alias = "SetFileInformationByHandle")]
#[stable(feature = "set_permissions_atomic", since = "1.16.0")] #[stable(feature = "set_permissions_atomic", since = "1.16.0")]
pub fn set_permissions(&self, perm: Permissions) -> io::Result<()> { pub fn set_permissions(&self, perm: Permissions) -> io::Result<()> {
self.inner.set_permissions(perm.0) self.inner.set_permissions(perm.0)
@ -1314,6 +1315,7 @@ impl Metadata {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "mtime", alias = "ftLastWriteTime")]
#[stable(feature = "fs_time", since = "1.10.0")] #[stable(feature = "fs_time", since = "1.10.0")]
pub fn modified(&self) -> io::Result<SystemTime> { pub fn modified(&self) -> io::Result<SystemTime> {
self.0.modified().map(FromInner::from_inner) self.0.modified().map(FromInner::from_inner)
@ -1349,6 +1351,7 @@ impl Metadata {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "atime", alias = "ftLastAccessTime")]
#[stable(feature = "fs_time", since = "1.10.0")] #[stable(feature = "fs_time", since = "1.10.0")]
pub fn accessed(&self) -> io::Result<SystemTime> { pub fn accessed(&self) -> io::Result<SystemTime> {
self.0.accessed().map(FromInner::from_inner) self.0.accessed().map(FromInner::from_inner)
@ -1381,6 +1384,7 @@ impl Metadata {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "btime", alias = "birthtime", alias = "ftCreationTime")]
#[stable(feature = "fs_time", since = "1.10.0")] #[stable(feature = "fs_time", since = "1.10.0")]
pub fn created(&self) -> io::Result<SystemTime> { pub fn created(&self) -> io::Result<SystemTime> {
self.0.created().map(FromInner::from_inner) self.0.created().map(FromInner::from_inner)
@ -1879,6 +1883,7 @@ impl AsInner<fs_imp::DirEntry> for DirEntry {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "rm", alias = "unlink", alias = "DeleteFile")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> { pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
fs_imp::unlink(path.as_ref()) fs_imp::unlink(path.as_ref())
@ -1917,6 +1922,7 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "stat")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> { pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
fs_imp::stat(path.as_ref()).map(Metadata) fs_imp::stat(path.as_ref()).map(Metadata)
@ -1951,6 +1957,7 @@ pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "lstat")]
#[stable(feature = "symlink_metadata", since = "1.1.0")] #[stable(feature = "symlink_metadata", since = "1.1.0")]
pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> { pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
fs_imp::lstat(path.as_ref()).map(Metadata) fs_imp::lstat(path.as_ref()).map(Metadata)
@ -1994,6 +2001,7 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "mv", alias = "MoveFile", alias = "MoveFileEx")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()> { pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()> {
fs_imp::rename(from.as_ref(), to.as_ref()) fs_imp::rename(from.as_ref(), to.as_ref())
@ -2052,6 +2060,9 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()>
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "cp")]
#[doc(alias = "CopyFile", alias = "CopyFileEx")]
#[doc(alias = "fclonefileat", alias = "fcopyfile")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<u64> { pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<u64> {
fs_imp::copy(from.as_ref(), to.as_ref()) fs_imp::copy(from.as_ref(), to.as_ref())
@ -2096,6 +2107,7 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<u64> {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "CreateHardLink", alias = "linkat")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Result<()> { pub fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Result<()> {
fs_imp::link(original.as_ref(), link.as_ref()) fs_imp::link(original.as_ref(), link.as_ref())
@ -2245,7 +2257,7 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "mkdir")] #[doc(alias = "mkdir", alias = "CreateDirectory")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "fs_create_dir")] #[cfg_attr(not(test), rustc_diagnostic_item = "fs_create_dir")]
pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> { pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
@ -2326,7 +2338,7 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "rmdir")] #[doc(alias = "rmdir", alias = "RemoveDirectory")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> { pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
fs_imp::rmdir(path.as_ref()) fs_imp::rmdir(path.as_ref())
@ -2449,6 +2461,7 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "ls", alias = "opendir", alias = "FindFirstFile", alias = "FindNextFile")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> { pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> {
fs_imp::readdir(path.as_ref()).map(ReadDir) fs_imp::readdir(path.as_ref()).map(ReadDir)
@ -2484,6 +2497,7 @@ pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[doc(alias = "chmod", alias = "SetFileAttributes")]
#[stable(feature = "set_permissions", since = "1.1.0")] #[stable(feature = "set_permissions", since = "1.1.0")]
pub fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions) -> io::Result<()> { pub fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions) -> io::Result<()> {
fs_imp::set_perm(path.as_ref(), perm.0) fs_imp::set_perm(path.as_ref(), perm.0)

View file

@ -173,51 +173,61 @@ pub trait FileExt {
/// ///
/// This corresponds to the `fd_tell` syscall and is similar to /// This corresponds to the `fd_tell` syscall and is similar to
/// `seek` where you offset 0 bytes from the current position. /// `seek` where you offset 0 bytes from the current position.
#[doc(alias = "fd_tell")]
fn tell(&self) -> io::Result<u64>; fn tell(&self) -> io::Result<u64>;
/// Adjust the flags associated with this file. /// Adjust the flags associated with this file.
/// ///
/// This corresponds to the `fd_fdstat_set_flags` syscall. /// This corresponds to the `fd_fdstat_set_flags` syscall.
#[doc(alias = "fd_fdstat_set_flags")]
fn fdstat_set_flags(&self, flags: u16) -> io::Result<()>; fn fdstat_set_flags(&self, flags: u16) -> io::Result<()>;
/// Adjust the rights associated with this file. /// Adjust the rights associated with this file.
/// ///
/// This corresponds to the `fd_fdstat_set_rights` syscall. /// This corresponds to the `fd_fdstat_set_rights` syscall.
#[doc(alias = "fd_fdstat_set_rights")]
fn fdstat_set_rights(&self, rights: u64, inheriting: u64) -> io::Result<()>; fn fdstat_set_rights(&self, rights: u64, inheriting: u64) -> io::Result<()>;
/// Provide file advisory information on a file descriptor. /// Provide file advisory information on a file descriptor.
/// ///
/// This corresponds to the `fd_advise` syscall. /// This corresponds to the `fd_advise` syscall.
#[doc(alias = "fd_advise")]
fn advise(&self, offset: u64, len: u64, advice: u8) -> io::Result<()>; fn advise(&self, offset: u64, len: u64, advice: u8) -> io::Result<()>;
/// Force the allocation of space in a file. /// Force the allocation of space in a file.
/// ///
/// This corresponds to the `fd_allocate` syscall. /// This corresponds to the `fd_allocate` syscall.
#[doc(alias = "fd_allocate")]
fn allocate(&self, offset: u64, len: u64) -> io::Result<()>; fn allocate(&self, offset: u64, len: u64) -> io::Result<()>;
/// Create a directory. /// Create a directory.
/// ///
/// This corresponds to the `path_create_directory` syscall. /// This corresponds to the `path_create_directory` syscall.
#[doc(alias = "path_create_directory")]
fn create_directory<P: AsRef<Path>>(&self, dir: P) -> io::Result<()>; fn create_directory<P: AsRef<Path>>(&self, dir: P) -> io::Result<()>;
/// Read the contents of a symbolic link. /// Read the contents of a symbolic link.
/// ///
/// This corresponds to the `path_readlink` syscall. /// This corresponds to the `path_readlink` syscall.
#[doc(alias = "path_readlink")]
fn read_link<P: AsRef<Path>>(&self, path: P) -> io::Result<PathBuf>; fn read_link<P: AsRef<Path>>(&self, path: P) -> io::Result<PathBuf>;
/// Return the attributes of a file or directory. /// Return the attributes of a file or directory.
/// ///
/// This corresponds to the `path_filestat_get` syscall. /// This corresponds to the `path_filestat_get` syscall.
#[doc(alias = "path_filestat_get")]
fn metadata_at<P: AsRef<Path>>(&self, lookup_flags: u32, path: P) -> io::Result<Metadata>; fn metadata_at<P: AsRef<Path>>(&self, lookup_flags: u32, path: P) -> io::Result<Metadata>;
/// Unlink a file. /// Unlink a file.
/// ///
/// This corresponds to the `path_unlink_file` syscall. /// This corresponds to the `path_unlink_file` syscall.
#[doc(alias = "path_unlink_file")]
fn remove_file<P: AsRef<Path>>(&self, path: P) -> io::Result<()>; fn remove_file<P: AsRef<Path>>(&self, path: P) -> io::Result<()>;
/// Remove a directory. /// Remove a directory.
/// ///
/// This corresponds to the `path_remove_directory` syscall. /// This corresponds to the `path_remove_directory` syscall.
#[doc(alias = "path_remove_directory")]
fn remove_directory<P: AsRef<Path>>(&self, path: P) -> io::Result<()>; fn remove_directory<P: AsRef<Path>>(&self, path: P) -> io::Result<()>;
} }
@ -359,6 +369,7 @@ pub trait OpenOptionsExt {
/// Open a file or directory. /// Open a file or directory.
/// ///
/// This corresponds to the `path_open` syscall. /// This corresponds to the `path_open` syscall.
#[doc(alias = "path_open")]
fn open_at<P: AsRef<Path>>(&self, file: &File, path: P) -> io::Result<File>; fn open_at<P: AsRef<Path>>(&self, file: &File, path: P) -> io::Result<File>;
} }
@ -500,6 +511,7 @@ impl DirEntryExt for fs::DirEntry {
/// Create a hard link. /// Create a hard link.
/// ///
/// This corresponds to the `path_link` syscall. /// This corresponds to the `path_link` syscall.
#[doc(alias = "path_link")]
pub fn link<P: AsRef<Path>, U: AsRef<Path>>( pub fn link<P: AsRef<Path>, U: AsRef<Path>>(
old_fd: &File, old_fd: &File,
old_flags: u32, old_flags: u32,
@ -518,6 +530,7 @@ pub fn link<P: AsRef<Path>, U: AsRef<Path>>(
/// Rename a file or directory. /// Rename a file or directory.
/// ///
/// This corresponds to the `path_rename` syscall. /// This corresponds to the `path_rename` syscall.
#[doc(alias = "path_rename")]
pub fn rename<P: AsRef<Path>, U: AsRef<Path>>( pub fn rename<P: AsRef<Path>, U: AsRef<Path>>(
old_fd: &File, old_fd: &File,
old_path: P, old_path: P,
@ -534,6 +547,7 @@ pub fn rename<P: AsRef<Path>, U: AsRef<Path>>(
/// Create a symbolic link. /// Create a symbolic link.
/// ///
/// This corresponds to the `path_symlink` syscall. /// This corresponds to the `path_symlink` syscall.
#[doc(alias = "path_symlink")]
pub fn symlink<P: AsRef<Path>, U: AsRef<Path>>( pub fn symlink<P: AsRef<Path>, U: AsRef<Path>>(
old_path: P, old_path: P,
fd: &File, fd: &File,