@@ -54,8 +54,8 @@ use libc::{c_int, mode_t};
54
54
#[ cfg( target_os = "android" ) ]
55
55
use libc:: {
56
56
dirent as dirent64, fstat as fstat64, fstatat as fstatat64, ftruncate64, lseek64,
57
- lstat as lstat64, off64_t, open as open64, openat as openat64, renameat, stat as stat64 ,
58
- unlinkat,
57
+ lstat as lstat64, mkdirat , off64_t, open as open64, openat as openat64, renameat,
58
+ stat as stat64 , unlinkat,
59
59
} ;
60
60
#[ cfg( not( any(
61
61
all( target_os = "linux" , not( target_env = "musl" ) ) ,
@@ -65,7 +65,7 @@ use libc::{
65
65
) ) ) ]
66
66
use libc:: {
67
67
dirent as dirent64, fstat as fstat64, ftruncate as ftruncate64, lseek as lseek64,
68
- lstat as lstat64, off_t as off64_t, open as open64, openat as openat64, renameat,
68
+ lstat as lstat64, mkdirat , off_t as off64_t, open as open64, openat as openat64, renameat,
69
69
stat as stat64, unlinkat,
70
70
} ;
71
71
#[ cfg( any(
@@ -74,8 +74,8 @@ use libc::{
74
74
target_os = "hurd"
75
75
) ) ]
76
76
use libc:: {
77
- dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, openat64, renameat, stat64 ,
78
- unlinkat,
77
+ dirent64, fstat64, ftruncate64, lseek64, lstat64, mkdirat , off64_t, open64, openat64, renameat,
78
+ stat64 , unlinkat,
79
79
} ;
80
80
81
81
use crate :: ffi:: { CStr , OsStr , OsString } ;
@@ -294,6 +294,10 @@ impl Dir {
294
294
run_path_with_cstr ( path. as_ref ( ) , & |path| self . open_c ( path, opts) )
295
295
}
296
296
297
+ pub fn create_dir < P : AsRef < Path > > ( & self , path : P ) -> io:: Result < ( ) > {
298
+ run_path_with_cstr ( path. as_ref ( ) , & |path| self . create_dir_c ( path) )
299
+ }
300
+
297
301
pub fn remove_file < P : AsRef < Path > > ( & self , path : P ) -> io:: Result < ( ) > {
298
302
run_path_with_cstr ( path. as_ref ( ) , & |path| self . remove_c ( path, false ) )
299
303
}
@@ -334,6 +338,10 @@ impl Dir {
334
338
Ok ( Self ( unsafe { OwnedFd :: from_raw_fd ( fd) } ) )
335
339
}
336
340
341
+ pub fn create_dir_c ( & self , path : & CStr ) -> io:: Result < ( ) > {
342
+ cvt ( unsafe { mkdirat ( self . 0 . as_raw_fd ( ) , path. as_ptr ( ) , 0o777 ) } ) . map ( |_| ( ) )
343
+ }
344
+
337
345
pub fn remove_c ( & self , path : & CStr , remove_dir : bool ) -> io:: Result < ( ) > {
338
346
cvt ( unsafe {
339
347
unlinkat (
0 commit comments