diff options
| author | pml68 <contact@pml68.dev> | 2025-06-20 03:01:07 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-06-20 03:01:07 +0200 |
| commit | efb9d3f7bcb013b39e31304293e58b7fb4144d30 (patch) | |
| tree | 6478322170861e49895dcd3d0e1471ac9761cf67 /src/types/project.rs | |
| parent | feat(PKGBUILD): add `check` for tests [skip ci] (diff) | |
| download | iced-builder-efb9d3f7bcb013b39e31304293e58b7fb4144d30.tar.gz | |
feat: project file to open can be passed as an argument + desktop entry
Diffstat (limited to 'src/types/project.rs')
| -rw-r--r-- | src/types/project.rs | 9 |
1 files changed, 8 insertions, 1 deletions
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<PathBuf>, ) -> Result<PathBuf, Error> { + 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) } |
