diff options
Diffstat (limited to 'crates/xa65/src/main.rs')
| -rw-r--r-- | crates/xa65/src/main.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/xa65/src/main.rs b/crates/xa65/src/main.rs index 5d46ec1..8a31e7b 100644 --- a/crates/xa65/src/main.rs +++ b/crates/xa65/src/main.rs @@ -1,5 +1,4 @@ use clap::Parser as ClapParser; -use rand::distributions::{Alphanumeric, DistString}; use std::path::PathBuf; use std::process::Command; @@ -63,6 +62,15 @@ fn get_binaries() -> Result<(PathBuf, PathBuf), String> { Ok((nasm, cl65)) } +// 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()); + + tmp.join(name) +} + fn main() { // Make sure that the binaries are there. let (nasm, cl65) = match get_binaries() { @@ -87,8 +95,7 @@ fn main() { // Generate a temporary directory in which both binary files will be placed // as an intermediate step. - let random_string = &Alphanumeric.sample_string(&mut rand::thread_rng(), 16); - let dir = std::env::temp_dir().join(random_string); + let dir = temporary_dir(); if let Err(e) = std::fs::create_dir(&dir) { die(e.to_string()); return; |
