//! Path utilities for Cloud Hypervisor VM management.

use std::path::{Path, PathBuf};

/// Returns the root directory for all VM data.
///
/// Uses `$HOME/hero/virt/vms` or falls back to `/tmp/hero/virt/vms`.
pub fn hero_vm_root() -> PathBuf {
    let home = std::env::var("HOME").unwrap_or_else(|_| "/tmp".into());
    Path::new(&home).join("hero/virt/vms")
}

/// Returns the directory for a specific VM.
pub fn vm_dir(id: &str) -> PathBuf {
    hero_vm_root().join(id)
}

/// Returns the path to a VM's JSON configuration file.
pub fn vm_json_path(id: &str) -> PathBuf {
    vm_dir(id).join("vm.json")
}

/// Returns the path to a VM's console log file.
pub fn vm_log_path(id: &str) -> PathBuf {
    vm_dir(id).join("logs/console.log")
}

/// Returns the path to a VM's PID file.
pub fn vm_pid_path(id: &str) -> PathBuf {
    vm_dir(id).join("pid")
}
