File tree 2 files changed +11
-0
lines changed
2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -2083,6 +2083,15 @@ mod tests {
2083
2083
check ! ( fs:: create_dir_all( & path. join( "a/" ) ) ) ;
2084
2084
}
2085
2085
2086
+ #[ test]
2087
+ fn canonicalize_works_simple ( ) {
2088
+ let tmpdir = tmpdir ( ) ;
2089
+ let tmpdir = fs:: canonicalize ( tmpdir. path ( ) ) . unwrap ( ) ;
2090
+ let file = tmpdir. join ( "test" ) ;
2091
+ File :: create ( & file) . unwrap ( ) ;
2092
+ assert_eq ! ( fs:: canonicalize( & file) . unwrap( ) , file) ;
2093
+ }
2094
+
2086
2095
#[ test]
2087
2096
#[ cfg( not( windows) ) ]
2088
2097
fn realpath_works ( ) {
Original file line number Diff line number Diff line change @@ -583,6 +583,8 @@ fn get_path(f: &File) -> io::Result<PathBuf> {
583
583
pub fn canonicalize ( p : & Path ) -> io:: Result < PathBuf > {
584
584
let mut opts = OpenOptions :: new ( ) ;
585
585
opts. read ( true ) ;
586
+ // This flag is so we can open directories too
587
+ opts. flags_and_attributes ( c:: FILE_FLAG_BACKUP_SEMANTICS ) ;
586
588
let f = try!( File :: open ( p, & opts) ) ;
587
589
get_path ( & f)
588
590
}
You can’t perform that action at this time.
0 commit comments