use std::path::PathBuf;
use std::fs;
use dirs;
pub fn jetbrains_paths() -> Vec<(PathBuf, &'static str)> {
let home = dirs::home_dir().unwrap_or_default();
let mut paths = vec![];
let cache_dir = home.join("Library/Caches/JetBrains");
if cache_dir.exists() {
if let Ok(entries) = fs::read_dir(&cache_dir) {
for entry in entries.flatten() {
let p = entry.path();
if p.is_dir() {
let name = p.file_name().unwrap_or_default().to_string_lossy().to_string();
paths.push((p, leak_string(format!("JetBrains {} cache", name))));
}
}
}
}
let log_dir = home.join("Library/Logs/JetBrains");
if log_dir.exists() {
paths.push((log_dir, "JetBrains logs"));
}
let toolbox = home.join("Library/Application Support/JetBrains/Toolbox");
if toolbox.exists() {
paths.push((toolbox, "JetBrains Toolbox data"));
}
paths
}
fn leak_string(s: String) -> &'static str {
Box::leak(s.into_boxed_str())
}