Files
client/app/main/paths.js
T
omar 7287fdb63e
ci / linux-x64 (push) Failing after 1m26s
ci / linux-arm64-cross (push) Failing after 2m20s
TeamsPeach desktop client: Electron UI, Rust core bridge, TS6 stream viewer, CI
2026-10-24 03:31:54 +03:00

48 lines
1.5 KiB
JavaScript

'use strict';
const path = require('node:path');
const fs = require('node:fs');
const { app } = require('electron');
const CORE_FILE = process.platform === 'win32' ? 'teamspeach-core.exe' : 'teamspeach-core';
const APP_ROOT = path.resolve(__dirname, '..', '..');
const RENDERER_DIR = path.join(APP_ROOT, 'app', 'renderer');
/** Candidate locations of the native core. Only main decides these; nothing comes from the renderer. */
function coreCandidates() {
if (app.isPackaged) return [path.join(process.resourcesPath, 'core', CORE_FILE)];
return [
path.join(APP_ROOT, 'core', 'target', 'release', CORE_FILE),
path.join(APP_ROOT, 'core', 'target', 'debug', CORE_FILE),
];
}
/** Newest existing candidate wins in development so a fresh debug build is not shadowed by a stale release build. */
function resolveCoreBinary() {
const candidates = coreCandidates();
let best = null;
for (const candidate of candidates) {
try {
const stat = fs.statSync(candidate);
if (stat.isFile() && (!best || stat.mtimeMs > best.mtimeMs)) best = { path: candidate, mtimeMs: stat.mtimeMs };
} catch {
// missing candidate
}
}
return { path: best ? best.path : null, candidates };
}
function dataDir() {
return path.join(app.getPath('userData'), 'core');
}
function logsDir() {
return path.join(app.getPath('userData'), 'logs');
}
function prefsFile() {
return path.join(app.getPath('userData'), 'prefs.json');
}
module.exports = { APP_ROOT, RENDERER_DIR, CORE_FILE, resolveCoreBinary, dataDir, logsDir, prefsFile };