mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-20 01:33:56 +00:00
28 lines
677 B
TypeScript
28 lines
677 B
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { app } from "electron";
|
|
import { registerEvent } from "../register-event";
|
|
|
|
const saveTempFile = async (
|
|
_event: Electron.IpcMainInvokeEvent,
|
|
fileName: string,
|
|
fileData: Uint8Array
|
|
): Promise<string> => {
|
|
try {
|
|
const tempDir = app.getPath("temp");
|
|
const tempFilePath = path.join(
|
|
tempDir,
|
|
`hydra-temp-${Date.now()}-${fileName}`
|
|
);
|
|
|
|
// Write the file data to temp directory
|
|
fs.writeFileSync(tempFilePath, fileData);
|
|
|
|
return tempFilePath;
|
|
} catch (error) {
|
|
throw new Error(`Failed to save temp file: ${error}`);
|
|
}
|
|
};
|
|
|
|
registerEvent("saveTempFile", saveTempFile);
|