-mod internal {
- pub use std::os::windows::fs::{symlink_file, symlink_dir};
- pub use std::fs::remove_dir as remove_symlink_dir;
- use std::fs;
- use std::io;
- use std::mem;
- use std::path::Path;
-
- #[inline]
- pub fn symlink_auto<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
- if fs::metadata(src.as_ref())?.is_dir() {
- symlink_dir(src.as_ref(), dst.as_ref())
- } else {
- symlink_file(src.as_ref(), dst.as_ref())
- }
- }
-
- // Copied from the Rust standard library, src/libstd/sys/windows/fs.rs, because it’s an
- // implementation detail that isn’t currently exposed in the public interface; I decided to do
- // it this way rather than depending on the Debug implementation (which likewise could change).
- #[derive(PartialEq)]
- enum FileType {
- Dir, File, SymlinkFile, SymlinkDir, ReparsePoint, MountPoint,
- }
-
- impl FileType {
- pub fn is_symlink_dir(&self) -> bool {
- *self == FileType::SymlinkDir || *self == FileType::MountPoint
- }
- }