Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Latest commit

 

History

History
54 lines (41 loc) · 1.63 KB

README.md

File metadata and controls

54 lines (41 loc) · 1.63 KB

cachedir(DEPRECATED), please use dirs instead: https://crates.io/crates/dirs

Replicating the example below, in dirs:

let cache_dir = dirs::cache_dir().ok_or(
    std::io::Error::new(std::io::ErrorKind::Other, "This OS is not supported")
)?.join("CacheName");

std::fs::create_dir_all(&cache_dir).map_err(|err| {
    eprintln!("Failed to create cache dir \"{}\": {}", cache_dir.display(), err);
    err
})?;

Build Status Build status

Documentation

Status: finished


A Rust library that helps with cache directories creation in a system-agnostic way.

Note: even though the crate is at version 0.1, it should be stable and its API is not expected to change soon.

Dual-licensed under MIT or the UNLICENSE.

Usage

Add this to your Cargo.toml:

[dependencies]
cachedir = "0.1"

Example

extern crate cachedir;

use cachedir::CacheDirConfig;

fn main() {
    let cache_dir = CacheDirConfig::new("CacheName")
                                   .get_cache_dir()
                                   .unwrap();

    println!("{}", cache_dir.display());
}

This creates CacheName into the user's cache directory.
For more information on the types of caches and code examples, please check the documentation.