about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyan Levick <rylev@users.noreply.github.com>2021-09-06 12:38:54 +0200
committerGitHub <noreply@github.com>2021-09-06 12:38:54 +0200
commit29a018def407dc623849c8db9443cdc45e464584 (patch)
treedb0de6021cd07ea1532d30cbb587c2bd8432ddb6
parentdcd0e1d835c16e41dab49037e7887cb80d746aef (diff)
parent2d95b5bce7119ae5549499083d24d143eae34d6b (diff)
downloadrust-29a018def407dc623849c8db9443cdc45e464584.tar.gz
rust-29a018def407dc623849c8db9443cdc45e464584.zip
Rollup merge of #88647 - ChrisDenton:win-symlink-docs, r=joshtriplett
Document when to use Windows' `symlink_dir` vs. `symlink_file`

It was previously unclear why there are two functions and when they should be used.

Fixes: #88635
-rw-r--r--library/std/src/os/windows/fs.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/library/std/src/os/windows/fs.rs b/library/std/src/os/windows/fs.rs
index b20eafb4d53..71563a02dcb 100644
--- a/library/std/src/os/windows/fs.rs
+++ b/library/std/src/os/windows/fs.rs
@@ -517,11 +517,20 @@ impl FileTypeExt for fs::FileType {
     }
 }
 
-/// Creates a new file symbolic link on the filesystem.
+/// Creates a new symlink to a non-directory file on the filesystem.
 ///
 /// The `link` path will be a file symbolic link pointing to the `original`
 /// path.
 ///
+/// The `original` path should not be a directory or a symlink to a directory,
+/// otherwise the symlink will be broken. Use [`symlink_dir`] for directories.
+///
+/// This function currently corresponds to [`CreateSymbolicLinkW`][CreateSymbolicLinkW].
+/// Note that this [may change in the future][changes].
+///
+/// [CreateSymbolicLinkW]: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinkw
+/// [changes]: io#platform-specific-behavior
+///
 /// # Examples
 ///
 /// ```no_run
@@ -537,11 +546,20 @@ pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io:
     sys::fs::symlink_inner(original.as_ref(), link.as_ref(), false)
 }
 
-/// Creates a new directory symlink on the filesystem.
+/// Creates a new symlink to a directory on the filesystem.
 ///
 /// The `link` path will be a directory symbolic link pointing to the `original`
 /// path.
 ///
+/// The `original` path must be a directory or a symlink to a directory,
+/// otherwise the symlink will be broken. Use [`symlink_file`] for other files.
+///
+/// This function currently corresponds to [`CreateSymbolicLinkW`][CreateSymbolicLinkW].
+/// Note that this [may change in the future][changes].
+///
+/// [CreateSymbolicLinkW]: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinkw
+/// [changes]: io#platform-specific-behavior
+///
 /// # Examples
 ///
 /// ```no_run