commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
e284782c6c1c2f565af2ab9b5c0be9f9c5ed3607 | Steven Allen | 2025-05-10T16:41:41 | feat: allow creating spooled temporary files in a specific directory (#353) | diff --git a/src/lib.rs b/src/lib.rs
index 9fadcfe..701f402 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -215,7 +215,7 @@ pub use crate::dir::{tempdir, tempdir_in, TempDir};
pub use crate::file::{
tempfile, tempfile_in, NamedTempFile, PathPersistError, PersistError, TempPath,
};
-pub use crate::spooled::{spooled_... | 3 | 53 | 6 |
07edc310a5c8725346cd2bb2a5d065ff298f4fa0 | Steven Allen | 2025-05-10T16:26:45 | feat: implement `SpooledTempFile::into_file` (#352)
This makes it possible to convert a spooled temporary file into a
regular temporary file. | diff --git a/src/spooled.rs b/src/spooled.rs
index 9c9846c..e114827 100644
--- a/src/spooled.rs
+++ b/src/spooled.rs
@@ -55,6 +55,14 @@ pub fn spooled_tempfile(max_size: usize) -> SpooledTempFile {
SpooledTempFile::new(max_size)
}
+/// Write a cursor into a temporary file, returning the temporary file.
+fn curs... | 1 | 19 | 7 |
b1223553bb888e35bab7675fbac235e4be6eaf7e | Steven Allen | 2025-05-10T15:59:14 | fix: add must_use attribute to TempDir::keep (#351)
Mistakenly excluded from the previous PR. | diff --git a/src/dir/mod.rs b/src/dir/mod.rs
index fa8d7e4..837fd20 100644
--- a/src/dir/mod.rs
+++ b/src/dir/mod.rs
@@ -413,6 +413,7 @@ impl TempDir {
/// fs::remove_dir_all(tmp_path)?;
/// # Ok::<(), std::io::Error>(())
/// ```
+ #[must_use]
pub fn keep(self) -> PathBuf {
// Prevent th... | 1 | 1 | 0 |
cbd1e976e106d4a12432e124494f735bf40eafe2 | Steven Allen | 2025-05-10T15:51:56 | feat: rename `TempDir::into_path` to `TempDir::keep` (#349)
This unifies the `TempDir`/`NamedTempFile` method names to help avoid
confusion. | diff --git a/src/dir/mod.rs b/src/dir/mod.rs
index 4b0c37a..fa8d7e4 100644
--- a/src/dir/mod.rs
+++ b/src/dir/mod.rs
@@ -382,6 +382,13 @@ impl TempDir {
self.path.as_ref()
}
+ /// Deprecated alias for [`TempDir::keep`].
+ #[must_use]
+ #[deprecated = "use TempDir::keep()"]
+ pub fn into_path... | 3 | 13 | 6 |
23e9e59fa193e9e71b535c2c0d825d7e5e3f58b5 | Guillaume Gomez | 2025-05-07T13:43:46 | Build docs.rs documentation with rustdoc jump to def feature enabled (#348) | diff --git a/Cargo.toml b/Cargo.toml
index 1dc77e7..858fe3d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -42,3 +42,6 @@ default = ["getrandom"]
nightly = []
# DEPRECATED unstable feature, will be removed in the near future.
unstable-windows-keep-open-tempfile = []
+
+[package.metadata.docs.rs]
+rustdoc-args = ["--gen... | 1 | 3 | 0 |
61b4283c201c7fcb4d6921fa7de914c8af7b6281 | Steven Allen | 2025-03-14T00:29:16 | feat(windows): add a feature to immediate tempfile deletion (#340)
This adds a feature making it possible to disable the immediate deletion
of unnamed temporary files on windows (introduced in 461369fd).
Hopefully, this will fix #339. If so, I'll revert 461369fd entirely. | diff --git a/Cargo.toml b/Cargo.toml
index 84d3540..c69ad91 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -40,3 +40,6 @@ doc-comment = "0.3"
[features]
default = ["getrandom"]
nightly = []
+# Disables immediate deletion of newly opened tempfiles on windows, instead relying on the old
+# "delete on close" behavior. Thi... | 2 | 4 | 0 |
35c204d7c2202cddb9c0883a5dd04b83a0d9f67b | Steven Allen | 2025-03-06T19:19:04 | chore: remove cfg-if dependency (#338)
It's tiny, but we dont' really need it so we might as well trim our
dependencies down a bit. | diff --git a/Cargo.toml b/Cargo.toml
index b82a069..84d3540 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,7 +17,6 @@ repository = "https://github.com/Stebalien/tempfile"
description = "A library for managing temporary files and directories."
[dependencies]
-cfg-if = "1"
fastrand = "2.1.1"
# Not available in std... | 3 | 15 | 21 |
0e178694704dc68739a113c9eac1c108e02c49d2 | Steven Allen | 2025-03-06T18:53:13 | update rustix (#336)
* update rustix
* use renamat_with on apple operating systems | diff --git a/Cargo.toml b/Cargo.toml
index abfc7fe..43ba97c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,7 +26,7 @@ once_cell = { version = "1.19.0", default-features = false, features = ["std"] }
getrandom = { version = "0.3.0", default-features = false, optional = true }
[target.'cfg(any(unix, target_os = "was... | 2 | 12 | 4 |
6cf65365a4b785ed12d24e4a60b526e2c600210e | Steven Allen | 2025-02-21T19:02:34 | doc: fix markdown | diff --git a/src/file/mod.rs b/src/file/mod.rs
index d61764e..4eb6b67 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -728,8 +728,8 @@ impl<F> NamedTempFile<F> {
/// **Atomicity:** This method is not guaranteed to be atomic on all platforms, although it will
/// generally be atomic on Windows and modern... | 1 | 2 | 2 |
df39d15e3ffa1274331f98be94defd0732e5de41 | Steven Allen | 2025-02-21T18:59:48 | doc: document atomicity of `persist_noclobber` (#334)
fixes #333 | diff --git a/src/file/mod.rs b/src/file/mod.rs
index 42e5443..d61764e 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -675,7 +675,7 @@ impl<F> NamedTempFile<F> {
/// If this method fails, it will return `self` in the resulting
/// [`PersistError`].
///
- /// Note: Temporary files cannot be persi... | 1 | 12 | 4 |
78309ed599042fdbaf9630a579957ba2a710601f | Steven Allen | 2025-02-17T15:49:13 | fix: cast handle to the windows crate HANDLE (#332)
This isn't necessary for windows-sys 0.59, but is for windows-sys 0.52.
fixes #331 | diff --git a/src/file/imp/windows.rs b/src/file/imp/windows.rs
index 5cfc8d9..620b16e 100644
--- a/src/file/imp/windows.rs
+++ b/src/file/imp/windows.rs
@@ -31,7 +31,7 @@ fn delete_open_file(f: &File) -> io::Result<()> {
Flags: FILE_DISPOSITION_FLAG_DELETE | FILE_DISPOSITION_FLAG_POSIX_SEMANTICS,
... | 1 | 1 | 1 |
3718075691418ab4d4656c1f8277e17240036ee8 | Steven Allen | 2025-02-16T21:02:49 | doc: remove incorrect documentation about windows and open files
My knowledge here is clearly out of date. | diff --git a/src/file/mod.rs b/src/file/mod.rs
index 4a3025f..42e5443 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -399,35 +399,20 @@ impl AsRef<OsStr> for TempPath {
///
/// ### Windows
///
-/// On Windows, open files _can't_ be deleted. This removes most of the concerns
-/// around temporary file cleaners... | 1 | 3 | 18 |
461369fd358b374040ef99e1cdb260eb5dcd1f85 | Steven Allen | 2025-02-16T20:40:47 | feat: delete unnamed temporary files on windows immediately | diff --git a/src/file/imp/windows.rs b/src/file/imp/windows.rs
index e7f6038..5cfc8d9 100644
--- a/src/file/imp/windows.rs
+++ b/src/file/imp/windows.rs
@@ -8,9 +8,11 @@ use std::{io, iter};
use windows_sys::Win32::Foundation::{HANDLE, INVALID_HANDLE_VALUE};
use windows_sys::Win32::Storage::FileSystem::{
- MoveF... | 1 | 30 | 5 |
78d30a217f08f1b8e282556f3d9bbf84e84e89be | Steven Allen | 2025-02-16T20:22:20 | doc: clarify "inner file will be deleted" documentation (#329)
fixes #203 | diff --git a/src/file/mod.rs b/src/file/mod.rs
index 5907a79..4a3025f 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -823,9 +823,11 @@ impl<F> NamedTempFile<F> {
&mut self.file
}
- /// Convert the temporary file into a `std::fs::File`.
+ /// Turn this named temporary file into an "unnamed" ... | 1 | 6 | 4 |
0fe11c451e692703ad95f46cfdb91c50d60935f7 | Steven Allen | 2025-02-16T20:07:32 | doc: document how to "keep" temporary files/dirs after creation (#328)
fixes #315 | diff --git a/src/lib.rs b/src/lib.rs
index e0e0500..f5665a6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -466,7 +466,10 @@ impl<'a, 'b> Builder<'a, 'b> {
/// scope.
///
/// By default, the file/folder is automatically cleaned up in the destructor of
- /// [`NamedTempFile`]/[`TempDir`]. When `keep` is s... | 1 | 4 | 1 |
35e0629944a5a10a6f02b7960332a6a274b3ce0c | Steven Allen | 2025-02-15T22:34:43 | feat: simplify getrandom call (#325)
New in getrandom 0.3, we can now get numbers directly. On some systems,
this'll use special CPU instructions and can be instantaneous. We're not
using them for crypto, so I'm not going to be picky. | diff --git a/src/util.rs b/src/util.rs
index beb6b1f..5dc62a2 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -58,9 +58,8 @@ pub fn create_helper<R>(
any(windows, unix, target_os = "redox", target_os = "wasi")
))]
if i == 3 {
- let mut seed = [0u8; 8];
- if getrandom::... | 1 | 2 | 3 |
1e5059fe9f397f5ba67f2dd84452d8cb3bbc6cc0 | Steven Allen | 2025-02-15T22:25:23 | fix: handle TLS deallocation (#324)
Previously, creating a temporary file from a TLS destructor could panic
in fastrand (because the thread-local RNG may have been deallocated).
Now, we fork the RNG before we create each file, falling back on an RNG
with a static seed if the thread-local RNG has been deallocated.
Tw... | diff --git a/src/util.rs b/src/util.rs
index b3f625d..beb6b1f 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -4,7 +4,7 @@ use std::{io, iter::repeat_with};
use crate::error::IoResultExt;
-fn tmpname(prefix: &OsStr, suffix: &OsStr, rand_len: usize) -> OsString {
+fn tmpname(rng: &mut fastrand::Rng, prefix: &OsStr, s... | 2 | 24 | 15 |
c7b2e1af28e4d9dde36fda0579aad18ae7918a6c | Steven Allen | 2025-02-08T23:21:25 | chore: simplify reborrow | diff --git a/src/util.rs b/src/util.rs
index 98aa362..b3f625d 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -28,7 +28,7 @@ pub fn create_helper<R>(
) -> io::Result<R> {
// Make the path absolute. Otherwise, changing the current directory can invalidate a stored
// path (causing issues when cleaning up tempor... | 1 | 1 | 1 |
8afa07a8c1e36b32bdda914d0ab9adc55c376d6b | Steven Allen | 2025-02-08T23:17:03 | fix: always use absolute paths (#323)
We used absolute paths in the builder when making directories and in
`create_named` but this didn't cover `Builder::make_in` and technically
introduced a small race in some unnamed tempfile cases (i.e., when we
can't atomically create unnamed temporary files and need to create the... | diff --git a/src/file/mod.rs b/src/file/mod.rs
index 1cb2382..5907a79 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -1043,16 +1043,11 @@ impl<F: AsRawHandle> AsRawHandle for NamedTempFile<F> {
}
pub(crate) fn create_named(
- mut path: PathBuf,
+ path: PathBuf,
open_options: &mut OpenOptions,
... | 4 | 28 | 17 |
3693c016b50cb43331966c80a9020e6d5cab709f | Paolo Barbolini | 2025-01-25T23:01:37 | build: upgrade getrandom to v0.3.0 (#320) | diff --git a/Cargo.toml b/Cargo.toml
index 8018146..942d682 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,7 +23,7 @@ fastrand = "2.1.1"
once_cell = { version = "1.19.0", default-features = false, features = ["std"] }
[target.'cfg(any(unix, windows, target_os = "wasi"))'.dependencies]
-getrandom = { version = "0.2... | 2 | 2 | 2 |
a4596e5d57359e43734407c283788b1d7720bf54 | Erich Gubler | 2025-01-22T01:56:15 | build: allow `windows-sys` 0.59 (#319) | diff --git a/Cargo.toml b/Cargo.toml
index 1269780..8018146 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -29,7 +29,7 @@ getrandom = { version = "0.2.15", default-features = false, optional = true }
rustix = { version = "0.38.39", features = ["fs"] }
[target.'cfg(windows)'.dependencies.windows-sys]
-version = ">=0.52... | 1 | 1 | 1 |
3ac6d4eb04f4d719c4aadfb2328b9d0d80afcddf | Steven Allen | 2025-01-05T19:47:50 | chore: fix clippy lifetime warning (#318) | diff --git a/src/lib.rs b/src/lib.rs
index 253c951..590bd84 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -228,7 +228,7 @@ pub struct Builder<'a, 'b> {
keep: bool,
}
-impl<'a, 'b> Default for Builder<'a, 'b> {
+impl Default for Builder<'_, '_> {
fn default() -> Self {
Builder {
random_l... | 1 | 1 | 1 |
3a722e86baad70464e25348379c11f68b011a82a | Steven Allen | 2025-01-05T18:02:42 | docs: improve & expand security documentation (#317)
Alternative to #311 (this patch includes a few miscellaneous
documentation fixes from that PR as well).
The previous documentation didn't sufficiently cover permissions issues
and mixed all the security concerns into a single section. This patch
separates things ou... | diff --git a/src/dir/mod.rs b/src/dir/mod.rs
index afd414f..4b0c37a 100644
--- a/src/dir/mod.rs
+++ b/src/dir/mod.rs
@@ -22,15 +22,20 @@ use crate::env;
/// Create a new temporary directory.
///
-/// The `tempdir` function creates a directory in the file system
-/// and returns a [`TempDir`].
-/// The directory wil... | 3 | 69 | 18 |
e7a40e3731c609a06fe959c88e8f681e31f17079 | Steven Allen | 2025-01-02T21:42:27 | Release v3.15.0 | diff --git a/Cargo.toml b/Cargo.toml
index 32a3695..1269780 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tempfile"
-version = "3.14.0"
+version = "3.15.0"
authors = [
"Steven Allen <steven@stebalien.com>",
"The Rust Project Developers", | 1 | 1 | 1 |
ae22b273a1bb539018c748f1613a8f2ca29038c4 | Panagiotis "Ivory" Vasilopoulos | 2024-11-17T05:40:47 | docs: add owasp link on insecure temporary files (#309) | diff --git a/src/lib.rs b/src/lib.rs
index 4f5a8bb..7fe44b1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -29,6 +29,9 @@
//! `tempfile` doesn't rely on file paths so this isn't an issue. However, `NamedTempFile` does
//! rely on file paths for _some_ operations. See the security documentation on
//! the `NamedTempFile... | 1 | 3 | 0 |
fa8ad0090413475cce8402044a06e724ffc6be0e | Lakshya Singh | 2024-11-05T04:00:43 | allow older windows-sys (#304)
dependabot bumped the version to 0.59 but older version 0.52 can also be supported allowing upstream crates to pull dependency as per their version choice. | diff --git a/Cargo.toml b/Cargo.toml
index 6f29fd7..dd9a0d4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,7 +26,7 @@ once_cell = { version = "1.19.0", default-features = false, features = ["std"] }
rustix = { version = "0.38.37", features = ["fs"] }
[target.'cfg(windows)'.dependencies.windows-sys]
-version = "0.5... | 1 | 1 | 1 |
335d91d538953bb535f0839f4daced8d008d1dab | AverageADF | 2024-10-23T22:01:49 | fix: expose SpooledData enum (#301) | diff --git a/src/lib.rs b/src/lib.rs
index ddd93e7..459afbe 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -161,7 +161,7 @@ pub use crate::dir::{tempdir, tempdir_in, TempDir};
pub use crate::file::{
tempfile, tempfile_in, NamedTempFile, PathPersistError, PersistError, TempPath,
};
-pub use crate::spooled::{spooled_... | 1 | 1 | 1 |
d21b602fa28182468909ac44a2ac60b7f0a16f95 | Steven Allen | 2024-09-28T15:33:49 | chore: update deps | diff --git a/Cargo.toml b/Cargo.toml
index 1dee2d9..d9879f5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,12 +18,12 @@ description = "A library for managing temporary files and directories."
[dependencies]
cfg-if = "1"
-fastrand = "2.0.1"
+fastrand = "2.1.1"
# Not available in stdlib until 1.70, but we support 1... | 1 | 2 | 2 |
d6600da8fc542c7076a4de129e98e40cdb4bad4f | Ash | 2024-09-28T15:32:23 | Add for `with_suffix` (#299) | diff --git a/src/dir/mod.rs b/src/dir/mod.rs
index 067c74a..afd414f 100644
--- a/src/dir/mod.rs
+++ b/src/dir/mod.rs
@@ -267,6 +267,58 @@ impl TempDir {
Builder::new().prefix(&prefix).tempdir()
}
+ /// Attempts to make a temporary directory with the specified suffix inside of
+ /// `env::temp_dir(... | 4 | 93 | 0 |
19280c588988101ea2ab796877766ca5bd23f397 | Imbris | 2024-08-11T17:04:08 | Document current default permissions for tempdirs (#296)
Fixes implying that the default is the same as the one for tempfiles | diff --git a/src/lib.rs b/src/lib.rs
index ca657cb..ddd93e7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -337,7 +337,6 @@ impl<'a, 'b> Builder<'a, 'b> {
}
/// The permissions to create the tempfile or [tempdir](Self::tempdir) with.
- /// This allows to them differ from the default mode of `0o600` on Unix.... | 1 | 6 | 3 |
c5eac9f6905d23c5d6fb96df7637be5d04c3c993 | Steven Allen | 2024-08-06T19:55:58 | fix: address clippy unnecessary deref lint in test (#294) | diff --git a/tests/env.rs b/tests/env.rs
index 558f767..4419a3f 100644
--- a/tests/env.rs
+++ b/tests/env.rs
@@ -7,7 +7,7 @@ fn test_override_temp_dir() {
assert_eq!(tempfile::env::temp_dir(), std::env::temp_dir());
let new_tmp = Path::new("/tmp/override");
- tempfile::env::override_temp_dir(&new_tmp).un... | 1 | 1 | 1 |
6e995724c10bc9c5f524df2575c8f3fe1a7df875 | Ralf Jung | 2024-08-06T19:39:19 | add keep() function to builder that suppresses delete-on-drop behavior (#293)
fixes #194 | diff --git a/src/dir/imp/any.rs b/src/dir/imp/any.rs
index 015f9f8..512a54e 100644
--- a/src/dir/imp/any.rs
+++ b/src/dir/imp/any.rs
@@ -7,7 +7,11 @@ fn not_supported<T>(msg: &str) -> io::Result<T> {
Err(io::Error::new(io::ErrorKind::Other, msg))
}
-pub fn create(path: PathBuf, permissions: Option<&std::fs::Per... | 10 | 99 | 28 |
3531c11be141d3338766b3ff327857cd9dff4200 | Steven Allen | 2024-08-02T20:14:01 | Release 3.11.0 | diff --git a/Cargo.toml b/Cargo.toml
index 503f152..315745a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tempfile"
-version = "3.10.1"
+version = "3.11.0"
authors = [
"Steven Allen <steven@stebalien.com>",
"The Rust Project Developers", | 1 | 1 | 1 |
9825fff53bc5540c2504288234e2c4e5f8bec471 | Sebastian Urban | 2024-07-29T16:05:07 | test: add a test case for override_temp_dir (#289) | diff --git a/tests/env.rs b/tests/env.rs
new file mode 100644
index 0000000..558f767
--- /dev/null
+++ b/tests/env.rs
@@ -0,0 +1,15 @@
+#![deny(rust_2018_idioms)]
+
+use std::path::Path;
+
+#[test]
+fn test_override_temp_dir() {
+ assert_eq!(tempfile::env::temp_dir(), std::env::temp_dir());
+
+ let new_tmp = Path... | 1 | 15 | 0 |
e5418bd64758d1d0444e9158005f00ca7d2bc6ee | Steven Allen | 2024-05-10T19:13:15 | chore: modernize doctests (#282)
We no longer need wrapping "main" blocks. | diff --git a/src/dir/mod.rs b/src/dir/mod.rs
index db70dd5..ba1b0db 100644
--- a/src/dir/mod.rs
+++ b/src/dir/mod.rs
@@ -37,14 +37,8 @@ use crate::Builder;
/// ```
/// use tempfile::tempdir;
/// use std::fs::File;
-/// use std::io::{self, Write};
-///
-/// # fn main() {
-/// # if let Err(_) = run() {
-/// # ... | 4 | 129 | 403 |
73e92b3e8373e7bec563c9e1e7b7d896661363c1 | Tobias Stoeckmann | 2024-04-16T21:32:31 | chore: fix doc url (#280)
It has to end with version (or latest).
Fixes ecb73745c552f9df53f8943ea80e9bebf51643a2. | diff --git a/src/lib.rs b/src/lib.rs
index 4c0eb84..5424ffd 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -160,7 +160,7 @@
#![doc(
html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
- html_root_url = "https://docs.rs/te... | 1 | 1 | 1 |
ecb73745c552f9df53f8943ea80e9bebf51643a2 | Tobias Stoeckmann | 2024-03-12T17:55:17 | chore: set html_root_url to latest (#279) | diff --git a/src/lib.rs b/src/lib.rs
index 2072f7a..4c0eb84 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -160,7 +160,7 @@
#![doc(
html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
- html_root_url = "https://docs.rs/te... | 1 | 1 | 1 |
56c593477f84e6effd906c81fbc22b68b734c2ac | Tobias Stoeckmann | 2024-02-26T22:24:01 | Fix integer overflows and truncation (#278)
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> | diff --git a/src/spooled.rs b/src/spooled.rs
index 2c8eaa4..9b2e7e7 100644
--- a/src/spooled.rs
+++ b/src/spooled.rs
@@ -96,7 +96,7 @@ impl SpooledTempFile {
}
pub fn set_len(&mut self, size: u64) -> Result<(), io::Error> {
- if size as usize > self.max_size {
+ if size > self.max_size as u64 ... | 3 | 26 | 5 |
5a949d6e75e5c559e09b5a865f534096199626b4 | Steven Allen | 2024-02-05T18:57:45 | chore: 2021 edition (#276)
Nothing to change here, just an edition bump. | diff --git a/Cargo.toml b/Cargo.toml
index 496d731..48f0ef9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,7 +8,7 @@ authors = [
"Jason White <me@jasonwhite.io>",
]
documentation = "https://docs.rs/tempfile"
-edition = "2018"
+edition = "2021"
rust-version = "1.63"
homepage = "https://stebalien.com/projects/temp... | 1 | 1 | 1 |
e246c4a00438ed64f6e290911a5b886f25714e8d | Steven Allen | 2024-02-05T18:45:41 | chore: update deps (#275) | diff --git a/Cargo.toml b/Cargo.toml
index c9f13ab..92ca81d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,10 +18,10 @@ description = "A library for managing temporary files and directories."
[dependencies]
cfg-if = "1"
-fastrand = "2.0.0"
+fastrand = "2.0.1"
[target.'cfg(any(unix, target_os = "wasi"))'.depende... | 1 | 2 | 2 |
4a05e47d3b912ef90054efb64b56132640dffb96 | Sebastian Thiel | 2024-02-05T18:17:32 | feat: Add `Builder::permissions()` method. (#273)
* feat: Add `Builder::permissions()` method.
With it it's possible to change the default mode of tempfiles on
unix systems.
The example also doesn't hide the fact that it is currently only
useful on Unix, but as the ecosystem matures, thanks to the usage
of `s... | diff --git a/src/dir/imp/any.rs b/src/dir/imp/any.rs
new file mode 100644
index 0000000..015f9f8
--- /dev/null
+++ b/src/dir/imp/any.rs
@@ -0,0 +1,19 @@
+use crate::error::IoResultExt;
+use crate::TempDir;
+use std::path::PathBuf;
+use std::{fs, io};
+
+fn not_supported<T>(msg: &str) -> io::Result<T> {
+ Err(io::Err... | 10 | 192 | 21 |
184ab8f5ca6f6019692d875c5407c31e53e268cc | Steven Allen | 2024-01-31T05:19:14 | fix: drop redox_syscall dependency (#272)
fixes #271 | diff --git a/Cargo.toml b/Cargo.toml
index bfe3e04..c9f13ab 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,9 +30,6 @@ features = [
"Win32_Foundation",
]
-[target.'cfg(target_os = "redox")'.dependencies]
-redox_syscall = "0.4"
-
[dev-dependencies]
doc-comment = "0.3"
diff --git a/src/file/imp/unix.rs b/src/... | 2 | 2 | 4 |
709a62a299f17b81ef4e6582a694f8d11d4b5d6e | Kenny Kerr | 2023-12-02T10:45:56 | Update `windows-sys` 0.52 (#265)
* 52
* rustix | diff --git a/Cargo.toml b/Cargo.toml
index 2e23d04..81bcd2e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,10 +21,10 @@ cfg-if = "1"
fastrand = "2.0.0"
[target.'cfg(any(unix, target_os = "wasi"))'.dependencies]
-rustix = { version = "0.38.21", features = ["fs"] }
+rustix = { version = "0.38.26", features = ["fs"] ... | 1 | 2 | 2 |
f3854daec8256f710c46724c8ff6cef778c28497 | Steven Allen | 2023-10-26T22:24:44 | chore: update rustix to 0.38.21 (#261)
fixes #259 | diff --git a/Cargo.toml b/Cargo.toml
index 8ab89e0..1f758fa 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,7 +21,7 @@ cfg-if = "1"
fastrand = "2.0.0"
[target.'cfg(any(unix, target_os = "wasi"))'.dependencies]
-rustix = { version = "0.38", features = ["fs"] }
+rustix = { version = "0.38.21", features = ["fs"] }
... | 1 | 1 | 1 |
723eb5e989472fbe54e1ea0327db0b8017e75c54 | Redempt | 2023-10-23T23:38:45 | Fix some typos in docs (#260) | diff --git a/src/file/mod.rs b/src/file/mod.rs
index 0b9d183..8a28343 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -731,7 +731,7 @@ impl<F> NamedTempFile<F> {
/// # Security
///
/// This method persists the temporary file using its path and may not be
- /// secure in the in all cases. Please ... | 1 | 2 | 2 |
b8e04113afa7f7f4a0b4aad982214613da41cc73 | Roy Wellington | 2023-09-19T16:13:44 | Correct docs about what this is equivalent to (#257) | diff --git a/src/file/mod.rs b/src/file/mod.rs
index aca44ce..0b9d183 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -611,7 +611,7 @@ impl NamedTempFile<File> {
/// This is equivalent to:
///
/// ```ignore
- /// Builder::new().prefix(&prefix).tempfile()
+ /// Builder::new().tempfile_in(dir)
... | 1 | 1 | 1 |
32ef2ace00b7e8a97db486a6189685a7b43c5caa | Steven Allen | 2023-08-18T21:48:34 | chore: more test cleanups (#253) | diff --git a/tests/tempdir.rs b/tests/tempdir.rs
index 6f9db7d..8ca7984 100644
--- a/tests/tempdir.rs
+++ b/tests/tempdir.rs
@@ -18,32 +18,9 @@ use std::thread;
use tempfile::{Builder, TempDir};
-macro_rules! t {
- ($e:expr) => {
- match $e {
- Ok(n) => n,
- Err(e) => panic!("error:... | 1 | 18 | 41 |
b4a2f646b473da0906a657bfa825d43ed1f19d39 | Steven Allen | 2023-08-18T21:46:48 | feat: add convenience methods for creating temp files with prefixes (#250)
- `TempDir::with_prefix(prefix)`
- `TempDir::with_prefix_in(prefix, directory)`
- `TempFile::with_prefix(prefix)`
- `TempFile::with_prefix_in(prefix, directory)`
fixes #249 | diff --git a/src/dir.rs b/src/dir.rs
index 483b6d8..1b79be4 100644
--- a/src/dir.rs
+++ b/src/dir.rs
@@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::ffi::OsStr;
use std::fs::remove_dir_all;
use std::mem;
use std::path::{self, Path, Pa... | 4 | 107 | 0 |
f994e9f5d99e4a7985161a70028209cf3638bb7b | Steven Allen | 2023-08-18T21:37:34 | chore: cleanup tempdir tests (#252)
We had some leftovers from when the tempdir crate was merged. | diff --git a/tests/tempdir.rs b/tests/tempdir.rs
index ce40f9d..898aba3 100644
--- a/tests/tempdir.rs
+++ b/tests/tempdir.rs
@@ -51,7 +51,6 @@ fn test_tempdir() {
assert!(!path.exists());
}
-#[test]
fn test_customnamed() {
let tmpfile = Builder::new()
.prefix("prefix")
@@ -148,72 +147,7 @@ fn tes... | 1 | 2 | 71 |
8b3703c19c7b69ed86ad595cdaf7a5b86eea8450 | Steven Allen | 2023-08-16T19:04:03 | chore: clippy fixes (#251) | diff --git a/tests/spooled.rs b/tests/spooled.rs
index 288d1e6..a3bcc03 100644
--- a/tests/spooled.rs
+++ b/tests/spooled.rs
@@ -10,7 +10,7 @@ fn test_automatic_rollover() {
let mut buf = Vec::new();
assert!(!t.is_rolled());
- assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 0);
+ assert_eq!(t.stream... | 2 | 26 | 26 |
a5c236ca11fb06373105f65952e194323e9f2637 | Dan Gohman | 2023-08-06T21:37:35 | Use `rename`/`unlink`/`etc. instead of `renameat`/`unlinkat`/etc. (#247)
Rustix on Haiku doesn't support `CWD`, so use the non-`at` versions
of functions, since tempfile was only ever passing `CWD` to them.
For `link`, switch to `std::fs::hard_link`, since the `link` function
has platform-dependent behavior and s... | diff --git a/src/file/imp/unix.rs b/src/file/imp/unix.rs
index fed4e02..79aba78 100644
--- a/src/file/imp/unix.rs
+++ b/src/file/imp/unix.rs
@@ -14,7 +14,10 @@ use crate::util;
use std::path::Path;
#[cfg(not(target_os = "redox"))]
-use rustix::fs::{linkat, renameat, unlinkat, AtFlags, CWD};
+use {
+ rustix::fs::... | 1 | 11 | 7 |
da36cd5ddd7adf84d1cacf17d6269f0597ac45f0 | LingMan | 2023-07-05T21:00:10 | Provide implementations for I/O safety traits unconditionally (#244)
* Provide implementations for I/O safety traits unconditionally
These traits have been stabilized with Rust 1.63. Since that is now our MSRV, we can drop the
`build.rs` as well as the `autocfg` build dependency.
While at it, I've also added a fe... | diff --git a/Cargo.toml b/Cargo.toml
index 064307d..2d2c888 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,8 +36,5 @@ redox_syscall = "0.3"
[dev-dependencies]
doc-comment = "0.3"
-[build-dependencies]
-autocfg = "1"
-
[features]
nightly = []
diff --git a/build.rs b/build.rs
deleted file mode 100644
index 5c1fb77... | 3 | 17 | 33 |
a2b45b3363ddf31efcd4920462d6ec3e0ef9a909 | LeoniePhiline | 2023-05-12T20:18:57 | fix(docs): Change `dir` and `file` variable names to match existing comments and rest of module (#237) | diff --git a/src/dir.rs b/src/dir.rs
index 917e47e..483b6d8 100644
--- a/src/dir.rs
+++ b/src/dir.rs
@@ -45,16 +45,16 @@ use crate::Builder;
/// # }
/// # fn run() -> Result<(), io::Error> {
/// // Create a directory inside of `std::env::temp_dir()`
-/// let dir = tempdir()?;
+/// let tmp_dir = tempdir()?;
///
-///... | 1 | 12 | 12 |
f474e6a98077e90bf3fc4c35bc2ffb6f6b1ae506 | LegionMammal978 | 2023-04-24T23:41:46 | Remove comment on SetFileInformationByHandle (#236)
The function cannot actually be used to move a file and set its
attributes in one operation. | diff --git a/src/file/imp/windows.rs b/src/file/imp/windows.rs
index cb2673b..9df65f9 100644
--- a/src/file/imp/windows.rs
+++ b/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... | 1 | 0 | 3 |
141c773eb71e110a54168f88880a0d80183e3163 | Steven Allen | 2023-04-14T13:59:00 | feat: implement default methods for SpooledTempFile Read/Write (#232)
That way we can take advantage of, e.g., vectorized operations. | diff --git a/src/spooled.rs b/src/spooled.rs
index a736cb7..2c8eaa4 100644
--- a/src/spooled.rs
+++ b/src/spooled.rs
@@ -122,16 +122,43 @@ impl Read for SpooledTempFile {
SpooledData::OnDisk(file) => file.read(buf),
}
}
+
+ fn read_vectored(&mut self, bufs: &mut [io::IoSliceMut<'_>]) -> io... | 1 | 47 | 5 |
3590dbfa5eeebdb0b511862770a3715f35deb527 | Steven Allen | 2023-04-08T20:30:50 | chore: modern rust (#231) | diff --git a/src/spooled.rs b/src/spooled.rs
index db14967..a736cb7 100644
--- a/src/spooled.rs
+++ b/src/spooled.rs
@@ -86,7 +86,7 @@ impl SpooledTempFile {
pub fn roll(&mut self) -> io::Result<()> {
if !self.is_rolled() {
let mut file = tempfile()?;
- if let SpooledData::InMemory... | 2 | 20 | 23 |
c76b783c47c8ef780c8533ad7aec1a60b75af96c | Steven Allen | 2023-04-08T20:20:08 | feat: implement AsFd/AsHandle to mirror the AsRaw* variants (#230)
We don't implement the "into" variants as that'll drop and delete the
temporary file. | diff --git a/Cargo.toml b/Cargo.toml
index acec630..3c97b0b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,5 +36,8 @@ redox_syscall = "0.3"
[dev-dependencies]
doc-comment = "0.3"
+[build-dependencies]
+autocfg = "1"
+
[features]
nightly = []
diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..5c... | 3 | 31 | 0 |
ae4f4c81859e143ad7dc49274b4bf7d6b2437afc | Steven Allen | 2023-04-08T19:53:24 | chore: bump rustix min version to 0.37.11 (#229)
Reduces compile times. Technically, downstream users can do this
themselves, but they likely won't know what's going on. This saves them
the trouble.
fixes #228 | diff --git a/Cargo.toml b/Cargo.toml
index 909aca0..acec630 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,7 +21,7 @@ cfg-if = "1"
fastrand = "1.6.0"
[target.'cfg(any(unix, target_os = "wasi"))'.dependencies]
-rustix = { version = "0.37.1", features = ["fs"] }
+rustix = { version = "0.37.11", features = ["fs"] }
... | 1 | 1 | 1 |
94883627f9d8f0dc3d74df6c2423dad37b712fd3 | Steven Allen | 2023-04-03T23:19:37 | Forward default NamedTempFile methods (#226)
Instead of using the default method implementations, forward them to the
underlying file. This allows the user to, e.g., take advantage of
vectorized IO. | diff --git a/src/file/mod.rs b/src/file/mod.rs
index 023acd2..d78d5a0 100644
--- a/src/file/mod.rs
+++ b/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())
... | 1 | 78 | 0 |
8ad7b8cfb04960655783f0d671a2130cab81c279 | Jason White | 2023-03-29T03:22:24 | NamedTempFile: Fix infinite recursion in trait bounds (#225)
Due to bug rust-lang/rust#96634, these generic bounds may cause an
infinite recursion in the compiler, even in unrelated code.
This specializes the `Write for &NamedTempFile<F>` impl on `File`
instead. This keeps the API the same as before the generic p... | diff --git a/src/file/mod.rs b/src/file/mod.rs
index 059ac40..023acd2 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -918,10 +918,7 @@ impl<F: Read> Read for NamedTempFile<F> {
}
}
-impl<'a, F> Read for &'a NamedTempFile<F>
-where
- &'a F: Read,
-{
+impl Read for &NamedTempFile<File> {
fn read(&m... | 2 | 28 | 12 |
089358d56bdc440a77e7fd17568f442421e0020f | LingMan | 2023-03-01T21:36:35 | Specify the MSRV in the Cargo.toml (#220)
It's good to have the MSRV available in a standarized, machine readable format. | diff --git a/Cargo.toml b/Cargo.toml
index 796dc87..b0b792b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,6 +9,7 @@ authors = [
]
documentation = "https://docs.rs/tempfile"
edition = "2018"
+rust-version = "1.48"
homepage = "https://stebalien.com/projects/tempfile-rs/"
keywords = ["tempfile", "tmpfile", "filesyst... | 1 | 1 | 0 |
279098a6ba08c0634b27332dc9b3d9d44813dbb1 | LingMan | 2023-03-01T21:06:22 | Silence unused variable warnings (#219)
These two are intentionally unused but are warned about when building e.g. wasm32-unknown-unknown. | diff --git a/src/file/imp/other.rs b/src/file/imp/other.rs
index d8a55a7..8721d2d 100644
--- a/src/file/imp/other.rs
+++ b/src/file/imp/other.rs
@@ -9,7 +9,7 @@ fn not_supported<T>() -> io::Result<T> {
))
}
-pub fn create_named(_path: &Path, open_options: &mut OpenOptions) -> io::Result<File> {
+pub fn create_n... | 1 | 2 | 2 |
ecab2b6ae6c093b5b10e748299c44d63e11196a1 | Taiki Endo | 2023-02-26T18:34:57 | Update windows-sys to 0.45, redox_syscall to 0.3 (#216)
* Update windows-sys to 0.45
* Update redox_syscall to 0.3
* Fix unused_variables warning on redox | diff --git a/Cargo.toml b/Cargo.toml
index c95fef6..796dc87 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,14 +23,14 @@ fastrand = "1.6.0"
rustix = { version = "0.36.0", features = ["fs"] }
[target.'cfg(windows)'.dependencies.windows-sys]
-version = "0.42"
+version = "0.45"
features = [
"Win32_Storage_FileSy... | 2 | 3 | 3 |
965456a53f038b7bfbfd0cfc26ea886f774bacc8 | Steven Allen | 2023-02-25T17:07:04 | fix: build failure | diff --git a/src/lib.rs b/src/lib.rs
index 493c7ad..4b6371d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -283,9 +283,7 @@ impl<'a, 'b> Builder<'a, 'b> {
///
/// Create a temporary directory with a chosen prefix under a chosen folder:
///
- /// ```
- /// use tempfile::Builder;
- ///
+ /// ```ig... | 1 | 1 | 3 |
3a256a260390e96750b7be159fc043147a35b632 | Steven Allen | 2023-02-25T17:00:31 | fix: clippy errors | diff --git a/src/dir.rs b/src/dir.rs
index 8a94a37..917e47e 100644
--- a/src/dir.rs
+++ b/src/dir.rs
@@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::mem;
use std::fs::remove_dir_all;
+use std::mem;
use std::path::{self, Path, PathBuf};... | 3 | 5 | 5 |
52dc0f9e053bba40a48e027e81f95d129790bfe2 | Jacob Kiesel | 2023-02-24T20:02:30 | Remove remove_dir_all dependency | diff --git a/Cargo.toml b/Cargo.toml
index 3d0fe74..4ec0b0a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,7 +18,6 @@ description = "A library for managing temporary files and directories."
[dependencies]
cfg-if = "1"
fastrand = "1.6.0"
-remove_dir_all = "0.5"
[target.'cfg(any(unix, target_os = "wasi"))'.depende... | 2 | 1 | 2 |
37a8ba026d6d2cffb25979499812fe54c5064ff1 | Alex Touchet | 2023-02-08T03:48:04 | Remove outdated exclusions and update link | diff --git a/Cargo.toml b/Cargo.toml
index 3dd88b1..3d0fe74 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,8 +9,7 @@ authors = [
]
documentation = "https://docs.rs/tempfile"
edition = "2018"
-exclude = ["/.travis.yml", "/appveyor.yml"]
-homepage = "http://stebalien.com/projects/tempfile-rs"
+homepage = "https://steb... | 1 | 1 | 2 |
8cc58fa11635436ee2604f69e1bb6b4fc1f556a2 | Samuel Henrique | 2023-01-18T23:58:37 | Add Builder usage example for tempdir with a chosen prefix under a chosen folder
This will be helpful for people migrating from tempdir
(TempDir::new_in), which accepts a prefix and a destination folder as
parameters.
Developers are suggested migrating to tempfile through RUSTSEC-2018-0017.
The example is quite... | diff --git a/src/lib.rs b/src/lib.rs
index bca1ba2..217af03 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -280,6 +280,16 @@ impl<'a, 'b> Builder<'a, 'b> {
/// # Ok(())
/// # }
/// ```
+ ///
+ /// Create a temporary directory with a chosen prefix under a chosen folder:
+ ///
+ /// ```
+ /// u... | 1 | 10 | 0 |
a077c8ee80bc00dde59be9fda843d266fe9b9ec4 | Dan Gohman | 2022-11-29T00:21:04 | Update to rustix 0.36.
The main change in this version is to switch to using the I/O safety
types and traits from std, on Rust versions where they're available. | diff --git a/Cargo.toml b/Cargo.toml
index bd2a4e2..3dd88b1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,7 +22,7 @@ fastrand = "1.6.0"
remove_dir_all = "0.5"
[target.'cfg(any(unix, target_os = "wasi"))'.dependencies]
-rustix = { version = "0.35.6", features = ["fs"] }
+rustix = { version = "0.36.0", features = [... | 1 | 1 | 1 |
2d3fdd635305a52e29a563813f7208453e50b4bc | Sebastian Thiel | 2022-11-16T11:29:35 | fix: don't claim 'too many temporary files exist' if a file already existed, once.
Previously when creating a temporary file without any random characters
in it, a loop would effectively run once and fail with the conclusion
that a file could not be created because too many temporary files exist
(2_147_483_648).
Now ... | diff --git a/src/util.rs b/src/util.rs
index 98c3ee8..c61082d 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -34,10 +34,10 @@ where
for _ in 0..num_retries {
let path = base.join(tmpname(prefix, suffix, random_len));
return match f(path) {
- Err(ref e) if e.kind() == io::ErrorKind::Alre... | 1 | 2 | 2 |
3eb8a515cebe7f0b55c80f7ae2472a95801ecbab | Niyaz Nigmatullin | 2022-10-21T11:02:56 | Bump `windows-sys` dependency version | diff --git a/Cargo.toml b/Cargo.toml
index a738615..bd2a4e2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,7 +25,7 @@ remove_dir_all = "0.5"
rustix = { version = "0.35.6", features = ["fs"] }
[target.'cfg(windows)'.dependencies.windows-sys]
-version = "0.36"
+version = "0.42"
features = [
"Win32_Storage_File... | 1 | 1 | 1 |
89f4d2d60c160b4bf2bb8f4e384cda9754dc58c6 | Steven Allen | 2022-08-22T09:25:10 | doc: fix tempdir_in documentation
fixes #190 | diff --git a/src/dir.rs b/src/dir.rs
index 2ecea2b..73faeec 100644
--- a/src/dir.rs
+++ b/src/dir.rs
@@ -65,9 +65,9 @@ pub fn tempdir() -> io::Result<TempDir> {
TempDir::new()
}
-/// Create a new temporary directory.
+/// Create a new temporary directory in a specific directory.
///
-/// The `tempdir` function... | 1 | 5 | 5 |
ba93682961c5b00b63daed8d05cab18279a8095a | Robert Collins | 2022-03-29T18:05:37 | Fix clippy lint | diff --git a/src/util.rs b/src/util.rs
index 5e95e5f..98c3ee8 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -1,4 +1,3 @@
-use fastrand;
use std::ffi::{OsStr, OsString};
use std::path::{Path, PathBuf};
use std::{io, iter::repeat_with};
diff --git a/tests/namedtempfile.rs b/tests/namedtempfile.rs
index cfdee33..22ec6a... | 3 | 7 | 8 |
75216fe4a8908ce211d8c961f4654a82a26c49c8 | Robert Collins | 2022-03-29T17:39:17 | Fix cargo build --all-features --all-targets | diff --git a/src/lib.rs b/src/lib.rs
index 4d00eb4..bca1ba2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -165,7 +165,7 @@
#![cfg_attr(test, deny(warnings))]
#![deny(rust_2018_idioms)]
#![allow(clippy::redundant_field_names)]
-#![cfg_attr(feature = "nightly", feature(wasi_ext))]
+#![cfg_attr(all(feature = "nightly", t... | 1 | 1 | 1 |
2f8ac1fbe9fd5a61eb761d3316e27fa44c4d3422 | Robert Collins | 2022-03-29T17:18:45 | Fix compile warnings on Windows | diff --git a/tests/tempfile.rs b/tests/tempfile.rs
index f4dddb2..c2f6844 100644
--- a/tests/tempfile.rs
+++ b/tests/tempfile.rs
@@ -2,8 +2,11 @@
use std::fs;
use std::io::{Read, Seek, SeekFrom, Write};
-use std::sync::mpsc::{sync_channel, TryRecvError};
-use std::thread;
+#[cfg(target_os = "linux")]
+use std::{
+ ... | 1 | 5 | 2 |
88910f1d58b4402b820505783b8486b57ae6847d | Dan Gohman | 2022-07-28T07:25:42 | Update src/file/imp/unix.rs
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com> | diff --git a/src/file/imp/unix.rs b/src/file/imp/unix.rs
index d8e8824..6dca726 100644
--- a/src/file/imp/unix.rs
+++ b/src/file/imp/unix.rs
@@ -124,7 +124,7 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<
}
}
- // Otherwise use `linkat` to create the n... | 1 | 1 | 1 |
a5d81782866d0502cda9917d21fa272ccf90bdb8 | Dan Gohman | 2022-01-11T19:23:00 | Use `renameat2` on Linux to implement `persist` with no overwrite.
Use `rustix::fs::renameat_with`, which corresponds to Linux's
`renameat2`, to implement the non-overlapping form of `persist`, on
Linux versions and filesystems where it's supported. | diff --git a/src/file/imp/unix.rs b/src/file/imp/unix.rs
index ddb4b9c..d8e8824 100644
--- a/src/file/imp/unix.rs
+++ b/src/file/imp/unix.rs
@@ -105,9 +105,30 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<
if overwrite {
renameat(cwd(), old_path, cwd(), new_path)?;
... | 1 | 22 | 1 |
716e58e9fc98c461c801a484dc41c59e3f6c36af | James Thomas Moon | 2022-07-15T00:11:50 | doc clarify statics may leak (#184)
documentation notes static declared instances may leak (like with lazy_static). Links to underlying reason
https://github.com/rust-lang-nursery/lazy-static.rs/issues/62
Issue #183 | diff --git a/src/file/mod.rs b/src/file/mod.rs
index 1f4eed9..97e7fb7 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -467,17 +467,19 @@ impl AsRef<OsStr> for TempPath {
/// # Resource Leaking
///
/// If the program exits before the `NamedTempFile` destructor is
-/// run, such as via [`std::process::exit()`], ... | 2 | 13 | 7 |
cc1bb98fdf679a42022e01a7e454f2145c3d4927 | Mads Marquart | 2022-06-11T04:10:23 | Use official windows-sys bindings | diff --git a/Cargo.toml b/Cargo.toml
index 6124a97..c8b95d0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,12 +24,11 @@ remove_dir_all = "0.5"
[target.'cfg(any(unix, target_os = "wasi"))'.dependencies]
libc = "0.2.27"
-[target.'cfg(windows)'.dependencies.winapi]
-version = "0.3"
+[target.'cfg(windows)'.dependencie... | 3 | 11 | 13 |
018058147b37dfe5e2e7bc38de841868c7d08d82 | Josh Triplett | 2022-06-10T04:24:21 | Add `#[must_use]` to various functions
Based on encountering some code that called `TempDir::path` and ignored
the result. | diff --git a/src/dir.rs b/src/dir.rs
index d5a944b..2ecea2b 100644
--- a/src/dir.rs
+++ b/src/dir.rs
@@ -292,6 +292,7 @@ impl TempDir {
/// # Ok(())
/// # }
/// ```
+ #[must_use]
pub fn path(&self) -> &path::Path {
self.path.as_ref()
}
@@ -323,6 +324,7 @@ impl TempDir {
/// # O... | 3 | 6 | 0 |
aae51b4d875a3c8353716bb943092a16d86a9436 | Jason White | 2022-04-09T00:16:45 | Update my email address
:) | diff --git a/Cargo.toml b/Cargo.toml
index c5729c8..6124a97 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,7 @@ authors = [
"Steven Allen <steven@stebalien.com>",
"The Rust Project Developers",
"Ashley Mannix <ashleymannix@live.com.au>",
- "Jason White <jasonaw0@gmail.com>",
+ "Jason White <me@jasonwhit... | 1 | 1 | 1 |
90da93adb7be1f999f57738f8ad7b0b4a4bd8d8c | Jason White | 2022-04-08T23:44:07 | Add Builder::{make, make_in} and NamedTempFile::from_parts
This enables the user to do more generic temporary file path creation,
such as creating a temporary UNIX domain socket or creating a temporary
`tokio::fs::File` (without using `tokio::fs::File::from_std`). | diff --git a/src/file/mod.rs b/src/file/mod.rs
index 4f483a0..1f4eed9 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -858,6 +858,14 @@ impl<F> NamedTempFile<F> {
pub fn into_parts(self) -> (F, TempPath) {
(self.file, self.path)
}
+
+ /// Creates a `NamedTempFile` from its constituent parts.... | 4 | 277 | 2 |
07238029afb04def67cc43a8e4cddfd471b5dc4f | Jason White | 2022-04-08T20:41:45 | Make NamedTempFile more generic
This enables using it with non-File types, like a `UnixListener`.
This should be a backwards compatible change. | diff --git a/src/file/mod.rs b/src/file/mod.rs
index b859ced..4f483a0 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -478,18 +478,18 @@ impl AsRef<OsStr> for TempPath {
/// [`NamedTempFile::new_in()`]: #method.new_in
/// [`std::env::temp_dir()`]: https://doc.rust-lang.org/std/env/fn.temp_dir.html
/// [`std::p... | 1 | 82 | 58 |
92ae3e9d6e82bdcfcf114be459d234d3602be2d4 | Steven Allen | 2022-01-08T19:04:42 | chore: remove extern crates | diff --git a/src/file/imp/mod.rs b/src/file/imp/mod.rs
index ceb630e..fbb2bbf 100644
--- a/src/file/imp/mod.rs
+++ b/src/file/imp/mod.rs
@@ -1,4 +1,4 @@
-cfg_if! {
+cfg_if::cfg_if! {
if #[cfg(any(unix, target_os = "redox", target_os = "wasi"))] {
mod unix;
pub use self::unix::*;
diff --git a/src/... | 3 | 3 | 10 |
a5f535c95b370f521e318c8b909067cb830a78e9 | Steven Allen | 2022-01-08T19:08:07 | fix: doc formatting | diff --git a/src/lib.rs b/src/lib.rs
index e171736..673ea92 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -28,11 +28,12 @@
//! the `NamedTempFile` type for more information.
//!
//! ## Early drop pitfall
+//!
//! Because `TempDir` and `NamedTempFile` rely on their destructors for cleanup, this can lead
//! to an une... | 1 | 5 | 2 |
ab67ccee85fe00df744c4422befafd0ce1ff264d | robinwilliam.hundt | 2020-02-15T12:58:46 | Add docs pointing out early dop pitfalls
This commit adds a section to the `src/libs.rs` docs
pointing out an easily encounterable error when
ussing `tempdir()` with apis that are generic over
`AsRef<Path>`, like `Command::current_dir`, resulting
in the directory being dropped to early (As pointed out in #115). | diff --git a/src/lib.rs b/src/lib.rs
index d89798f..e171736 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -27,6 +27,39 @@
//! rely on file paths for _some_ operations. See the security documentation on
//! the `NamedTempFile` type for more information.
//!
+//! ## Early drop pitfall
+//! Because `TempDir` and `NamedTe... | 1 | 33 | 0 |
9a6321760bcfae15ac488f1f4bd94db4e97e9367 | Steven Allen | 2022-01-08T18:58:54 | chore: update fastrand | diff --git a/Cargo.toml b/Cargo.toml
index 4d476b9..c0d6b83 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,7 +18,7 @@ description = "A library for managing temporary files and directories."
[dependencies]
cfg-if = "1"
-fastrand = "1.2.3"
+fastrand = "1.6.0"
remove_dir_all = "0.5"
[target.'cfg(any(unix, target_... | 1 | 1 | 1 |
e24fae3ac2857544c608ad4727710a70d7631a14 | Steven Allen | 2022-01-08T18:46:37 | chore: avoid allocation when generating temp names | diff --git a/src/util.rs b/src/util.rs
index 2bd00b2..8c91b9c 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -8,11 +8,10 @@ use crate::error::IoResultExt;
fn tmpname(prefix: &OsStr, suffix: &OsStr, rand_len: usize) -> OsString {
let mut buf = OsString::with_capacity(prefix.len() + suffix.len() + rand_len);
bu... | 1 | 4 | 5 |
f83a062eb052271108f939494837d499003d6c52 | Joshua Li | 2020-06-17T18:24:27 | feat: replace rand with fastrand | diff --git a/Cargo.toml b/Cargo.toml
index 6682f83..4d476b9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,7 +18,7 @@ description = "A library for managing temporary files and directories."
[dependencies]
cfg-if = "1"
-rand = { version = "0.8", features = ["small_rng", "getrandom"], default_features = false }
+fas... | 2 | 8 | 22 |
37432444876948efdab1eb69dc1786c1c3c2b747 | Ryan McGrath | 2022-01-07T00:10:11 | Rename `SpooledInner` to `SpooledData`. | diff --git a/src/spooled.rs b/src/spooled.rs
index ba49ed7..ed6c16f 100644
--- a/src/spooled.rs
+++ b/src/spooled.rs
@@ -4,7 +4,7 @@ use std::io::{self, Cursor, Read, Seek, SeekFrom, Write};
/// A wrapper for the two states of a `SpooledTempFile`.
#[derive(Debug)]
-pub enum SpooledInner {
+pub enum SpooledData {
... | 1 | 20 | 20 |
f31d29afb98d0413517cdac73474cdb4c47822cb | Ryan McGrath | 2022-01-06T05:13:21 | Expose `SpooledInner` and add a `into_inner()`. | diff --git a/src/spooled.rs b/src/spooled.rs
index e6f750e..ba49ed7 100644
--- a/src/spooled.rs
+++ b/src/spooled.rs
@@ -2,8 +2,9 @@ use crate::file::tempfile;
use std::fs::File;
use std::io::{self, Cursor, Read, Seek, SeekFrom, Write};
+/// A wrapper for the two states of a `SpooledTempFile`.
#[derive(Debug)]
-en... | 1 | 7 | 1 |
24cbfe4df7608f3729eede2edb3adbb8c91303cd | kas | 2021-12-21T19:29:11 | Add method for manually creating TempPaths | diff --git a/src/file/mod.rs b/src/file/mod.rs
index 41e5eed..b859ced 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -351,6 +351,18 @@ impl TempPath {
}),
}
}
+
+ /// Create a new TempPath from an existing path. This can be done even if no
+ /// file exists at the given path.
+ ... | 2 | 59 | 2 |
b161dbec7d5e44648434ce2a6b1fcb374d628ce3 | Jiahao XU | 2021-12-17T13:06:18 | Reduce size of `TempDir` by removing the `Option`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> | diff --git a/src/dir.rs b/src/dir.rs
index bda644f..d5a944b 100644
--- a/src/dir.rs
+++ b/src/dir.rs
@@ -9,6 +9,7 @@
// except according to those terms.
use remove_dir_all::remove_dir_all;
+use std::mem;
use std::path::{self, Path, PathBuf};
use std::{fmt, fs, io};
@@ -192,7 +193,7 @@ pub fn tempdir_in<P: AsRef... | 1 | 18 | 11 |
d30d86a48afdd7ca2f8d3309b3f0dbab2688ac56 | Jiahao XU | 2021-12-17T12:46:16 | Reduce size of `TempPath` by 1 `usize`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> | diff --git a/src/file/mod.rs b/src/file/mod.rs
index 31fdd4b..41e5eed 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -138,7 +138,7 @@ impl error::Error for PathPersistError {
///
/// When dropped, the temporary file is deleted.
pub struct TempPath {
- path: PathBuf,
+ path: Box<Path>,
}
impl TempPat... | 1 | 10 | 8 |
e5bf65f2fb6e8bd1cb97e97dc97eb1c86ed236c3 | Jiahao XU | 2021-12-17T12:17:56 | Reduce size of `TempDir` by 1 pointer
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> | diff --git a/src/dir.rs b/src/dir.rs
index d630762..bda644f 100644
--- a/src/dir.rs
+++ b/src/dir.rs
@@ -192,7 +192,7 @@ pub fn tempdir_in<P: AsRef<Path>>(dir: P) -> io::Result<TempDir> {
/// [`std::fs`]: http://doc.rust-lang.org/std/fs/index.html
/// [`std::process::exit()`]: http://doc.rust-lang.org/std/process/fn.... | 1 | 5 | 3 |
f097ff48fc921afb34c6bf327b009e398365edb5 | Alan Somers | 2021-11-18T03:01:34 | Fix the build on Redox with -Zminimal-versions
Fixes #154 | diff --git a/Cargo.toml b/Cargo.toml
index 1f8e784..6682f83 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -33,7 +33,7 @@ features = [
]
[target.'cfg(target_os = "redox")'.dependencies]
-redox_syscall = "0.2"
+redox_syscall = "0.2.9"
[dev-dependencies]
doc-comment = "0.3" | 1 | 1 | 1 |
48ccbeb354ed6d92c97e2516da2d8c668dda2e2f | D1plo1d | 2021-05-15T18:29:22 | feat: Removed O_EXCL to allow for tmpfile persistence on Linux | diff --git a/src/file/imp/unix.rs b/src/file/imp/unix.rs
index bbf6cb1..89249fd 100644
--- a/src/file/imp/unix.rs
+++ b/src/file/imp/unix.rs
@@ -70,11 +70,11 @@ fn create_unlinked(path: &Path) -> io::Result<File> {
#[cfg(target_os = "linux")]
pub fn create(dir: &Path) -> io::Result<File> {
- use libc::{EISDIR, E... | 1 | 2 | 2 |
e428a2e0d93079513b551196b9857a30be734f13 | Steven Allen | 2021-04-09T18:41:22 | Remove unnecessary Rc | diff --git a/src/util.rs b/src/util.rs
index fda7676..01beeed 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -5,30 +5,28 @@ use std::thread_local;
use std::{
cell::UnsafeCell,
path::{Path, PathBuf},
- rc::Rc,
};
use std::{io, str};
use crate::error::IoResultExt;
thread_local! {
- static THREAD_R... | 1 | 3 | 5 |
fe6b66403c5f3777e20cadda4d8f555acbbe9ff8 | Jake McGinty | 2021-03-24T17:45:38 | use rand's SmallRng for random number generation | diff --git a/Cargo.toml b/Cargo.toml
index 2742b3e..1f8e784 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,7 +18,7 @@ description = "A library for managing temporary files and directories."
[dependencies]
cfg-if = "1"
-rand = "0.8"
+rand = { version = "0.8", features = ["small_rng", "getrandom"], default_features ... | 2 | 15 | 5 |
5c23957d3ad422e1ff56eb74c5940c76fc47f204 | Steven Allen | 2021-04-09T03:58:43 | test: disable cleaner test on everything but linux | diff --git a/tests/tempfile.rs b/tests/tempfile.rs
index 065dccb..f4dddb2 100644
--- a/tests/tempfile.rs
+++ b/tests/tempfile.rs
@@ -26,6 +26,8 @@ fn test_cleanup() {
assert!(num_files == 0);
}
+// Only run this test on Linux. MacOS doesn't like us creating so many files, apparently.
+#[cfg(target_os = "linux")... | 1 | 2 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.