File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -2083,6 +2083,15 @@ mod tests {
20832083 check ! ( fs:: create_dir_all( & path. join( "a/" ) ) ) ;
20842084 }
20852085
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+
20862095 #[ test]
20872096 #[ cfg( not( windows) ) ]
20882097 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> {
583583pub fn canonicalize ( p : & Path ) -> io:: Result < PathBuf > {
584584 let mut opts = OpenOptions :: new ( ) ;
585585 opts. read ( true ) ;
586+ // This flag is so we can open directories too
587+ opts. flags_and_attributes ( c:: FILE_FLAG_BACKUP_SEMANTICS ) ;
586588 let f = try!( File :: open ( p, & opts) ) ;
587589 get_path ( & f)
588590}
You can’t perform that action at this time.
0 commit comments