{"id":13822879,"url":"https://github.com/dirs-dev/dirs-rs","last_synced_at":"2025-05-16T17:32:30.698Z","repository":{"id":40587609,"uuid":"131760791","full_name":"dirs-dev/dirs-rs","owner":"dirs-dev","description":"a low-level library that provides config/cache/data paths, following the respective conventions on Linux, macOS and Windows","archived":false,"fork":false,"pushed_at":"2024-04-03T10:53:18.000Z","size":66,"stargazers_count":615,"open_issues_count":12,"forks_count":46,"subscribers_count":10,"default_branch":"main","last_synced_at":"2024-05-16T05:09:36.624Z","etag":null,"topics":["knownfolders","xdg-basedir","xdg-user-dirs"],"latest_commit_sha":null,"homepage":"https://dirs.dev","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dirs-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-01T20:39:46.000Z","updated_at":"2024-06-18T14:05:00.944Z","dependencies_parsed_at":"2024-01-18T04:09:04.771Z","dependency_job_id":"f9a5e070-192f-4aa5-b9b5-89ff348e2d22","html_url":"https://github.com/dirs-dev/dirs-rs","commit_stats":{"total_commits":58,"total_committers":14,"mean_commits":4.142857142857143,"dds":0.2931034482758621,"last_synced_commit":"e99c8fc5667d11e027b934971913240e880e6b82"},"previous_names":["soc/dirs-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirs-dev%2Fdirs-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirs-dev%2Fdirs-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirs-dev%2Fdirs-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirs-dev%2Fdirs-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dirs-dev","download_url":"https://codeload.github.com/dirs-dev/dirs-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213893313,"owners_count":15653524,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["knownfolders","xdg-basedir","xdg-user-dirs"],"created_at":"2024-08-04T08:02:22.219Z","updated_at":"2025-05-16T17:32:30.690Z","avatar_url":"https://github.com/dirs-dev.png","language":"Rust","readme":"[![crates.io](https://img.shields.io/crates/v/dirs.svg?style=for-the-badge)](https://crates.io/crates/dirs)\n[![API documentation](https://img.shields.io/docsrs/dirs/latest?style=for-the-badge)](https://docs.rs/dirs/)\n![actively developed](https://img.shields.io/badge/maintenance-actively--developed-brightgreen.svg?style=for-the-badge)\n![License: MIT/Apache-2.0](https://img.shields.io/badge/license-MIT%2FApache--2.0-orange.svg?style=for-the-badge)\n\n# `dirs`\n\n## Introduction\n\n- a tiny low-level library with a minimal API\n- that provides the platform-specific, user-accessible locations\n- for retrieving and storing configuration, cache and other data\n- on Linux, Redox, Windows (≥ Vista), macOS and other platforms.\n\nThe library provides the location of these directories by leveraging the mechanisms defined by\n- the [XDG base directory](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html) and\n  the [XDG user directory](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/) specifications on Linux and Redox\n- the [Known Folder](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457.aspx) API on Windows\n- the [Standard Directories](https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW6)\n  guidelines on macOS\n\n## Platforms\n\nThis library is written in Rust, and supports Linux, Redox, macOS and Windows.\nOther platforms are also supported; they use the Linux conventions.\n\nThe minimal required version of Rust is 1.13 except for Redox, where the minimum Rust version\ndepends on the [`redox_users`](https://crates.io/crates/redox_users) crate.\n\nIt's mid-level sister library, _directories_, is available for Rust ([directories-rs](https://github.com/dirs-dev/directories-rs))\nand on the JVM ([directories-jvm](https://github.com/dirs-dev/directories-jvm)).\n\n## Usage\n\n#### Dependency\n\nAdd the library as a dependency to your project by inserting\n\n```toml\ndirs = \"5.0\"\n```\n\ninto the `[dependencies]` section of your Cargo.toml file.\n\nIf you are upgrading from version 2, please read the [section on breaking changes](#3) first.\n\n#### Example\n\nLibrary run by user Alice:\n\n```rust\nextern crate dirs;\n\ndirs::home_dir();\n// Lin: Some(/home/alice)\n// Win: Some(C:\\Users\\Alice)\n// Mac: Some(/Users/Alice)\n\ndirs::audio_dir();\n// Lin: Some(/home/alice/Music)\n// Win: Some(C:\\Users\\Alice\\Music)\n// Mac: Some(/Users/Alice/Music)\n\ndirs::config_dir();\n// Lin: Some(/home/alice/.config)\n// Win: Some(C:\\Users\\Alice\\AppData\\Roaming)\n// Mac: Some(/Users/Alice/Library/Application Support)\n\ndirs::executable_dir();\n// Lin: Some(/home/alice/.local/bin)\n// Win: None\n// Mac: None\n```\n\n## Design Goals\n\n- The _dirs_ library is a low-level crate designed to provide the paths to standard directories\n  as defined by operating systems rules or conventions.\u003cbr/\u003e\n  If your requirements are more complex, e. g. computing cache, config, etc. paths for specific\n  applications or projects, consider using [directories](https://github.com/dirs-dev/directories-rs)\n  instead.\n- This library does not create directories or check for their existence. The library only provides\n  information on what the path to a certain directory _should_ be.\u003cbr/\u003e\n  How this information is used is a decision that developers need to make based on the requirements\n  of each individual application.\n- This library is intentionally focused on providing information on user-writable directories only,\n  as there is no discernible benefit in returning a path that points to a user-level, writable\n  directory on one operating system, but a system-level, read-only directory on another.\u003cbr/\u003e\n  The confusion and unexpected failure modes of such an approach would be immense.\n  - `executable_dir` is specified to provide the path to a user-writable directory for binaries.\u003cbr/\u003e\n    As such a directory only commonly exists on Linux, it returns `None` on macOS and Windows.\n  - `font_dir` is specified to provide the path to a user-writable directory for fonts.\u003cbr/\u003e\n    As such a directory only exists on Linux and macOS, it returns `None` on Windows.\n  - `runtime_dir` is specified to provide the path to a directory for non-essential runtime data.\n    It is required that this directory is created when the user logs in, is only accessible by the\n    user itself, is deleted when the user logs out, and supports all filesystem features of the\n    operating system.\u003cbr/\u003e\n    As such a directory only commonly exists on Linux, it returns `None` on macOS and Windows.\n\n## Features\n\n**If you want to compute the location of cache, config or data directories for your own application or project,\nuse `ProjectDirs` of the [directories](https://github.com/dirs-dev/directories-rs) project instead.**\n\n| Function name      | Value on Linux/Redox                                                   | Value on Windows                  | Value on macOS                              |\n|--------------------| ---------------------------------------------------------------------- |-----------------------------------| ------------------------------------------- |\n| `home_dir`         | `Some($HOME)`                                                          | `Some({FOLDERID_Profile})`        | `Some($HOME)`                               |\n| `cache_dir`        | `Some($XDG_CACHE_HOME)`         or `Some($HOME`/.cache`)`              | `Some({FOLDERID_LocalAppData})`   | `Some($HOME`/Library/Caches`)`              |\n| `config_dir`       | `Some($XDG_CONFIG_HOME)`        or `Some($HOME`/.config`)`             | `Some({FOLDERID_RoamingAppData})` | `Some($HOME`/Library/Application Support`)` |\n| `config_local_dir` | `Some($XDG_CONFIG_HOME)`        or `Some($HOME`/.config`)`             | `Some({FOLDERID_LocalAppData})`   | `Some($HOME`/Library/Application Support`)` |\n| `data_dir`         | `Some($XDG_DATA_HOME)`          or `Some($HOME`/.local/share`)`        | `Some({FOLDERID_RoamingAppData})` | `Some($HOME`/Library/Application Support`)` |\n| `data_local_dir`   | `Some($XDG_DATA_HOME)`          or `Some($HOME`/.local/share`)`        | `Some({FOLDERID_LocalAppData})`   | `Some($HOME`/Library/Application Support`)` |\n| `executable_dir`   | `Some($XDG_BIN_HOME)`           or `Some($HOME`/.local/bin`)`          | `None`                            | `None`                                      |\n| `preference_dir`   | `Some($XDG_CONFIG_HOME)`        or `Some($HOME`/.config`)`             | `Some({FOLDERID_RoamingAppData})` | `Some($HOME`/Library/Preferences`)`         |\n| `runtime_dir`      | `Some($XDG_RUNTIME_DIR)`        or `None`                              | `None`                            | `None`                                      |\n| `state_dir`        | `Some($XDG_STATE_HOME)`         or `Some($HOME`/.local/state`)`        | `None`                            | `None`                                      |\n| `audio_dir`        | `Some(XDG_MUSIC_DIR)`           or `None`                              | `Some({FOLDERID_Music})`          | `Some($HOME`/Music/`)`                      |\n| `desktop_dir`      | `Some(XDG_DESKTOP_DIR)`         or `None`                              | `Some({FOLDERID_Desktop})`        | `Some($HOME`/Desktop/`)`                    |\n| `document_dir`     | `Some(XDG_DOCUMENTS_DIR)`       or `None`                              | `Some({FOLDERID_Documents})`      | `Some($HOME`/Documents/`)`                  |\n| `download_dir`     | `Some(XDG_DOWNLOAD_DIR)`        or `None`                              | `Some({FOLDERID_Downloads})`      | `Some($HOME`/Downloads/`)`                  |\n| `font_dir`         | `Some($XDG_DATA_HOME`/fonts/`)` or `Some($HOME`/.local/share/fonts/`)` | `None`                            | `Some($HOME`/Library/Fonts/`)`              |\n| `picture_dir`      | `Some(XDG_PICTURES_DIR)`        or `None`                              | `Some({FOLDERID_Pictures})`       | `Some($HOME`/Pictures/`)`                   |\n| `public_dir`       | `Some(XDG_PUBLICSHARE_DIR)`     or `None`                              | `Some({FOLDERID_Public})`         | `Some($HOME`/Public/`)`                     |\n| `template_dir`     | `Some(XDG_TEMPLATES_DIR)`       or `None`                              | `Some({FOLDERID_Templates})`      | `None`                                      |\n| `video_dir`        | `Some(XDG_VIDEOS_DIR)`          or `None`                              | `Some({FOLDERID_Videos})`         | `Some($HOME`/Movies/`)`                     |\n\n## Comparison\n\nThere are other crates in the Rust ecosystem that try similar or related things.\nHere is an overview of them, combined with ratings on properties that guided the design of this crate.\n\nPlease take this table with a grain of salt: a different crate might very well be more suitable for your specific use case.\n(Of course _my_ crate achieves _my_ design goals better than other crates, which might have had different design goals.)\n\n| Library                                                   | Status         | Lin | Mac | Win |Base|User|Proj|Conv|\n| --------------------------------------------------------- | -------------- |:---:|:---:|:---:|:--:|:--:|:--:|:--:|\n| [app_dirs](https://crates.io/crates/app_dirs)             | Unmaintained   |  ✔  |  ✔  |  ✔  | 🞈  | ✖  | ✔  | ✖  |\n| [app_dirs2](https://crates.io/crates/app_dirs2)           | Maintained     |  ✔  |  ✔  |  ✔  | 🞈  | ✖  | ✔  | ✖  |\n| **dirs**                                                  | **Developed**  |  ✔  |  ✔  |  ✔  | ✔  | ✔  | ✖  | ✔  |\n| [directories](https://crates.io/crates/directories)       | Developed      |  ✔  |  ✔  |  ✔  | ✔  | ✔  | ✔  | ✔  |\n| [s_app_dir](https://crates.io/crates/s_app_dir)           | Unmaintained?  |  ✔  |  ✖  |  🞈  | ✖  | ✖  | 🞈  | ✖  |\n| [standard_paths](https://crates.io/crates/standard_paths) | Maintained     |  ✔  |  ✖  |  ✔  | ✔  | ✔  | ✔  | ✖  |\n| [xdg](https://crates.io/crates/xdg)                       | Maintained     |  ✔  |  ✖  |  ✖  | ✔  | ✖  | ✔  | 🞈  |\n| [xdg-basedir](https://crates.io/crates/xdg-basedir)       | Unmaintained?  |  ✔  |  ✖  |  ✖  | ✔   | ✖  | ✖  | 🞈  |\n| [xdg-rs](https://crates.io/crates/xdg-rs)                 | Obsolete       |  ✔  |  ✖  |  ✖  | ✔   | ✖  | ✖  | 🞈  |\n\n- Lin: Linux support\n- Mac: macOS support\n- Win: Windows support\n- Base: Supports [generic base directories](https://github.com/dirs-dev/directories-rs#basedirs)\n- User: Supports [user directories](https://github.com/dirs-dev/directories-rs#userdirs)\n- Proj: Supports [project-specific base directories](https://github.com/dirs-dev/directories-rs#projectdirs)\n- Conv: Follows naming conventions of the operating system it runs on\n\n## Build\n\nIt's possible to cross-compile this library if the necessary toolchains are installed with rustup.\nThis is helpful to ensure a change hasn't broken code on a different platform.\n\nThe following commands will build this library on Linux, macOS and Windows:\n\n```\ncargo build --target=x86_64-unknown-linux-gnu\ncargo build --target=x86_64-pc-windows-gnu\ncargo build --target=x86_64-apple-darwin\ncargo build --target=x86_64-unknown-redox\n```\n\n## Changelog\n\n### 6\n\n- Update `dirs-sys` dependency to `0.5.0`, which in turn updates `windows-sys` dependency to `0.59.0`.\n\n### 5\n\n- Update `dirs-sys` dependency to `0.4.0`.\n- Add `config_local_dir` for non-roaming configuration on Windows. On non-Windows platforms the behavior is identical to `config dir`.\n\n### 4\n\n- **BREAKING CHANGE** The behavior of `executable_dir` has been adjusted to not depend on `$XDG_DATA_HOME`.\n  Code, which assumed that setting the `$XDG_DATA_HOME` environment variable also impacted `executable_dir` if\n  the `$XDG_BIN_HOME` environment variable was not set, requires adjustment.\n- Add support for `XDG_STATE_HOME`.\n\n### 3\n\n- **BREAKING CHANGE** The behavior of `config_dir` on macOS has been adjusted\n  (thanks to [everyone involved](https://github.com/dirs-dev/directories-rs/issues/62)):\n  - The existing `config_dir` function has been changed to return the `Application Support`\n    directory on macOS, as suggested by Apple documentation.\n  - The behavior of the `config_dir` function on non-macOS platforms has not been changed.\n  - If you have used the `config_dir` function to store files, it may be necessary to write code\n    that migrates the files to the new location on macOS.\u003cbr/\u003e\n    (Alternative: change uses of the `config_dir` function to uses of the `preference_dir` function\n    to retain the old behavior.)\n- The newly added `preference_dir` function returns the `Preferences` directory on macOS now,\n  which – according to Apple documentation – shall only be used to store .plist files using\n  Apple-proprietary APIs.\n  – `preference_dir` and `config_dir` behave identical on non-macOS platforms.\n\n### 2\n\n**BREAKING CHANGE** The behavior of deactivated, missing or invalid [_XDG User Dirs_](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)\nentries on Linux has been improved (contributed by @tmiasko, thank you!):\n\n- Version 1 returned the user's home directory (`Some($HOME)`) for such faulty entries, except for a faulty `XDG_DESKTOP_DIR` entry which returned (`Some($HOME/Desktop)`).\n- Version 2 returns `None` for such entries.\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0\n   ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license\n   ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirs-dev%2Fdirs-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirs-dev%2Fdirs-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirs-dev%2Fdirs-rs/lists"}