Skip to content

Commit 15ab7b4

Browse files
committed
Rename std::fs::soft_link to std::fs::symlink
The term "soft link" is not used in any other APIs or formal documentation on symbolic links, making this name somewhat surprising and hard to find. Switch to the more commonly recognized, but still reasonably short, std::fs::symlink instead. Because this is a stable API in the beta period, the old name is retained but marked deprecated as a wrapper around the new name.
1 parent 6436e34 commit 15ab7b4

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/libstd/fs.rs

+21-12
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
699699
/// Given a path, query the file system to get information about a file,
700700
/// directory, etc.
701701
///
702-
/// This function will traverse soft links to query information about the
702+
/// This function will traverse symbolic links to query information about the
703703
/// destination file.
704704
///
705705
/// # Examples
@@ -811,31 +811,40 @@ pub fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<(
811811
fs_imp::link(src.as_ref(), dst.as_ref())
812812
}
813813

814-
/// Creates a new soft link on the filesystem.
814+
/// Creates a new symbolic link on the filesystem.
815815
///
816-
/// The `dst` path will be a soft link pointing to the `src` path.
816+
/// The `dst` path will be a symbolic link pointing to the `src` path.
817817
///
818818
/// # Examples
819819
///
820820
/// ```
821821
/// use std::fs;
822822
///
823823
/// # fn foo() -> std::io::Result<()> {
824-
/// try!(fs::soft_link("a.txt", "b.txt"));
824+
/// try!(fs::symlink("a.txt", "b.txt"));
825825
/// # Ok(())
826826
/// # }
827827
/// ```
828828
#[stable(feature = "rust1", since = "1.0.0")]
829-
pub fn soft_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
829+
pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
830830
fs_imp::symlink(src.as_ref(), dst.as_ref())
831831
}
832832

833-
/// Reads a soft link, returning the file that the link points to.
833+
/// Creates a new symbolic link on the filesystem.
834+
///
835+
/// Replaced by `std::fs::symlink`.
836+
#[deprecated(since = "1.0.0", reason = "replaced with std::fs::symlink")]
837+
#[stable(feature = "rust1", since = "1.0.0")]
838+
pub fn soft_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
839+
symlink(src, dst)
840+
}
841+
842+
/// Reads a symbolic link, returning the file that the link points to.
834843
///
835844
/// # Errors
836845
///
837846
/// This function will return an error on failure. Failure conditions include
838-
/// reading a file that does not exist or reading a file that is not a soft
847+
/// reading a file that does not exist or reading a file that is not a symbolic
839848
/// link.
840849
///
841850
/// # Examples
@@ -928,8 +937,8 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
928937
/// Removes a directory at this path, after removing all its contents. Use
929938
/// carefully!
930939
///
931-
/// This function does **not** follow soft links and it will simply remove the
932-
/// soft link itself.
940+
/// This function does **not** follow symbolic links and it will simply remove the
941+
/// symbolic link itself.
933942
///
934943
/// # Errors
935944
///
@@ -1528,7 +1537,7 @@ mod tests {
15281537
check!(fs::create_dir_all(&dtt));
15291538
check!(fs::create_dir_all(&d2));
15301539
check!(check!(File::create(&canary)).write(b"foo"));
1531-
check!(fs::soft_link(&d2, &dt.join("d2")));
1540+
check!(fs::symlink(&d2, &dt.join("d2")));
15321541
check!(fs::remove_dir_all(&d1));
15331542

15341543
assert!(!d1.is_dir());
@@ -1658,7 +1667,7 @@ mod tests {
16581667
let out = tmpdir.join("out.txt");
16591668

16601669
check!(check!(File::create(&input)).write("foobar".as_bytes()));
1661-
check!(fs::soft_link(&input, &out));
1670+
check!(fs::symlink(&input, &out));
16621671
// if cfg!(not(windows)) {
16631672
// assert_eq!(check!(lstat(&out)).kind, FileType::Symlink);
16641673
// assert_eq!(check!(out.lstat()).kind, FileType::Symlink);
@@ -1675,7 +1684,7 @@ mod tests {
16751684
fn symlink_noexist() {
16761685
let tmpdir = tmpdir();
16771686
// symlinks can point to things that don't exist
1678-
check!(fs::soft_link(&tmpdir.join("foo"), &tmpdir.join("bar")));
1687+
check!(fs::symlink(&tmpdir.join("foo"), &tmpdir.join("bar")));
16791688
assert_eq!(check!(fs::read_link(&tmpdir.join("bar"))),
16801689
tmpdir.join("foo"));
16811690
}

src/libstd/old_io/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ pub fn link(src: &Path, dst: &Path) -> IoResult<()> {
498498

499499
/// Creates a new symbolic link on the filesystem. The `dst` path will be a
500500
/// symlink pointing to the `src` path.
501-
#[deprecated(since = "1.0.0", reason = "replaced with std::fs::soft_link")]
501+
#[deprecated(since = "1.0.0", reason = "replaced with std::fs::symlink")]
502502
#[unstable(feature = "old_io")]
503503
pub fn symlink(src: &Path, dst: &Path) -> IoResult<()> {
504504
fs_imp::symlink(src, dst)

0 commit comments

Comments
 (0)