@@ -1118,7 +1118,7 @@ impl OpenOptions {
1118
1118
1119
1119
impl File {
1120
1120
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) )
1122
1122
}
1123
1123
1124
1124
pub fn open_c ( path : & CStr , opts : & OpenOptions ) -> io:: Result < File > {
@@ -1394,7 +1394,7 @@ impl DirBuilder {
1394
1394
}
1395
1395
1396
1396
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 ( |_| ( ) ) )
1398
1398
}
1399
1399
1400
1400
pub fn set_mode ( & mut self , mode : u32 ) {
@@ -1575,7 +1575,7 @@ impl fmt::Debug for File {
1575
1575
}
1576
1576
1577
1577
pub 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 ( ) ) ) } ) ?;
1579
1579
if ptr. is_null ( ) {
1580
1580
Err ( Error :: last_os_error ( ) )
1581
1581
} else {
@@ -1586,27 +1586,27 @@ pub fn readdir(path: &Path) -> io::Result<ReadDir> {
1586
1586
}
1587
1587
1588
1588
pub 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 ( |_| ( ) ) )
1590
1590
}
1591
1591
1592
1592
pub 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| {
1595
1595
cvt ( unsafe { libc:: rename ( old. as_ptr ( ) , new. as_ptr ( ) ) } ) . map ( |_| ( ) )
1596
1596
} )
1597
1597
} )
1598
1598
}
1599
1599
1600
1600
pub 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 ( |_| ( ) ) )
1602
1602
}
1603
1603
1604
1604
pub 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 ( |_| ( ) ) )
1606
1606
}
1607
1607
1608
1608
pub fn readlink ( p : & Path ) -> io:: Result < PathBuf > {
1609
- run_path_with_cstr ( p, |c_path| {
1609
+ run_path_with_cstr ( p, & |c_path| {
1610
1610
let p = c_path. as_ptr ( ) ;
1611
1611
1612
1612
let mut buf = Vec :: with_capacity ( 256 ) ;
@@ -1635,16 +1635,16 @@ pub fn readlink(p: &Path) -> io::Result<PathBuf> {
1635
1635
}
1636
1636
1637
1637
pub 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| {
1640
1640
cvt ( unsafe { libc:: symlink ( original. as_ptr ( ) , link. as_ptr ( ) ) } ) . map ( |_| ( ) )
1641
1641
} )
1642
1642
} )
1643
1643
}
1644
1644
1645
1645
pub 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| {
1648
1648
cfg_if:: cfg_if! {
1649
1649
if #[ cfg( any( target_os = "vxworks" , target_os = "redox" , target_os = "android" , target_os = "espidf" , target_os = "horizon" , target_os = "vita" ) ) ] {
1650
1650
// 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<()> {
1678
1678
}
1679
1679
1680
1680
pub fn stat ( p : & Path ) -> io:: Result < FileAttr > {
1681
- run_path_with_cstr ( p, |p| {
1681
+ run_path_with_cstr ( p, & |p| {
1682
1682
cfg_has_statx ! {
1683
1683
if let Some ( ret) = unsafe { try_statx(
1684
1684
libc:: AT_FDCWD ,
@@ -1697,7 +1697,7 @@ pub fn stat(p: &Path) -> io::Result<FileAttr> {
1697
1697
}
1698
1698
1699
1699
pub fn lstat ( p : & Path ) -> io:: Result < FileAttr > {
1700
- run_path_with_cstr ( p, |p| {
1700
+ run_path_with_cstr ( p, & |p| {
1701
1701
cfg_has_statx ! {
1702
1702
if let Some ( ret) = unsafe { try_statx(
1703
1703
libc:: AT_FDCWD ,
@@ -1716,7 +1716,7 @@ pub fn lstat(p: &Path) -> io::Result<FileAttr> {
1716
1716
}
1717
1717
1718
1718
pub 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 {
1720
1720
Ok ( libc:: realpath ( path. as_ptr ( ) , ptr:: null_mut ( ) ) )
1721
1721
} ) ?;
1722
1722
if r. is_null ( ) {
@@ -1925,7 +1925,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
1925
1925
}
1926
1926
1927
1927
pub fn chown ( path : & Path , uid : u32 , gid : u32 ) -> io:: Result < ( ) > {
1928
- run_path_with_cstr ( path, |path| {
1928
+ run_path_with_cstr ( path, & |path| {
1929
1929
cvt ( unsafe { libc:: chown ( path. as_ptr ( ) , uid as libc:: uid_t , gid as libc:: gid_t ) } )
1930
1930
. map ( |_| ( ) )
1931
1931
} )
@@ -1937,15 +1937,15 @@ pub fn fchown(fd: c_int, uid: u32, gid: u32) -> io::Result<()> {
1937
1937
}
1938
1938
1939
1939
pub fn lchown ( path : & Path , uid : u32 , gid : u32 ) -> io:: Result < ( ) > {
1940
- run_path_with_cstr ( path, |path| {
1940
+ run_path_with_cstr ( path, & |path| {
1941
1941
cvt ( unsafe { libc:: lchown ( path. as_ptr ( ) , uid as libc:: uid_t , gid as libc:: gid_t ) } )
1942
1942
. map ( |_| ( ) )
1943
1943
} )
1944
1944
}
1945
1945
1946
1946
#[ cfg( not( any( target_os = "fuchsia" , target_os = "vxworks" ) ) ) ]
1947
1947
pub 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 ( |_| ( ) ) )
1949
1949
}
1950
1950
1951
1951
pub use remove_dir_impl:: remove_dir_all;
@@ -2140,7 +2140,7 @@ mod remove_dir_impl {
2140
2140
if attr. file_type ( ) . is_symlink ( ) {
2141
2141
crate :: fs:: remove_file ( p)
2142
2142
} 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) )
2144
2144
}
2145
2145
}
2146
2146
0 commit comments