From 9c52119e18e4f0d9ba00883b1933e1f83cb7502d Mon Sep 17 00:00:00 2001 From: kelpsyberry <138107494+kelpsyberry@users.noreply.github.com> Date: Fri, 29 Mar 2024 22:59:43 +0100 Subject: [PATCH] Switch from `tempdir` to `tempfile` --- Cargo.lock | 78 +++-------------------- frontend/desktop/Cargo.toml | 6 +- frontend/desktop/src/emu/dldi.rs | 4 +- frontend/desktop/src/ui/title_menu_bar.rs | 8 ++- 4 files changed, 18 insertions(+), 78 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fccb321..30c965a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,7 +158,7 @@ dependencies = [ "enumflags2", "futures-channel", "futures-util", - "rand 0.8.5", + "rand", "serde", "serde_repr", "url", @@ -926,7 +926,7 @@ dependencies = [ "core-foundation", "crossbeam-channel", "parking_lot 0.11.2", - "rand 0.8.5", + "rand", "serde", "serde_json", ] @@ -1005,7 +1005,7 @@ dependencies = [ "slog-async", "slog-imgui", "slog-term", - "tempdir", + "tempfile", "wgpu", "winit", ] @@ -1248,12 +1248,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "futures-channel" version = "0.3.30" @@ -2228,9 +2222,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -2366,19 +2360,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - [[package]] name = "rand" version = "0.8.5" @@ -2387,7 +2368,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -2397,24 +2378,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.6.4" @@ -2436,15 +2402,6 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "realfft" version = "3.3.0" @@ -2521,15 +2478,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "renderdoc-sys" version = "1.1.0" @@ -2879,16 +2827,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" -[[package]] -name = "tempdir" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" -dependencies = [ - "rand 0.4.6", - "remove_dir_all", -] - [[package]] name = "tempfile" version = "3.10.1" @@ -3933,7 +3871,7 @@ dependencies = [ "hex", "nix", "ordered-stream", - "rand 0.8.5", + "rand", "serde", "serde_repr", "sha1", diff --git a/frontend/desktop/Cargo.toml b/frontend/desktop/Cargo.toml index 4738408..6d7c647 100644 --- a/frontend/desktop/Cargo.toml +++ b/frontend/desktop/Cargo.toml @@ -14,7 +14,7 @@ debug-views = [ "dust-core/channel-audio-capture", ] gdb-server = ["gdb-protocol", "dust-core/debugger-hooks"] -dldi = ["fatfs", "tempdir"] +dldi = ["fatfs", "tempfile"] discord-presence = ["discord-rpc"] @@ -62,7 +62,7 @@ parking_lot = "0.12" bitflags = "2.5" miniz_oxide = { version = "0.7", features = ["simd"] } fatfs = { version = "0.3", optional = true } -tempdir = { version = "0.3", optional = true } +tempfile = { version = "3.10", optional = true } proc-bitfield = { version = "0.3", features = ["nightly"] } # Config @@ -86,4 +86,4 @@ gdb-protocol = { version = "0.1", optional = true } [target.'cfg(target_os = "macos")'.dependencies] cocoa = "0.25" objc = "0.2" -tempdir = "0.3" +tempfile = "3.10" diff --git a/frontend/desktop/src/emu/dldi.rs b/frontend/desktop/src/emu/dldi.rs index d834a33..f1e3534 100644 --- a/frontend/desktop/src/emu/dldi.rs +++ b/frontend/desktop/src/emu/dldi.rs @@ -8,7 +8,7 @@ use std::{ io::{self, Read, Seek, SeekFrom, Write}, path::{Path, PathBuf}, }; -use tempdir::TempDir; +use tempfile::TempDir; struct LoadedChunk { index: u64, @@ -257,7 +257,7 @@ impl FsProvider { return Ok(()); } let mut chunk_manager = ChunkManager { - temp_dir: TempDir::new("dust-dldi")?, + temp_dir: tempfile::Builder::new().prefix("dust-dldi").tempdir()?, cur_addr: 0, fs_max_size: 1 << 30, chunk_size_shift: 22, diff --git a/frontend/desktop/src/ui/title_menu_bar.rs b/frontend/desktop/src/ui/title_menu_bar.rs index bb3e3eb..4c627ba 100644 --- a/frontend/desktop/src/ui/title_menu_bar.rs +++ b/frontend/desktop/src/ui/title_menu_bar.rs @@ -14,7 +14,7 @@ use imgui::{Image, TextureId}; use std::path::PathBuf; use std::{fmt::Write, path::Path}; #[cfg(target_os = "macos")] -use tempdir::TempDir; +use tempfile::TempDir; bitflags::bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -57,7 +57,7 @@ impl TitleMenuBarState { game_file_path: None, #[cfg(target_os = "macos")] temp_icon_dir: if config!(_config, game_icon_mode) == GameIconMode::Game { - TempDir::new("dust-icons").ok() + tempfile::Builder::new().prefix("dust-icons").tempdir().ok() } else { None }, @@ -292,7 +292,9 @@ impl TitleMenuBarState { match config!(config, game_icon_mode) { GameIconMode::None => None, GameIconMode::File => None, - GameIconMode::Game => TempDir::new("dust-icons").ok(), + GameIconMode::Game => { + tempfile::Builder::new().prefix("dust-icons").tempdir().ok() + } } }; self.update_game_icon(config, _window);