mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-02-01 19:15:07 +01:00
feat: adding initial download sources
This commit is contained in:
38
src/main/services/7zip.ts
Normal file
38
src/main/services/7zip.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { app } from "electron";
|
||||
import cp from "node:child_process";
|
||||
import path from "node:path";
|
||||
|
||||
export const binaryName = {
|
||||
linux: "7zzs",
|
||||
darwin: "7zz",
|
||||
win32: "7zr.exe",
|
||||
};
|
||||
|
||||
export class _7Zip {
|
||||
private static readonly binaryPath = app.isPackaged
|
||||
? path.join(process.resourcesPath, binaryName[process.platform])
|
||||
: path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"..",
|
||||
"binaries",
|
||||
binaryName[process.platform]
|
||||
);
|
||||
|
||||
public static extractFile(
|
||||
filePath: string,
|
||||
outputPath: string,
|
||||
cb: () => void
|
||||
) {
|
||||
const child = cp.spawn(this.binaryPath, [
|
||||
"x",
|
||||
filePath,
|
||||
"-o" + outputPath,
|
||||
"-y",
|
||||
]);
|
||||
|
||||
child.on("exit", () => {
|
||||
cb();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user