Debian Codegraph @

src/path.rs

raw ◀ ▶
1 Debian patch touch this file
1 // Fragments - path.rs
2 // Copyright (C) 2022 Felix Häcker <[email protected]>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17 use std::fs;
18 use std::path::PathBuf;
•19 use std::sync::LazyLock;
20
21 use gtk::glib;
22
23 use crate::config;
24
•25 pub static DATA: LazyLock<PathBuf> = LazyLock::new(|| glib::user_data_dir().join(config::PKGNAME));
26 pub static CONFIG: LazyLock<PathBuf> =
27 LazyLock::new(|| glib::user_config_dir().join(config::PKGNAME));
28 pub static CACHE: LazyLock<PathBuf> =
29 LazyLock::new(|| glib::user_cache_dir().join(config::PKGNAME));
30
31 pub fn init() -> std::io::Result<()> {
32 fs::create_dir_all(DATA.to_owned())?;
33 fs::create_dir_all(CONFIG.to_owned())?;
34 fs::create_dir_all(CACHE.to_owned())?;
35 Ok(())
36 }