1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
use std::fs; /// A builder used to create directories in various manners. /// /// This corresponds to [`std::fs::DirBuilder`]. /// /// Unlike `std::fs::DirBuilder`, this API has no `DirBuilder::create`, because /// creating directories requires a capability. Use /// [`Dir::create_with_dir_builder`] instead. /// /// [`std::fs::DirBuilder`]: https://doc.rust-lang.org/std/fs/struct.DirBuilder.html /// [`Dir::create_with_dir_builder`]: https://doc.rust-lang.org/std/fs/struct.Dir.html#method.create_with_dir_builder pub struct DirBuilder { std: fs::DirBuilder, } impl DirBuilder { /// Constructs a new instance of `Self` from the given `std::fs::File`. pub fn from_std(std: fs::DirBuilder) -> Self { Self { std } } /// Creates a new set of options with default mode/security settings for all platforms and also non-recursive. /// /// This corresponds to [`std::fs::DirBuilder::new`]. /// /// [`std::fs::DirBuilder::new`]: https://doc.rust-lang.org/std/fs/struct.DirBuilder.html#method.new #[allow(clippy::new_without_default)] #[inline] pub fn new() -> Self { Self { std: fs::DirBuilder::new(), } } /// Indicates that directories should be created recursively, creating all parent directories. /// /// This corresponds to [`std::fs::DirBuilder::recursive`]. /// /// [`std::fs::DirBuilder::recursive`]: https://doc.rust-lang.org/std/fs/struct.DirBuilder.html#method.recursive #[inline] pub fn recursive(&mut self, recursive: bool) -> &mut Self { self.std.recursive(recursive); self } } #[cfg(unix)] impl std::os::unix::fs::DirBuilderExt for DirBuilder { #[inline] fn mode(&mut self, mode: u32) -> &mut Self { self.std.mode(mode); self } } // TODO: impl Debug for DirBuilder? But don't expose DirBuilder's path...