@@ -6,6 +6,7 @@ use crate::sys;
6
6
use crate :: { Error , NixPath , Result } ;
7
7
use cfg_if:: cfg_if;
8
8
use std:: ffi;
9
+ use std:: os:: unix:: io:: AsFd ;
9
10
use std:: os:: unix:: io:: { AsRawFd , IntoRawFd , RawFd } ;
10
11
use std:: ptr;
11
12
@@ -39,18 +40,18 @@ impl Dir {
39
40
mode : sys:: stat:: Mode ,
40
41
) -> Result < Self > {
41
42
let fd = fcntl:: open ( path, oflag, mode) ?;
42
- Dir :: from_fd ( fd)
43
+ Dir :: from_fd ( fd. into_raw_fd ( ) )
43
44
}
44
45
45
46
/// Opens the given path as with `fcntl::openat`.
46
- pub fn openat < P : ?Sized + NixPath > (
47
- dirfd : RawFd ,
47
+ pub fn openat < Fd : AsFd , P : ?Sized + NixPath > (
48
+ dirfd : & Fd ,
48
49
path : & P ,
49
50
oflag : OFlag ,
50
51
mode : sys:: stat:: Mode ,
51
52
) -> Result < Self > {
52
53
let fd = fcntl:: openat ( dirfd, path, oflag, mode) ?;
53
- Dir :: from_fd ( fd)
54
+ Dir :: from_fd ( fd. into_raw_fd ( ) )
54
55
}
55
56
56
57
/// Converts from a descriptor-based object, closing the descriptor on success or failure.
@@ -240,7 +241,7 @@ impl Entry {
240
241
241
242
/// Returns the bare file name of this directory entry without any other leading path component.
242
243
pub fn file_name ( & self ) -> & ffi:: CStr {
243
- unsafe { :: std :: ffi:: CStr :: from_ptr ( self . 0 . d_name . as_ptr ( ) ) }
244
+ unsafe { ffi:: CStr :: from_ptr ( self . 0 . d_name . as_ptr ( ) ) }
244
245
}
245
246
246
247
/// Returns the type of this directory entry, if known.
0 commit comments