refactor: change name from builder to installer

This commit is contained in:
Didier Slof 2023-07-17 20:40:01 +02:00
parent c3db07dc64
commit 7a56816472
Signed by: didier
GPG key ID: 01E71F18AA4398E5
7 changed files with 70 additions and 41 deletions

48
pkgr/src/tmpfs.rs Normal file
View file

@ -0,0 +1,48 @@
use std::path::PathBuf;
pub struct TempDir {
path: PathBuf,
}
impl TempDir {
pub fn new(path: PathBuf) -> TempDir {
if !path.exists() {
std::fs::create_dir_all(&path).unwrap();
}
TempDir {
path
}
}
pub fn push<S: Into<String>>(&mut self, path: S) {
self.path.push(path.into());
}
}
impl Default for TempDir {
fn default() -> TempDir {
TempDir::new({
let mut t = std::env::temp_dir();
t.push("pkgr");
t
})
}
}
impl Into<PathBuf> for TempDir {
fn into(self) -> PathBuf {
self.path
}
}
impl Into<String> for TempDir {
fn into(self) -> String {
self.path.to_str().unwrap().to_string()
}
}
impl ToString for TempDir {
fn to_string(&self) -> String {
self.path.to_str().unwrap().to_string()
}
}