Add cross-platform path handling (#89)

Add cross-platform path handling support

- Add sanitizePath, joinPath, buildOutputPath utilities
- Add operatingSystem to Settings interface
- Replace hardcoded Windows paths with dynamic path handling
- Support Windows, Linux, and macOS
This commit is contained in:
Ahmed Alghafri
2025-11-21 20:36:25 -07:00
committed by GitHub
parent bb9e2dcbb6
commit a49bb560bd
3 changed files with 51 additions and 18 deletions
+7 -2
View File
@@ -9,6 +9,7 @@ export interface Settings {
artistSubfolder: boolean;
albumSubfolder: boolean;
trackNumber: boolean;
operatingSystem: "Windows" | "linux/MacOS"
}
export const DEFAULT_SETTINGS: Settings = {
@@ -20,16 +21,20 @@ export const DEFAULT_SETTINGS: Settings = {
artistSubfolder: false,
albumSubfolder: false,
trackNumber: false,
operatingSystem: "Windows"
};
// TODO: add mac/linux defaults
const DEFAULT_PATH : string = "C:\\Users\\Public\\Music";
async function fetchDefaultPath(): Promise<string> {
try {
const data = await GetDefaults();
return data.downloadPath || "C:\\Users\\Public\\Music";
return data.downloadPath || DEFAULT_PATH;
} catch (error) {
console.error("Failed to fetch default path:", error);
}
return "C:\\Users\\Public\\Music";
return DEFAULT_PATH;
}
const SETTINGS_KEY = "spotiflac-settings";