xdg
Version, currently main branch1 version
- main branchlatestMay 1, 2025
github.com/dsisnero/xdg
XDG directories for Crystal
1 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
xdg:
github: dsisnero/xdg
branch: mainmain is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
>= 1.15.1- License
- MIT
- Author
- Dominic Sisneros
- Target
xdgfrom src/xdg.cr
Dependencies
This version declares no dependencies.
README
xdg
Crystal implementation of the XDG Base Directory Specification with cross-platform support (Linux, macOS, Windows)
Provides standardized access to application configuration, data, and cache directories while respecting platform conventions and environment variables.
Installation
- Add the dependency to your
shard.yml:
dependencies:
xdg:
github: dsisnero/xdg
- Run
shards install
Usage
# Creates parent directories with 0700 permissions if missing
config_file = XDG.app_config_path("myapp.cfg", create: true)
# Writes file with automatic directory creation (0700 for new dirs)
File.write(config_file, config_data) rescue puts "Save failed"
# Runtime directory security (must be 0700)
runtime_dir = XDG.runtime_dir! # Raises if permissions wrong
Key features:
- Automatic directory creation with 0700 permissions
- Existing directories remain untouched
- Strict security checks only for runtime directory
- Clean error hierarchy (XDG::Error > DirectoryError/SecurityError)
Development
- Clone the repo:
git clone https://github.com/dsisnero/xdg.git - Install dependencies:
shards install - Run tests:
crystal spec
Key components:
src/xdg.cr: Core implementationspec/xdg_spec.cr: Comprehensive test suite- Platform-specific logic handled through compile-time flags
Contributing
- Fork it (https://github.com/dsisnero/xdg/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Please include:
- Spec tests for new features
- Updates to documentation when applicable
- Cross-platform verification
Contributors
- Dominic Sisneros - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
main- Seen
- May 1, 2025
- Crystal
>= 1.15.1- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/dsisnero/xdg
Metadata
- Created
- Aug 16, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 1