File tree 2 files changed +32
-0
lines changed 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,32 @@ impl ChildPath {
96
96
}
97
97
}
98
98
99
+ /// Create empty directories at [`ChildPath`].
100
+ ///
101
+ /// [`ChildPath`]: struct.ChildPath.html
102
+ pub trait PathCreateDir {
103
+ /// Create an empty file at [`ChildPath`].
104
+ ///
105
+ /// # Examples
106
+ ///
107
+ /// ```rust
108
+ /// use assert_fs::prelude::*;
109
+ ///
110
+ /// let temp = assert_fs::TempDir::new().unwrap();
111
+ /// temp.child("subdir").create_dir_all().unwrap();
112
+ /// temp.close().unwrap();
113
+ /// ```
114
+ ///
115
+ /// [`ChildPath`]: struct.ChildPath.html
116
+ fn create_dir_all ( & self ) -> io:: Result < ( ) > ;
117
+ }
118
+
119
+ impl PathCreateDir for ChildPath {
120
+ fn create_dir_all ( & self ) -> io:: Result < ( ) > {
121
+ create_dir_all ( self . path ( ) )
122
+ }
123
+ }
124
+
99
125
/// Create empty files at [`ChildPath`].
100
126
///
101
127
/// [`ChildPath`]: struct.ChildPath.html
@@ -222,6 +248,11 @@ impl PathCopy for ChildPath {
222
248
}
223
249
}
224
250
251
+ fn create_dir_all ( path : & path:: Path ) -> io:: Result < ( ) > {
252
+ fs:: create_dir_all ( path) ?;
253
+ Ok ( ( ) )
254
+ }
255
+
225
256
fn touch ( path : & path:: Path ) -> io:: Result < ( ) > {
226
257
fs:: File :: create ( path) ?;
227
258
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ pub use fixture::TempDir;
78
78
/// Extension traits that are useful to have available.
79
79
pub mod prelude {
80
80
pub use assert:: PathAssert ;
81
+ pub use fixture:: PathCreateDir ;
81
82
pub use fixture:: FileTouch ;
82
83
pub use fixture:: FileWriteBin ;
83
84
pub use fixture:: FileWriteStr ;
You can’t perform that action at this time.
0 commit comments