1 /// Windows-specific extensions to wrappers in `fs_err` for `std::fs` types. 2 pub mod fs { 3 use crate::{SourceDestError, SourceDestErrorKind}; 4 use std::io; 5 use std::path::Path; 6 7 /// Creates a new symlink to a directory on the filesystem. 8 /// 9 /// Wrapper for [std::os::windows::fs::symlink_dir](https://doc.rust-lang.org/std/os/windows/fs/fn.symlink_dir.html) symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()>10 pub fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> { 11 let src = src.as_ref(); 12 let dst = dst.as_ref(); 13 std::os::windows::fs::symlink_dir(src, dst) 14 .map_err(|err| SourceDestError::build(err, SourceDestErrorKind::SymlinkDir, src, dst)) 15 } 16 17 /// Creates a new symlink to a non-directory file on the filesystem. 18 /// 19 /// Wrapper for [std::os::windows::fs::symlink_file](https://doc.rust-lang.org/std/os/windows/fs/fn.symlink_file.html) symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()>20 pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> { 21 let src = src.as_ref(); 22 let dst = dst.as_ref(); 23 std::os::windows::fs::symlink_file(src, dst) 24 .map_err(|err| SourceDestError::build(err, SourceDestErrorKind::SymlinkFile, src, dst)) 25 } 26 27 /// Wrapper for [`std::os::windows::fs::FileExt`](https://doc.rust-lang.org/std/os/windows/fs/trait.FileExt.html). 28 /// 29 /// The std traits might be extended in the future (See issue [#49961](https://github.com/rust-lang/rust/issues/49961#issuecomment-382751777)). 30 /// This trait is sealed and can not be implemented by other crates. 31 pub trait FileExt: crate::Sealed { 32 /// Wrapper for [`FileExt::seek_read`](https://doc.rust-lang.org/std/os/windows/fs/trait.FileExt.html#tymethod.seek_read) seek_read(&self, buf: &mut [u8], offset: u64) -> io::Result<usize>33 fn seek_read(&self, buf: &mut [u8], offset: u64) -> io::Result<usize>; 34 /// Wrapper for [`FileExt::seek_wriite`](https://doc.rust-lang.org/std/os/windows/fs/trait.FileExt.html#tymethod.seek_write) seek_write(&self, buf: &[u8], offset: u64) -> io::Result<usize>35 fn seek_write(&self, buf: &[u8], offset: u64) -> io::Result<usize>; 36 } 37 38 /// Wrapper for [`std::os::windows::fs::OpenOptionsExt`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html) 39 /// 40 /// The std traits might be extended in the future (See issue [#49961](https://github.com/rust-lang/rust/issues/49961#issuecomment-382751777)). 41 /// This trait is sealed and can not be implemented by other crates. 42 pub trait OpenOptionsExt: crate::Sealed { 43 /// Wrapper for [`OpenOptionsExt::access_mode`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.access_mode) access_mode(&mut self, access: u32) -> &mut Self44 fn access_mode(&mut self, access: u32) -> &mut Self; 45 /// Wrapper for [`OpenOptionsExt::share_mode`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.share_mode) share_mode(&mut self, val: u32) -> &mut Self46 fn share_mode(&mut self, val: u32) -> &mut Self; 47 /// Wrapper for [`OpenOptionsExt::custom_flags`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.custom_flags) custom_flags(&mut self, flags: u32) -> &mut Self48 fn custom_flags(&mut self, flags: u32) -> &mut Self; 49 /// Wrapper for [`OpenOptionsExt::attributes`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.attributes) attributes(&mut self, val: u32) -> &mut Self50 fn attributes(&mut self, val: u32) -> &mut Self; 51 /// Wrapper for [`OpenOptionsExt::security_qos_flags`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.security_qos_flags) security_qos_flags(&mut self, flags: u32) -> &mut Self52 fn security_qos_flags(&mut self, flags: u32) -> &mut Self; 53 } 54 } 55