Skip to content

Commit 2d95b5b

Browse files
committed
Document when to use Windows' symlink_dir vs. symlink_file
It was previously unclear which should be used when.
1 parent 226e181 commit 2d95b5b

File tree

1 file changed

+20
-2
lines changed
  • library/std/src/os/windows

1 file changed

+20
-2
lines changed

library/std/src/os/windows/fs.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,20 @@ impl FileTypeExt for fs::FileType {
517517
}
518518
}
519519

520-
/// Creates a new file symbolic link on the filesystem.
520+
/// Creates a new symlink to a non-directory file on the filesystem.
521521
///
522522
/// The `link` path will be a file symbolic link pointing to the `original`
523523
/// path.
524524
///
525+
/// The `original` path should not be a directory or a symlink to a directory,
526+
/// otherwise the symlink will be broken. Use [`symlink_dir`] for directories.
527+
///
528+
/// This function currently corresponds to [`CreateSymbolicLinkW`][CreateSymbolicLinkW].
529+
/// Note that this [may change in the future][changes].
530+
///
531+
/// [CreateSymbolicLinkW]: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinkw
532+
/// [changes]: io#platform-specific-behavior
533+
///
525534
/// # Examples
526535
///
527536
/// ```no_run
@@ -537,11 +546,20 @@ pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io:
537546
sys::fs::symlink_inner(original.as_ref(), link.as_ref(), false)
538547
}
539548

540-
/// Creates a new directory symlink on the filesystem.
549+
/// Creates a new symlink to a directory on the filesystem.
541550
///
542551
/// The `link` path will be a directory symbolic link pointing to the `original`
543552
/// path.
544553
///
554+
/// The `original` path must be a directory or a symlink to a directory,
555+
/// otherwise the symlink will be broken. Use [`symlink_file`] for other files.
556+
///
557+
/// This function currently corresponds to [`CreateSymbolicLinkW`][CreateSymbolicLinkW].
558+
/// Note that this [may change in the future][changes].
559+
///
560+
/// [CreateSymbolicLinkW]: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinkw
561+
/// [changes]: io#platform-specific-behavior
562+
///
545563
/// # Examples
546564
///
547565
/// ```no_run

0 commit comments

Comments
 (0)