Function symlink::symlink_auto [−][src]
pub fn symlink_auto<P: AsRef<Path>, Q: AsRef<Path>>(
src: P,
dst: Q
) -> Result<()>
Create a symlink (non-preferred way).
On Windows, file and directory symlinks are created by distinct methods; to cope with that, this function checks whether the destination is a file or a folder and creates the appropriate type of symlink based on that result. Therefore, if the destination does not exist or if you do not have permission to fetch its metadata, this will return an error on Windows.
On Unix platforms there is no distinction, so this isn’t magic: it’s precisely equivalent to
calling std::os::unix::fs::symlink
.
A note on using this function
Because this is slightly less efficient and more hazardous on Windows, you should prefer to use
symlink_file
or symlink_dir
instead. Only
use this if you don’t know or care whether the destination is a file or a directory (but even
then, you do need to know that it exists).
Errors
An error will be returned if the symlink cannot be created, or—on Windows—if the destination does not exist or cannot be read.