From efb9d3f7bcb013b39e31304293e58b7fb4144d30 Mon Sep 17 00:00:00 2001 From: pml68 Date: Fri, 20 Jun 2025 03:01:07 +0200 Subject: feat: project file to open can be passed as an argument + desktop entry --- src/types/project.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/types') diff --git a/src/types/project.rs b/src/types/project.rs index 11789ac..7262ccf 100644 --- a/src/types/project.rs +++ b/src/types/project.rs @@ -62,7 +62,14 @@ impl Project { self, path: Option, ) -> Result { + use tokio::fs; + let path = if let Some(p) = path { + let parent = p.parent(); + if parent.is_some_and(|parent| !parent.exists()) { + fs::create_dir_all(parent.unwrap()).await?; + } + p } else { rfd::AsyncFileDialog::new() @@ -77,7 +84,7 @@ impl Project { }; let contents = serde_json::to_string(&self)?; - tokio::fs::write(&path, contents).await?; + fs::write(&path, contents).await?; Ok(path) } -- cgit v1.2.3