update: directory structure for binary files

This commit is contained in:
alikia2x (寒寒) 2025-01-06 21:51:48 +08:00
parent 95fa5b4ac7
commit 496c00e7e3
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6
5 changed files with 18 additions and 11 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -1,6 +1,5 @@
import gulp from "gulp";
import ts from "gulp-typescript";
// @ts-ignore
import clean from "gulp-clean";
import fs from "fs";
@ -30,7 +29,7 @@ gulp.task("assets", () => {
});
gulp.task("binary", () => {
return gulp.src("bin/**/*", { encoding: false }).pipe(gulp.dest("dist/electron/bin"));
return gulp.src(`bin/${process.platform}-${process.arch}/**/*`, { encoding: false }).pipe(gulp.dest("dist/electron/bin"));
});
gulp.task("locales", () => {

View File

@ -2,17 +2,17 @@ import * as path from "path";
import { Database } from "better-sqlite3";
import DB from "better-sqlite3";
import { __dirname } from "../dirname.js";
import { getDatabaseDir } from "../utils/index.js";
import { getBinDir, getDatabaseDir } from "../utils/index.js";
import { migrate } from "./migrate/index.js";
function getLibSimpleExtensionPath() {
switch (process.platform) {
case "win32":
return path.join(__dirname, "bin", process.platform, "libsimple", "simple.dll");
return path.join(getBinDir(), "libsimple", "simple.dll");
case "darwin":
return path.join(__dirname, "bin", process.platform, "libsimple", "libsimple.dylib");
return path.join(getBinDir(), "libsimple", "libsimple.dylib");
case "linux":
return path.join(__dirname, "bin", process.platform, "libsimple", "libsimple.so");
return path.join(getBinDir(), "libsimple", "libsimple.so");
default:
throw new Error("Unsupported platform");
}

View File

@ -1,6 +1,7 @@
import path from "path";
import fs from "fs";
import { getUserDataDir } from "../platform/index.js";
import { __dirname } from "../../dirname.js";
export function createDataDir() {
const dataDir = getUserDataDir();
@ -68,6 +69,10 @@ export function getLogDir() {
return logDir;
}
export function getBinDir() {
return path.join(__dirname, "bin");
}
export async function waitForFileExists(filePath: string, timeout: number = 10000): Promise<void> {
return new Promise((resolve, reject) => {
fs.access(filePath, fs.constants.F_OK, (err) => {

View File

@ -1,8 +1,7 @@
import { join } from "path";
import os from "os";
import { app } from "electron";
import { __dirname } from "../../dirname.js";
import { logger } from "../index.js";
import { getBinDir, logger } from "../index.js";
export function getUserDataDir() {
switch (process.platform) {
@ -41,13 +40,13 @@ export function getFFmpegPath() {
let path = "";
switch (process.platform) {
case "win32":
path = join(__dirname, "bin", process.platform, "ffmpeg.exe");
path = join(getBinDir(), "ffmpeg.exe");
break;
case "darwin":
path = join(__dirname, "bin", process.platform, "ffmpeg");
path = join(getBinDir(), "ffmpeg");
break;
case "linux":
path = join(__dirname, "bin", process.platform, "ffmpeg");
path = join(getBinDir(), "ffmpeg");
break;
default:
throw new Error("Unsupported platform");
@ -55,3 +54,7 @@ export function getFFmpegPath() {
logger.info("FFmpeg path: %s", path);
return path;
}
export function getOCRitPath() {
const path = join(getBinDir(), "ocrit");
}