mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 22:06:17 +00:00
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import { app, dialog } from "electron";
|
|
import { logger } from "./logger";
|
|
|
|
export class SystemPath {
|
|
static readonly paths = {
|
|
userData: "userData",
|
|
downloads: "downloads",
|
|
documents: "documents",
|
|
desktop: "desktop",
|
|
home: "home",
|
|
appData: "appData",
|
|
temp: "temp",
|
|
};
|
|
|
|
static checkIfPathsAreAvailable() {
|
|
const paths = Object.keys(
|
|
SystemPath.paths
|
|
) as (keyof typeof SystemPath.paths)[];
|
|
|
|
paths.forEach((pathName) => {
|
|
try {
|
|
app.getPath(pathName);
|
|
} catch (error) {
|
|
logger.error(`Error getting path ${pathName}`);
|
|
if (error instanceof Error) {
|
|
logger.error(error.message, error.stack);
|
|
}
|
|
|
|
dialog.showErrorBox(
|
|
`Hydra was not able to find path for '${pathName}' system folder`,
|
|
`Some functionalities may not work as expected.\nPlease check your system settings.`
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
static getPath(pathName: keyof typeof SystemPath.paths): string {
|
|
try {
|
|
return app.getPath(pathName);
|
|
} catch (error) {
|
|
console.error(`Error getting path: ${error}`);
|
|
return "";
|
|
}
|
|
}
|
|
}
|