aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/xa65/Cargo.toml1
-rw-r--r--crates/xa65/src/main.rs13
2 files changed, 10 insertions, 4 deletions
diff --git a/crates/xa65/Cargo.toml b/crates/xa65/Cargo.toml
index a6696bd..1ecceb0 100644
--- a/crates/xa65/Cargo.toml
+++ b/crates/xa65/Cargo.toml
@@ -6,4 +6,3 @@ authors = ["Miquel Sabaté Solà <mikisabate@gmail.com>"]
[dependencies]
clap = { version = "^4", features = ["derive"] }
-rand = "0.8.5"
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;