@@ -107,7 +107,6 @@ fn schedule_copies<
107
107
}
108
108
. map_io_err ( || format ! ( "Failed to read metadata for file: {from:?}" ) ) ?;
109
109
110
- #[ cfg( unix) ]
111
110
if from_metadata. is_dir ( ) {
112
111
use std:: os:: unix:: fs:: { DirBuilderExt , MetadataExt } ;
113
112
match fs:: DirBuilder :: new ( ) . mode ( from_metadata. mode ( ) ) . create ( & to) {
@@ -126,8 +125,19 @@ fn schedule_copies<
126
125
fs:: hard_link ( & link, & to)
127
126
. map_io_err ( || format ! ( "Failed to create hard link: {to:?} -> {link:?}" ) ) ?;
128
127
} else {
129
- std:: os:: unix:: fs:: symlink ( & link, & to)
130
- . map_io_err ( || format ! ( "Failed to create symlink: {to:?} -> {link:?}" ) ) ?;
128
+ let run = || {
129
+ #[ cfg( unix) ]
130
+ {
131
+ std:: os:: unix:: fs:: symlink ( & link, & to)
132
+ }
133
+ #[ cfg( windows) ]
134
+ if fs:: metadata ( & link) ?. file_type ( ) . is_dir ( ) {
135
+ std:: os:: windows:: fs:: symlink_dir ( & link, to)
136
+ } else {
137
+ std:: os:: windows:: fs:: symlink_file ( & link, to)
138
+ }
139
+ } ;
140
+ run ( ) . map_io_err ( || format ! ( "Failed to create symlink: {to:?} -> {link:?}" ) ) ?;
131
141
}
132
142
} else if hard_link {
133
143
match fs:: remove_file ( & to) {
@@ -139,13 +149,6 @@ fn schedule_copies<
139
149
} else {
140
150
fs:: copy ( & from, & to) . map_io_err ( || format ! ( "Failed to copy file: {from:?}" ) ) ?;
141
151
}
142
-
143
- #[ cfg( not( unix) ) ]
144
- if from_metadata. is_dir ( ) {
145
- copy. run ( ( from, to) ) ?;
146
- } else {
147
- fs:: copy ( & from, & to) . map_io_err ( || format ! ( "Failed to copy file: {from:?}" ) ) ?;
148
- }
149
152
}
150
153
Ok ( ( ) )
151
154
}
0 commit comments