| 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 |
|
| 20 |
use gtk::glib; |
| 21 |
use once_cell::sync::Lazy; |
| 22 |
|
| 23 |
use crate::config; |
| 24 |
|
| 25 |
pub static DATA: Lazy<PathBuf> = Lazy::new(|| glib::user_data_dir().join(config::PKGNAME)); |
| 26 |
pub static CONFIG: Lazy<PathBuf> = Lazy::new(|| glib::user_config_dir().join(config::PKGNAME)); |
| 27 |
pub static CACHE: Lazy<PathBuf> = Lazy::new(|| glib::user_cache_dir().join(config::PKGNAME)); |
| 28 |
|
| 29 |
pub fn init() -> std::io::Result<()> { |
| 30 |
fs::create_dir_all(DATA.to_owned())?; |
| 31 |
fs::create_dir_all(CONFIG.to_owned())?; |
| 32 |
fs::create_dir_all(CACHE.to_owned())?; |
| 33 |
Ok(()) |
| 34 |
} |