File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,10 @@ use std::fs;
7
7
use std::fs::{File, OpenOptions};
8
8
use std::io;
9
9
use std::io::prelude::*;
10
+ #[cfg(target_os = "unix")]
10
11
use std::os::unix;
12
+ #[cfg(target_os = "windows")]
13
+ use std::os::windows;
11
14
use std::path::Path;
12
15
13
16
// A simple implementation of `% cat path`
@@ -62,11 +65,16 @@ fn main() {
62
65
63
66
println!("`ln -s ../b.txt a/c/b.txt`");
64
67
// Create a symbolic link, returns `io::Result<()>`
65
- if cfg!(target_family = "unix") {
68
+ #[ cfg(target_os = "unix")] {
66
69
unix::fs::symlink("../b.txt", "a/c/b.txt").unwrap_or_else(|why| {
67
70
println!("! {:?}", why.kind());
68
71
});
69
72
}
73
+ #[cfg(target_os = "windows")] {
74
+ windows::fs::symlink_file("../b.txt", "a/c/b.txt").unwrap_or_else(|why| {
75
+ println!("! {:?}", why.to_string());
76
+ });
77
+ }
70
78
71
79
println!("`cat a/c/b.txt`");
72
80
match cat(&Path::new("a/c/b.txt")) {
You can’t perform that action at this time.
0 commit comments