@@ -110,7 +110,7 @@ pub fn copy_files_except_ext(
110
110
111
111
for entry in fs:: read_dir ( from) ? {
112
112
let entry = entry?;
113
- let metadata = entry. metadata ( ) ?;
113
+ let metadata = entry. path ( ) . metadata ( ) ?;
114
114
115
115
// If the entry is a dir and the recursive option is enabled, call itself
116
116
if metadata. is_dir ( ) && recursive {
@@ -187,7 +187,17 @@ pub fn get_404_output_file(input_404: &Option<String>) -> String {
187
187
#[ cfg( test) ]
188
188
mod tests {
189
189
use super :: copy_files_except_ext;
190
- use std:: fs;
190
+ use std:: { fs, io:: Result , path:: Path } ;
191
+
192
+ #[ cfg( target_os = "windows" ) ]
193
+ fn symlink < P : AsRef < Path > , Q : AsRef < Path > > ( src : P , dst : Q ) -> Result < ( ) > {
194
+ std:: os:: windows:: fs:: symlink_file ( src, dst)
195
+ }
196
+
197
+ #[ cfg( not( target_os = "windows" ) ) ]
198
+ fn symlink < P : AsRef < Path > , Q : AsRef < Path > > ( src : P , dst : Q ) -> Result < ( ) > {
199
+ std:: os:: unix:: fs:: symlink ( src, dst)
200
+ }
191
201
192
202
#[ test]
193
203
fn copy_files_except_ext_test ( ) {
@@ -218,6 +228,12 @@ mod tests {
218
228
if let Err ( err) = fs:: File :: create ( & tmp. path ( ) . join ( "sub_dir_exists/file.txt" ) ) {
219
229
panic ! ( "Could not create sub_dir_exists/file.txt: {}" , err) ;
220
230
}
231
+ if let Err ( err) = symlink (
232
+ & tmp. path ( ) . join ( "file.png" ) ,
233
+ & tmp. path ( ) . join ( "symlink.png" ) ,
234
+ ) {
235
+ panic ! ( "Could not symlink file.png: {}" , err) ;
236
+ }
221
237
222
238
// Create output dir
223
239
if let Err ( err) = fs:: create_dir ( & tmp. path ( ) . join ( "output" ) ) {
@@ -249,5 +265,8 @@ mod tests {
249
265
if !( & tmp. path ( ) . join ( "output/sub_dir_exists/file.txt" ) ) . exists ( ) {
250
266
panic ! ( "output/sub_dir/file.png should exist" )
251
267
}
268
+ if !( & tmp. path ( ) . join ( "output/symlink.png" ) ) . exists ( ) {
269
+ panic ! ( "output/symlink.png should exist" )
270
+ }
252
271
}
253
272
}
0 commit comments