;; deps.edn
{:deps {com.outskirtslabs/dirs {:mvn/version "0.1.0"}}}
;; Leiningen
[com.outskirtslabs/dirs "0.1.0"]
A 0-dependency implementation of XDG base directories, systemd unit directories, Windows Known Folder paths, and macOS standard directories for Clojure, ClojureScript, and ClojureDart.
ol.dirs returns string paths or vectors of string paths. It does not create directories, does not check whether they exist, and carries no runtime dependencies.
| Runtime | Linux | macOS | Windows |
|---|---|---|---|
Clojure | yes | yes | yes |
ClojureScript on Node | yes | yes | yes |
ClojureDart | yes | yes | yes |
Project status: Maturing.
;; deps.edn
{:deps {com.outskirtslabs/dirs {:mvn/version "0.1.0"}}}
;; Leiningen
[com.outskirtslabs/dirs "0.1.0"]
(require '[ol.dirs :as dirs])
(dirs/config-home)
;; => "/home/alice/.config"
(dirs/config-home "My App")
;; => "/home/alice/.config/my-app"
(dirs/config-home "org" "Acme Corp" "My App")
;; => Linux: "/home/alice/.config/my-app"
;; => macOS: "/Users/Alice/Library/Application Support/org.Acme-Corp.My-App"
;; => Windows: "C:\\Users\\Alice\\AppData\\Roaming\\Acme Corp\\My App"
These functions support app-specific arities. Arity 0 returns the base directory, arity 1 appends an application name, and arity 3 appends a platform-specific qualifier, organization, and application path. The concrete path shapes are shown below in the App Path Rules table and in the example above.
data-home, config-home, state-home, cache-home, runtime-dir, executable-dir, preference-dir, state-dir, and config-dir all support those same arities.
data-dirs and config-dirs do too, but return vectors and append the application path to each search root.
| Form | Linux | macOS | Windows |
|---|---|---|---|
|
|
|
|
|
|
|
|
| Function | Linux | macOS | Windows |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| same as |
|
|
|
|
|
|
|
|
|
|
On Linux, trusted systemd units can override config-home, state-home, and cache-home via CONFIGURATION_DIRECTORY, STATE_DIRECTORY, and CACHE_DIRECTORY as documented in systemd.exec(5).
| Function | Linux | macOS | Windows |
|---|---|---|---|
|
|
| Music Known Folder |
|
|
| Desktop Known Folder |
|
|
| Documents Known Folder |
|
|
| Downloads Known Folder |
|
|
|
|
|
|
| Pictures Known Folder |
|
|
| Public Known Folder |
|
|
| Templates Known Folder |
|
|
| Videos Known Folder |
These functions may return nil by design:
runtime-dir and executable-dir on non-Linux platforms
font-dir on Windows
template-dir on macOS
Linux user-facing directories when user-dirs.dirs is missing, unreadable, disabled, or malformed
bb test:clj
bb test:cljs
bb test:cljd
bb test
The CLJD workspace commands live under dart/, because the Dart toolchain emits generated files that are easier to keep isolated there.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |