diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/fs-err/src/os/unix.rs | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/fs-err/src/os/unix.rs')
-rw-r--r-- | third_party/rust/fs-err/src/os/unix.rs | 38 |
1 files changed, 38 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;
+ }
+}
|