package xdg-basedir

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

XDG basedir implementation

The XDG basedir specification makes clear where to store configuration, cache and data files. This a way to maintain a clean $HOME. Locations can be customized through environment variables (XDG_DATA_HOME, XDG_CONFIG_HOME). It also allows to store files in several places (i.e. system directories).

  • author Sylvain Le Gall

Types

type filename = string
type dirname = string
type dirnames = dirname list
type t = {
  1. data_home : dirname;
    (*

    $HOME/.local/share

    *)
  2. data_dirs : dirnames;
    (*

    /usr/share

    *)
  3. config_home : dirname;
    (*

    $HOME/.config

    *)
  4. config_dirs : dirnames;
    (*

    /etc/xdg

    *)
  5. cache_home : dirname;
    (*

    $HOME/.cache

    *)
}

XDG environment

Modules and functions

val default : t

Default XDG environment

val mkdir_openfile : (filename -> 'a) -> filename -> 'a

mkdir_openfile f fn Create parent directory of fn and apply f fn

module Data : sig ... end

In this module, ~xdg_env allows to override the default XDG environment. If you use ~exists:true, the files/dirs are tested for existence.

module Config : sig ... end

See Data for explanations about ~xdg_env and ~exists

module Cache : sig ... end

See Data for explanations about ~xdg_env and ~exists

OCaml

Innovation. Community. Security.