Skip to main content

qualia_client_core/
qapp_paths.rs

1//! Storage path helpers for installed Qualia qapps.
2
3use crate::qapp_registry::{QAPPS_DIR, QAPP_PACKAGE_MANIFEST};
4use std::path::{Path, PathBuf};
5
6/// `{storage}/Qapps/`
7pub fn qapps_dir(storage_path: impl AsRef<Path>) -> PathBuf {
8    storage_path.as_ref().join(QAPPS_DIR)
9}
10
11/// Ensure `{storage}/Qapps/` exists.
12pub fn ensure_qapps_dir(storage_path: impl AsRef<Path>) -> std::io::Result<PathBuf> {
13    let dir = qapps_dir(storage_path);
14    std::fs::create_dir_all(&dir)?;
15    Ok(dir)
16}
17
18/// Active install directory for a package id (flat layout under `{storage}/Qapps/{id}/`).
19pub fn resolve_active_package_dir(storage_path: impl AsRef<Path>, package_id: &str) -> PathBuf {
20    crate::qapp_install::resolve_active_package_dir(storage_path.as_ref(), package_id)
21}
22
23/// `{package}/qapp.json` when present.
24pub fn resolve_package_manifest_path(qapp_dir: &Path) -> Option<PathBuf> {
25    let path = qapp_dir.join(QAPP_PACKAGE_MANIFEST);
26    if path.exists() {
27        Some(path)
28    } else {
29        None
30    }
31}