@@ -1118,7 +1118,7 @@ impl OpenOptions {
11181118
11191119impl File {
11201120 pub fn open ( path : & Path , opts : & OpenOptions ) -> io:: Result < File > {
1121- run_path_with_cstr ( path, |path| File :: open_c ( path, opts) )
1121+ run_path_with_cstr ( path, & mut |path| File :: open_c ( path, opts) )
11221122 }
11231123
11241124 pub fn open_c ( path : & CStr , opts : & OpenOptions ) -> io:: Result < File > {
@@ -1394,7 +1394,7 @@ impl DirBuilder {
13941394 }
13951395
13961396 pub fn mkdir ( & self , p : & Path ) -> io:: Result < ( ) > {
1397- run_path_with_cstr ( p, |p| cvt ( unsafe { libc:: mkdir ( p. as_ptr ( ) , self . mode ) } ) . map ( |_| ( ) ) )
1397+ run_path_with_cstr ( p, & |p| cvt ( unsafe { libc:: mkdir ( p. as_ptr ( ) , self . mode ) } ) . map ( |_| ( ) ) )
13981398 }
13991399
14001400 pub fn set_mode ( & mut self , mode : u32 ) {
@@ -1575,7 +1575,7 @@ impl fmt::Debug for File {
15751575}
15761576
15771577pub fn readdir ( path : & Path ) -> io:: Result < ReadDir > {
1578- let ptr = run_path_with_cstr ( path, |p| unsafe { Ok ( libc:: opendir ( p. as_ptr ( ) ) ) } ) ?;
1578+ let ptr = run_path_with_cstr ( path, & |p| unsafe { Ok ( libc:: opendir ( p. as_ptr ( ) ) ) } ) ?;
15791579 if ptr. is_null ( ) {
15801580 Err ( Error :: last_os_error ( ) )
15811581 } else {
@@ -1586,27 +1586,27 @@ pub fn readdir(path: &Path) -> io::Result<ReadDir> {
15861586}
15871587
15881588pub fn unlink ( p : & Path ) -> io:: Result < ( ) > {
1589- run_path_with_cstr ( p, |p| cvt ( unsafe { libc:: unlink ( p. as_ptr ( ) ) } ) . map ( |_| ( ) ) )
1589+ run_path_with_cstr ( p, & |p| cvt ( unsafe { libc:: unlink ( p. as_ptr ( ) ) } ) . map ( |_| ( ) ) )
15901590}
15911591
15921592pub fn rename ( old : & Path , new : & Path ) -> io:: Result < ( ) > {
1593- run_path_with_cstr ( old, |old| {
1594- run_path_with_cstr ( new, |new| {
1593+ run_path_with_cstr ( old, & |old| {
1594+ run_path_with_cstr ( new, & |new| {
15951595 cvt ( unsafe { libc:: rename ( old. as_ptr ( ) , new. as_ptr ( ) ) } ) . map ( |_| ( ) )
15961596 } )
15971597 } )
15981598}
15991599
16001600pub fn set_perm ( p : & Path , perm : FilePermissions ) -> io:: Result < ( ) > {
1601- run_path_with_cstr ( p, |p| cvt_r ( || unsafe { libc:: chmod ( p. as_ptr ( ) , perm. mode ) } ) . map ( |_| ( ) ) )
1601+ run_path_with_cstr ( p, & |p| cvt_r ( || unsafe { libc:: chmod ( p. as_ptr ( ) , perm. mode ) } ) . map ( |_| ( ) ) )
16021602}
16031603
16041604pub fn rmdir ( p : & Path ) -> io:: Result < ( ) > {
1605- run_path_with_cstr ( p, |p| cvt ( unsafe { libc:: rmdir ( p. as_ptr ( ) ) } ) . map ( |_| ( ) ) )
1605+ run_path_with_cstr ( p, & |p| cvt ( unsafe { libc:: rmdir ( p. as_ptr ( ) ) } ) . map ( |_| ( ) ) )
16061606}
16071607
16081608pub fn readlink ( p : & Path ) -> io:: Result < PathBuf > {
1609- run_path_with_cstr ( p, |c_path| {
1609+ run_path_with_cstr ( p, & |c_path| {
16101610 let p = c_path. as_ptr ( ) ;
16111611
16121612 let mut buf = Vec :: with_capacity ( 256 ) ;
@@ -1635,16 +1635,16 @@ pub fn readlink(p: &Path) -> io::Result<PathBuf> {
16351635}
16361636
16371637pub fn symlink ( original : & Path , link : & Path ) -> io:: Result < ( ) > {
1638- run_path_with_cstr ( original, |original| {
1639- run_path_with_cstr ( link, |link| {
1638+ run_path_with_cstr ( original, & |original| {
1639+ run_path_with_cstr ( link, & |link| {
16401640 cvt ( unsafe { libc:: symlink ( original. as_ptr ( ) , link. as_ptr ( ) ) } ) . map ( |_| ( ) )
16411641 } )
16421642 } )
16431643}
16441644
16451645pub fn link ( original : & Path , link : & Path ) -> io:: Result < ( ) > {
1646- run_path_with_cstr ( original, |original| {
1647- run_path_with_cstr ( link, |link| {
1646+ run_path_with_cstr ( original, & |original| {
1647+ run_path_with_cstr ( link, & |link| {
16481648 cfg_if:: cfg_if! {
16491649 if #[ cfg( any( target_os = "vxworks" , target_os = "redox" , target_os = "android" , target_os = "espidf" , target_os = "horizon" , target_os = "vita" ) ) ] {
16501650 // VxWorks, Redox and ESP-IDF lack `linkat`, so use `link` instead. POSIX leaves
@@ -1678,7 +1678,7 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> {
16781678}
16791679
16801680pub fn stat ( p : & Path ) -> io:: Result < FileAttr > {
1681- run_path_with_cstr ( p, |p| {
1681+ run_path_with_cstr ( p, & |p| {
16821682 cfg_has_statx ! {
16831683 if let Some ( ret) = unsafe { try_statx(
16841684 libc:: AT_FDCWD ,
@@ -1697,7 +1697,7 @@ pub fn stat(p: &Path) -> io::Result<FileAttr> {
16971697}
16981698
16991699pub fn lstat ( p : & Path ) -> io:: Result < FileAttr > {
1700- run_path_with_cstr ( p, |p| {
1700+ run_path_with_cstr ( p, & |p| {
17011701 cfg_has_statx ! {
17021702 if let Some ( ret) = unsafe { try_statx(
17031703 libc:: AT_FDCWD ,
@@ -1716,7 +1716,7 @@ pub fn lstat(p: &Path) -> io::Result<FileAttr> {
17161716}
17171717
17181718pub fn canonicalize ( p : & Path ) -> io:: Result < PathBuf > {
1719- let r = run_path_with_cstr ( p, |path| unsafe {
1719+ let r = run_path_with_cstr ( p, & |path| unsafe {
17201720 Ok ( libc:: realpath ( path. as_ptr ( ) , ptr:: null_mut ( ) ) )
17211721 } ) ?;
17221722 if r. is_null ( ) {
@@ -1925,7 +1925,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
19251925}
19261926
19271927pub fn chown ( path : & Path , uid : u32 , gid : u32 ) -> io:: Result < ( ) > {
1928- run_path_with_cstr ( path, |path| {
1928+ run_path_with_cstr ( path, & |path| {
19291929 cvt ( unsafe { libc:: chown ( path. as_ptr ( ) , uid as libc:: uid_t , gid as libc:: gid_t ) } )
19301930 . map ( |_| ( ) )
19311931 } )
@@ -1937,15 +1937,15 @@ pub fn fchown(fd: c_int, uid: u32, gid: u32) -> io::Result<()> {
19371937}
19381938
19391939pub fn lchown ( path : & Path , uid : u32 , gid : u32 ) -> io:: Result < ( ) > {
1940- run_path_with_cstr ( path, |path| {
1940+ run_path_with_cstr ( path, & |path| {
19411941 cvt ( unsafe { libc:: lchown ( path. as_ptr ( ) , uid as libc:: uid_t , gid as libc:: gid_t ) } )
19421942 . map ( |_| ( ) )
19431943 } )
19441944}
19451945
19461946#[ cfg( not( any( target_os = "fuchsia" , target_os = "vxworks" ) ) ) ]
19471947pub fn chroot ( dir : & Path ) -> io:: Result < ( ) > {
1948- run_path_with_cstr ( dir, |dir| cvt ( unsafe { libc:: chroot ( dir. as_ptr ( ) ) } ) . map ( |_| ( ) ) )
1948+ run_path_with_cstr ( dir, & |dir| cvt ( unsafe { libc:: chroot ( dir. as_ptr ( ) ) } ) . map ( |_| ( ) ) )
19491949}
19501950
19511951pub use remove_dir_impl:: remove_dir_all;
@@ -2140,7 +2140,7 @@ mod remove_dir_impl {
21402140 if attr. file_type ( ) . is_symlink ( ) {
21412141 crate :: fs:: remove_file ( p)
21422142 } else {
2143- run_path_with_cstr ( p, |p| remove_dir_all_recursive ( None , & p) )
2143+ run_path_with_cstr ( p, & |p| remove_dir_all_recursive ( None , & p) )
21442144 }
21452145 }
21462146
0 commit comments