export function useFileStorage() {
    const writeFile = async (file: string, data : string | Buffer, inWorkingDir : boolean = true) => {
        const result = await window.electron.ipcRenderer.invoke('fileStorage:writeFile', file, data, inWorkingDir);
        return result;
    }

    const readFile = async (file : string, inWorkingDir : boolean = true) => {
        const result = await window.electron.ipcRenderer.invoke('fileStorage:readFile', file, inWorkingDir);
        return result;
    }

    const fileExists = async (file : string, inWorkingDir : boolean = true) => {
        const result = await window.electron.ipcRenderer.invoke('fileStorage:fileExists', file, inWorkingDir);
        return result;
    }

    const size = async (file : string, inWorkingDir : boolean = true) => {
        const result = await window.electron.ipcRenderer.invoke('fileStorage:size', file, inWorkingDir);
        return result;
    }

    return {writeFile, readFile, fileExists, size};
}