File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ use walkdir::WalkDir;
18
18
use std:: os:: unix:: fs:: OpenOptionsExt ;
19
19
// FIXME: what about Windows? Are default ACLs executable?
20
20
21
+ #[ cfg( unix) ]
22
+ use std:: os:: unix:: fs:: symlink as symlink_file;
23
+ #[ cfg( windows) ]
24
+ use std:: os:: windows:: fs:: symlink_file;
25
+
21
26
use errors:: * ;
22
27
23
28
/// Convert a `&Path` to a UTF-8 `&str`
@@ -29,9 +34,15 @@ pub fn path_to_str(path: &Path) -> Result<&str> {
29
34
30
35
/// Wrap `fs::copy` with a nicer error message
31
36
pub fn copy < P : AsRef < Path > , Q : AsRef < Path > > ( from : P , to : Q ) -> Result < u64 > {
32
- fs:: copy ( & from, & to)
33
- . chain_err ( || format ! ( "failed to copy '{}' to '{}'" ,
34
- from. as_ref( ) . display( ) , to. as_ref( ) . display( ) ) )
37
+ if fs:: symlink_metadata ( & from) ?. file_type ( ) . is_symlink ( ) {
38
+ let link = fs:: read_link ( & from) ?;
39
+ symlink_file ( link, & to) ?;
40
+ Ok ( 0 )
41
+ } else {
42
+ fs:: copy ( & from, & to)
43
+ . chain_err ( || format ! ( "failed to copy '{}' to '{}'" ,
44
+ from. as_ref( ) . display( ) , to. as_ref( ) . display( ) ) )
45
+ }
35
46
}
36
47
37
48
/// Wrap `fs::create_dir` with a nicer error message
You can’t perform that action at this time.
0 commit comments