get_data_dir

Function get_data_dir 

Source
pub fn get_data_dir() -> Result<PathBuf>
Expand description

Returns the platform-specific data directory for AGPM.

This function returns the appropriate data directory for storing persistent application data, following platform conventions and standards.

§Returns

The data directory path ({data_dir}/agpm), or an error if it cannot be determined

§Examples

use agpm_cli::utils::platform::get_data_dir;

let data_dir = get_data_dir()?;
println!("AGPM data directory: {}", data_dir.display());

// Use for storing persistent data
let lockfile_backup = data_dir.join("lockfile_backups");

§Platform Paths

  • Linux: $XDG_DATA_HOME/agpm or $HOME/.local/share/agpm
  • macOS: $HOME/Library/Application Support/agpm
  • Windows: %APPDATA%\agpm

§Standards Compliance

  • Linux: Follows XDG Base Directory Specification
  • macOS: Follows Apple File System Programming Guide
  • Windows: Follows Windows Known Folders conventions

§Use Cases

  • Storing user preferences and settings
  • Application state and history
  • User-created templates and profiles
  • Persistent application data

§Persistence

Unlike cache directories, data directories are intended for long-term storage and should persist across system updates and cleanup operations.

§Difference from Cache

  • Data directory: Persistent, user-important data
  • Cache directory: Temporary, performance optimization data

§See Also