summaryrefslogtreecommitdiffstats
path: root/vendor/tempfile/src/file
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/tempfile/src/file
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/tempfile/src/file')
-rw-r--r--vendor/tempfile/src/file/imp/windows.rs3
-rw-r--r--vendor/tempfile/src/file/mod.rs96
2 files changed, 96 insertions, 3 deletions
diff --git a/vendor/tempfile/src/file/imp/windows.rs b/vendor/tempfile/src/file/imp/windows.rs
index cb2673b5a..9df65f9e8 100644
--- a/vendor/tempfile/src/file/imp/windows.rs
+++ b/vendor/tempfile/src/file/imp/windows.rs
@@ -75,9 +75,6 @@ pub fn keep(path: &Path) -> io::Result<()> {
}
pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<()> {
- // TODO: We should probably do this in one-shot using SetFileInformationByHandle but the API is
- // really painful.
-
unsafe {
let old_path_w = to_utf16(old_path);
let new_path_w = to_utf16(new_path);
diff --git a/vendor/tempfile/src/file/mod.rs b/vendor/tempfile/src/file/mod.rs
index 023acd26a..7be8dc8c2 100644
--- a/vendor/tempfile/src/file/mod.rs
+++ b/vendor/tempfile/src/file/mod.rs
@@ -916,12 +916,58 @@ impl<F: Read> Read for NamedTempFile<F> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.as_file_mut().read(buf).with_err_path(|| self.path())
}
+
+ fn read_vectored(&mut self, bufs: &mut [io::IoSliceMut<'_>]) -> io::Result<usize> {
+ self.as_file_mut()
+ .read_vectored(bufs)
+ .with_err_path(|| self.path())
+ }
+
+ fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
+ self.as_file_mut()
+ .read_to_end(buf)
+ .with_err_path(|| self.path())
+ }
+
+ fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
+ self.as_file_mut()
+ .read_to_string(buf)
+ .with_err_path(|| self.path())
+ }
+
+ fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
+ self.as_file_mut()
+ .read_exact(buf)
+ .with_err_path(|| self.path())
+ }
}
impl Read for &NamedTempFile<File> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.as_file().read(buf).with_err_path(|| self.path())
}
+
+ fn read_vectored(&mut self, bufs: &mut [io::IoSliceMut<'_>]) -> io::Result<usize> {
+ self.as_file()
+ .read_vectored(bufs)
+ .with_err_path(|| self.path())
+ }
+
+ fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
+ self.as_file()
+ .read_to_end(buf)
+ .with_err_path(|| self.path())
+ }
+
+ fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
+ self.as_file()
+ .read_to_string(buf)
+ .with_err_path(|| self.path())
+ }
+
+ fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
+ self.as_file().read_exact(buf).with_err_path(|| self.path())
+ }
}
impl<F: Write> Write for NamedTempFile<F> {
@@ -932,6 +978,24 @@ impl<F: Write> Write for NamedTempFile<F> {
fn flush(&mut self) -> io::Result<()> {
self.as_file_mut().flush().with_err_path(|| self.path())
}
+
+ fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result<usize> {
+ self.as_file_mut()
+ .write_vectored(bufs)
+ .with_err_path(|| self.path())
+ }
+
+ fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
+ self.as_file_mut()
+ .write_all(buf)
+ .with_err_path(|| self.path())
+ }
+
+ fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
+ self.as_file_mut()
+ .write_fmt(fmt)
+ .with_err_path(|| self.path())
+ }
}
impl Write for &NamedTempFile<File> {
@@ -942,6 +1006,20 @@ impl Write for &NamedTempFile<File> {
fn flush(&mut self) -> io::Result<()> {
self.as_file().flush().with_err_path(|| self.path())
}
+
+ fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result<usize> {
+ self.as_file()
+ .write_vectored(bufs)
+ .with_err_path(|| self.path())
+ }
+
+ fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
+ self.as_file().write_all(buf).with_err_path(|| self.path())
+ }
+
+ fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
+ self.as_file().write_fmt(fmt).with_err_path(|| self.path())
+ }
}
impl<F: Seek> Seek for NamedTempFile<F> {
@@ -956,6 +1034,13 @@ impl Seek for &NamedTempFile<File> {
}
}
+#[cfg(all(fd, unix))]
+impl<F: std::os::unix::io::AsFd> std::os::unix::io::AsFd for NamedTempFile<F> {
+ fn as_fd(&self) -> std::os::unix::io::BorrowedFd<'_> {
+ self.as_file().as_fd()
+ }
+}
+
#[cfg(unix)]
impl<F> std::os::unix::io::AsRawFd for NamedTempFile<F>
where
@@ -967,6 +1052,17 @@ where
}
}
+#[cfg(all(fd, windows))]
+impl<F> std::os::windows::io::AsHandle for NamedTempFile<F>
+where
+ F: std::os::windows::io::AsHandle,
+{
+ #[inline]
+ fn as_handle(&self) -> std::os::windows::io::BorrowedHandle<'_> {
+ self.as_file().as_handle()
+ }
+}
+
#[cfg(windows)]
impl<F> std::os::windows::io::AsRawHandle for NamedTempFile<F>
where