#xdg #macro #directory

xdg-user-macros

A set of macros to aid in user-focused development using the XDG standard user home directories

1 unstable release

Uses old Rust 2015

0.1.1 Apr 15, 2018

#1419 in Filesystem

ISC license

8KB
122 lines

XDG Home Macros

Build Status

xdg-home-macros provides macros to aid developers with properly adhering to the XDG standard in user-targeted applications.

This package uses std::env as the primary form of defining the folder structure, but falls back to the common locations since some OS implementations do not set the environment variables and instead rely upon the user to specify them according to the standard.

Example:

#[macro_use] extern crate xdg_user_macros;
use std::path::PathBuf;
use std::env::{self, home_dir};
fn main() {
  let path = xdg_data_home!("my-awesome-app");
  let mut expected = home_dir().unwrap();
  expected.push(".local/share/my-awesome-app");
  assert_eq!(path, expected)
}

NOTE: The macros provided in this library do not create the folders associated with the returned PathBuf from each macro. Folder presence checks should be handled elsewhere in the application.

Dependencies

~42KB