From b7645c842f6c3fd718debe8de3e32ae346b17567 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Mon, 15 Dec 2025 21:58:16 +0100 Subject: xa65: use the current timestamp for the tmp directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The easy "let's count how many directories there are in /tmp" trick was prone to errors. Hence, let's make things (hopefully) easier by just appending the current timestamp in milliseconds to the directory name. Fixes: 4961b715328d ("xa65: better ensure the name of the tmp directory") Signed-off-by: Miquel Sabaté Solà --- crates/xa65/src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'crates/xa65') diff --git a/crates/xa65/src/main.rs b/crates/xa65/src/main.rs index 59bdc7d..fb1577c 100644 --- a/crates/xa65/src/main.rs +++ b/crates/xa65/src/main.rs @@ -2,6 +2,7 @@ use std::fs::File; use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::process::Command; +use std::time::{SystemTime, UNIX_EPOCH}; /// Version for this program. const VERSION: &str = "0.1.0"; @@ -168,8 +169,13 @@ fn get_binaries(nasm_name: String) -> Result<(PathBuf, PathBuf), String> { // Returns the path to the temporary directory that can be used for the run. fn temporary_dir() -> PathBuf { let tmp = &std::env::temp_dir(); - let paths = std::fs::read_dir(tmp).unwrap(); - let name = format!("xa65-{}", paths.count() + 1); + + let start = SystemTime::now(); + let epoch = start + .duration_since(UNIX_EPOCH) + .expect("xa65 (error): could not get current time."); + + let name = format!("xa65-{}", epoch.as_millis()); tmp.join(name) } -- cgit v1.2.3