summaryrefslogtreecommitdiffstats
path: root/third_party/rust/fs-err/src/os
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /third_party/rust/fs-err/src/os
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/fs-err/src/os')
-rw-r--r--third_party/rust/fs-err/src/os/unix.rs38
-rw-r--r--third_party/rust/fs-err/src/os/windows.rs49
2 files changed, 87 insertions, 0 deletions
diff --git a/third_party/rust/fs-err/src/os/unix.rs b/third_party/rust/fs-err/src/os/unix.rs
new file mode 100644
index 0000000000..ad7c488c4d
--- /dev/null
+++ b/third_party/rust/fs-err/src/os/unix.rs
@@ -0,0 +1,38 @@
+/// Unix-specific extensions to wrappers in `fs_err` for `std::fs` types.
+pub mod fs {
+ use std::io;
+ use std::path::Path;
+
+ use crate::SourceDestError;
+ use crate::SourceDestErrorKind;
+
+ /// Wrapper for [`std::os::unix::fs::symlink`](https://doc.rust-lang.org/std/os/unix/fs/fn.symlink.html)
+ pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
+ let src = src.as_ref();
+ let dst = dst.as_ref();
+ std::os::unix::fs::symlink(src, dst)
+ .map_err(|err| SourceDestError::build(err, SourceDestErrorKind::Symlink, src, dst))
+ }
+
+ /// Wrapper for [`std::os::unix::fs::FileExt`](https://doc.rust-lang.org/std/os/unix/fs/trait.FileExt.html).
+ ///
+ /// The std traits might be extended in the future (See issue [#49961](https://github.com/rust-lang/rust/issues/49961#issuecomment-382751777)).
+ /// This trait is sealed and can not be implemented by other crates.
+ pub trait FileExt: crate::Sealed {
+ /// Wrapper for [`FileExt::read_at`](https://doc.rust-lang.org/std/os/unix/fs/trait.FileExt.html#tymethod.read_at)
+ fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize>;
+ /// Wrapper for [`FileExt::write_at`](https://doc.rust-lang.org/std/os/unix/fs/trait.FileExt.html#tymethod.write_at)
+ fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize>;
+ }
+
+ /// Wrapper for [`std::os::unix::fs::OpenOptionsExt`](https://doc.rust-lang.org/std/os/unix/fs/trait.OpenOptionsExt.html)
+ ///
+ /// The std traits might be extended in the future (See issue [#49961](https://github.com/rust-lang/rust/issues/49961#issuecomment-382751777)).
+ /// This trait is sealed and can not be implemented by other crates.
+ pub trait OpenOptionsExt: crate::Sealed {
+ /// Wrapper for [`OpenOptionsExt::mode`](https://doc.rust-lang.org/std/os/unix/fs/trait.OpenOptionsExt.html#tymethod.mode)
+ fn mode(&mut self, mode: u32) -> &mut Self;
+ /// Wrapper for [`OpenOptionsExt::custom_flags`](https://doc.rust-lang.org/std/os/unix/fs/trait.OpenOptionsExt.html#tymethod.custom_flags)
+ fn custom_flags(&mut self, flags: i32) -> &mut Self;
+ }
+}
diff --git a/third_party/rust/fs-err/src/os/windows.rs b/third_party/rust/fs-err/src/os/windows.rs
new file mode 100644
index 0000000000..f559856237
--- /dev/null
+++ b/third_party/rust/fs-err/src/os/windows.rs
@@ -0,0 +1,49 @@
+/// Windows-specific extensions to wrappers in `fs_err` for `std::fs` types.
+pub mod fs {
+ use crate::{SourceDestError, SourceDestErrorKind};
+ use std::io;
+ use std::path::Path;
+ /// Wrapper for [std::os::windows::fs::symlink_dir](https://doc.rust-lang.org/std/os/windows/fs/fn.symlink_dir.html)
+ pub fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
+ let src = src.as_ref();
+ let dst = dst.as_ref();
+ std::os::windows::fs::symlink_dir(src, dst)
+ .map_err(|err| SourceDestError::build(err, SourceDestErrorKind::SymlinkDir, src, dst))
+ }
+
+ /// Wrapper for [std::os::windows::fs::symlink_file](https://doc.rust-lang.org/std/os/windows/fs/fn.symlink_file.html)
+ pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
+ let src = src.as_ref();
+ let dst = dst.as_ref();
+ std::os::windows::fs::symlink_file(src, dst)
+ .map_err(|err| SourceDestError::build(err, SourceDestErrorKind::SymlinkFile, src, dst))
+ }
+
+ /// Wrapper for [`std::os::windows::fs::FileExt`](https://doc.rust-lang.org/std/os/windows/fs/trait.FileExt.html).
+ ///
+ /// The std traits might be extended in the future (See issue [#49961](https://github.com/rust-lang/rust/issues/49961#issuecomment-382751777)).
+ /// This trait is sealed and can not be implemented by other crates.
+ pub trait FileExt: crate::Sealed {
+ /// Wrapper for [`FileExt::seek_read`](https://doc.rust-lang.org/std/os/windows/fs/trait.FileExt.html#tymethod.seek_read)
+ fn seek_read(&self, buf: &mut [u8], offset: u64) -> io::Result<usize>;
+ /// Wrapper for [`FileExt::seek_wriite`](https://doc.rust-lang.org/std/os/windows/fs/trait.FileExt.html#tymethod.seek_write)
+ fn seek_write(&self, buf: &[u8], offset: u64) -> io::Result<usize>;
+ }
+
+ /// Wrapper for [`std::os::windows::fs::OpenOptionsExt`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html)
+ ///
+ /// The std traits might be extended in the future (See issue [#49961](https://github.com/rust-lang/rust/issues/49961#issuecomment-382751777)).
+ /// This trait is sealed and can not be implemented by other crates.
+ pub trait OpenOptionsExt: crate::Sealed {
+ /// Wrapper for [`OpenOptionsExt::access_mode`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.access_mode)
+ fn access_mode(&mut self, access: u32) -> &mut Self;
+ /// Wrapper for [`OpenOptionsExt::share_mode`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.share_mode)
+ fn share_mode(&mut self, val: u32) -> &mut Self;
+ /// Wrapper for [`OpenOptionsExt::custom_flags`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.custom_flags)
+ fn custom_flags(&mut self, flags: u32) -> &mut Self;
+ /// Wrapper for [`OpenOptionsExt::attributes`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.attributes)
+ fn attributes(&mut self, val: u32) -> &mut Self;
+ /// Wrapper for [`OpenOptionsExt::security_qos_flags`](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.security_qos_flags)
+ fn security_qos_flags(&mut self, flags: u32) -> &mut Self;
+ }
+}