SongRec/Internal formats/preferences.toml: Difference between revisions
Appearance
| Line 10: | Line 10: | ||
The location for the <code>preferences.toml</code> file is calculated through the <code>[https://github.com/marin-m/SongRec/blob/0.6.9/src/utils/filesystem_operations.rs#L31 obtain_preferences_file_path]</code> function of <code>[https://github.com/marin-m/SongRec/blob/0.6.9/src/utils/filesystem_operations.rs src/utils/filesystem_operations.rs]</code>. | The location for the <code>preferences.toml</code> file is calculated through the <code>[https://github.com/marin-m/SongRec/blob/0.6.9/src/utils/filesystem_operations.rs#L31 obtain_preferences_file_path]</code> function of <code>[https://github.com/marin-m/SongRec/blob/0.6.9/src/utils/filesystem_operations.rs src/utils/filesystem_operations.rs]</code>. | ||
<syntaxhighlight lang="rust"> | |||
pub fn obtain_preferences_file_path() -> Result<String, Box<dyn Error>> { | |||
let project_dir = | |||
ProjectDirs::from(QUALIFIER, ORGANIZATION, APPLICATION).ok_or("No valid path")?; | |||
let mut preferences_file_path: PathBuf = obtain_preferences_directory(project_dir)?; | |||
preferences_file_path.push("preferences.toml"); | |||
Ok(preferences_file_path.to_str().unwrap().to_string()) | |||
} | |||
</syntaxhighlight> | |||
== Variables == | == Variables == | ||
(WIP 2026-05-05) | (WIP 2026-05-05) | ||
Revision as of 04:11, 6 May 2026
The preferences.toml file of SongRec is saved, under Linux, at the ~/.config/songrec/preferences.toml path by default, when using an unsandboxed environment.
It uses the TOML format.
It is written through by the src/core/preferences.rs utility file, which open the path of the preferences file through src/utils/filesystem_operations.rs.
Save location
(WIP 2026-05-05)
The location for the preferences.toml file is calculated through the obtain_preferences_file_path function of src/utils/filesystem_operations.rs.
pub fn obtain_preferences_file_path() -> Result<String, Box<dyn Error>> {
let project_dir =
ProjectDirs::from(QUALIFIER, ORGANIZATION, APPLICATION).ok_or("No valid path")?;
let mut preferences_file_path: PathBuf = obtain_preferences_directory(project_dir)?;
preferences_file_path.push("preferences.toml");
Ok(preferences_file_path.to_str().unwrap().to_string())
}
Variables
(WIP 2026-05-05)