Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use FILE_ATTRIBUTE_TEMPORARY on Windows
Browse files Browse the repository at this point in the history
andreacorbellini committed Apr 9, 2024

Verified

This commit was signed with the committer’s verified signature.
jnatten Jonas Natten
1 parent 884fba7 commit 3a7121f
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@ rand = { version = "0.8" }
[target.'cfg(unix)'.dependencies]
nix = { version = "0.28", features = ["fs", "user"] }

[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.52.0" }

[dev-dependencies]
tempfile = { version = "3.10.1" }

3 changes: 3 additions & 0 deletions src/imp/generic.rs
Original file line number Diff line number Diff line change
@@ -7,8 +7,10 @@ use std::fs::File;
use std::io::Error;
use std::io::ErrorKind;
use std::io::Result;
use std::os::windows::fs::OpenOptionsExt;
use std::path::Path;
use std::path::PathBuf;
use windows_sys::Win32::Storage::FileSystem::FILE_ATTRIBUTE_TEMPORARY;

fn is_a_directory() -> Error {
// TODO Use `ErrorKind::IsADirectory` once it is stabilized
@@ -55,6 +57,7 @@ impl TemporaryFile {
.write(true)
.read(opts.read)
.create_new(true)
.custom_flags(FILE_ATTRIBUTE_TEMPORARY)
.open(&path)
{
Ok(file) => break (file, path),

0 comments on commit 3a7121f

Please sign in to comment.