| 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 |
/// Wrapper for [std::os::windows::fs::symlink_dir](https://doc.rust-lang.org/std/os/windows/fs/fn.symlink_dir.html) |
| 7 |
pub fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> { |
| 8 |
let src = src.as_ref(); |
| 9 |
let dst = dst.as_ref(); |
| 10 |
std::os::windows::fs::symlink_dir(src, dst) |
| 11 |
.map_err(|err| SourceDestError::build(err, SourceDestErrorKind::SymlinkDir, src, dst)) |
| 12 |
} |
| 13 |
|
| 14 |
/// Wrapper for [std::os::windows::fs::symlink_file](https://doc.rust-lang.org/std/os/windows/fs/fn.symlink_file.html) |
| 15 |
pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> { |
| 16 |
let src = src.as_ref(); |
| 17 |
let dst = dst.as_ref(); |
| 18 |
std::os::windows::fs::symlink_file(src, dst) |
| 19 |
.map_err(|err| SourceDestError::build(err, SourceDestErrorKind::SymlinkFile, src, dst)) |
| 20 |
} |
| 21 |
|
| 22 |
/// Wrapper for [`std::os::windows::fs::FileExt`](https://doc.rust-lang.org/std/os/windows/fs/trait.FileExt.html). |
| 23 |
/// |
| 24 |
/// The std traits might be extended in the future (See issue [#49961](https://github.com/rust-lang/rust/issues/49961#issuecomment-382751777)). |
| 25 |
/// This trait is sealed and can not be implemented by other crates. |
| 26 |
pub trait FileExt: crate::Sealed { |
| 27 |
/// Wrapper for [`FileExt::seek_read`](https://doc.rust-lang.org/std/os/windows/fs/trait.FileExt.html#tymethod.seek_read) |
| 28 |
fn seek_read(&self, buf: &mut [u8], offset: u64) -> io::Result<usize>; |
| 29 |
/// Wrapper for [`FileExt::seek_wriite`](https://doc.rust-lang.org/std/os/windows/fs/trait.FileExt.html#tymethod.seek_write) |
| 30 |
fn seek_write(&self, buf: &[u8], offset: u64) -> io::Result<usize>; |
| 31 |
} |
| 32 |
|
| 33 |
/// Wrapper for [`std::os::windows::fs::OpenOptionsExt`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html) |
| 34 |
/// |
| 35 |
/// The std traits might be extended in the future (See issue [#49961](https://github.com/rust-lang/rust/issues/49961#issuecomment-382751777)). |
| 36 |
/// This trait is sealed and can not be implemented by other crates. |
| 37 |
pub trait OpenOptionsExt: crate::Sealed { |
| 38 |
/// Wrapper for [`OpenOptionsExt::access_mode`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.access_mode) |
| 39 |
fn access_mode(&mut self, access: u32) -> &mut Self; |
| 40 |
/// Wrapper for [`OpenOptionsExt::share_mode`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.share_mode) |
| 41 |
fn share_mode(&mut self, val: u32) -> &mut Self; |
| 42 |
/// Wrapper for [`OpenOptionsExt::custom_flags`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.custom_flags) |
| 43 |
fn custom_flags(&mut self, flags: u32) -> &mut Self; |
| 44 |
/// Wrapper for [`OpenOptionsExt::attributes`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.attributes) |
| 45 |
fn attributes(&mut self, val: u32) -> &mut Self; |
| 46 |
/// Wrapper for [`OpenOptionsExt::security_qos_flags`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.security_qos_flags) |
| 47 |
fn security_qos_flags(&mut self, flags: u32) -> &mut Self; |
| 48 |
} |
| 49 |
} |