use std::{ fs::File, path::{Path, PathBuf}, }; use happylock::ThreadKey; use uuid::Uuid; use crate::processes::process_id; fn root() -> &'static Path { Path::new("~/.dozos") } fn path(root: &Path, program_id: Uuid, file_id: Uuid) -> PathBuf { let mut builder = PathBuf::from(root); builder.push(program_id.to_string()); builder.push(file_id.to_string()); builder } pub fn open(key: &mut ThreadKey, file_id: Uuid) -> std::io::Result { let path = path(root(), process_id(key), file_id); File::options() .read(true) .write(true) .create(true) .truncate(false) .open(path) }