add auto path detection

This commit is contained in:
2026-01-16 14:49:01 +01:00
parent 57f9bfb8cb
commit 3e1b938e9a
5 changed files with 38 additions and 6 deletions

14
main.js
View File

@@ -1,6 +1,7 @@
const { app, BrowserWindow , ipcMain} = require('electron/main');
const path = require('node:path');
const Store = require('electron-store').default;
const fs = require('fs/promises');
const store = new Store();
@@ -38,4 +39,17 @@ ipcMain.handle('save-path', (event, path) => {
ipcMain.handle('load-path', () => {
return store.get('silksong-path');
});
async function fileExists(filePath) {
try {
await fs.access(filePath);
return true;
} catch {
return false;
}
}
ipcMain.handle('file-exists', async (_, filePath) => {
return await fileExists(filePath);
});