SongRec/Internal formats/song history.csv: Difference between revisions
Appearance
| Line 62: | Line 62: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == Columns == | ||
(WIP 2026-05-06) | (WIP 2026-05-06) | ||
Revision as of 07:25, 6 May 2026
The song_history.csv file of SongRec is saved, under Linux, at the ~/.local/share/songrec/song_history.csv path by default, when using an unsandboxed environment.
It uses the CSV format.
Save location
(WIP 2026-05-06)
The location for the song_history.csv file is calculated through the obtain_recognition_history_csv_path function of src/utils/filesystem_operations.rs.
Relevant code:
use app_dirs::{get_app_root, AppDataType::*, AppInfo};
use directories::ProjectDirs;
use std::error::Error;
use std::fs::create_dir_all;
#[cfg(not(windows))]
use std::os::unix::fs::symlink;
#[cfg(windows)]
use std::os::windows::fs::symlink_dir;
use std::path::PathBuf;
use std::sync::LazyLock;
const QUALIFIER: &str = "";
const ORGANIZATION: &str = "SongRec";
const APPLICATION: &str = "SongRec";
static PROJECT_DIRS: LazyLock<ProjectDirs> =
LazyLock::new(|| ProjectDirs::from(QUALIFIER, ORGANIZATION, APPLICATION).unwrap());
pub fn obtain_recognition_history_csv_path() -> Result<PathBuf, Box<dyn Error>> {
let mut csv_path = obtain_data_directory()?;
csv_path.push("song_history.csv");
Ok(csv_path)
}
fn obtain_data_directory() -> Result<PathBuf, Box<dyn Error>> {
let data_dir = PROJECT_DIRS.data_dir();
if !data_dir.exists() {
let old_dir = get_old_data_dir_path()?;
if old_dir.exists() {
#[cfg(not(windows))]
symlink(old_dir, data_dir)?;
#[cfg(windows)]
symlink_dir(old_dir, data_dir)?;
} else {
create_dir_all(data_dir)?;
}
}
Ok(data_dir.to_path_buf())
}
// Backwards compatibility
fn get_old_data_dir_path() -> Result<PathBuf, Box<dyn Error>> {
let app_info = AppInfo {
name: "SongRec",
author: "SongRec",
};
Ok(get_app_root(UserData, &app_info)?)
}
Columns
(WIP 2026-05-06)