mirror of
https://github.com/mileswolfallen2/OmniEmu2.0.git
synced 2026-12-06 08:33:53 +00:00
fix license
This commit is contained in:
1 parent
9a3594ce3b
commit
2e0ec5f70c
5 files changed
+97
-365
No files matched your search
+24
-4
@@ -633,20 +633,40 @@ async function extractArchive(
|
||||
decompId: string,
|
||||
): Promise<void> {
|
||||
const { execSync } = require('child_process');
|
||||
const platform = process.platform;
|
||||
|
||||
try {
|
||||
if (archiveName.endsWith('.zip')) {
|
||||
onProgress({ decompId, stage: 'extracting', percent: 75, message: 'Extracting zip archive...' });
|
||||
execSync(`unzip -o "${archivePath}" -d "${destDir}"`, { timeout: 300000 });
|
||||
if (platform === 'win32') {
|
||||
// Windows: use PowerShell Expand-Archive, fallback to 7z
|
||||
try {
|
||||
execSync(`powershell -NoProfile -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${destDir}' -Force"`, { timeout: 300000 });
|
||||
} catch {
|
||||
// Fallback: try 7z for zip
|
||||
try {
|
||||
const sevenZip = require('7zip-bin').path7za;
|
||||
execSync(`"${sevenZip}" x "${archivePath}" -o"${destDir}" -y`, { timeout: 300000 });
|
||||
} catch {
|
||||
execSync(`7z x "${archivePath}" -o"${destDir}" -y`, { timeout: 300000 });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
execSync(`unzip -o "${archivePath}" -d "${destDir}"`, { timeout: 300000 });
|
||||
}
|
||||
} else if (archiveName.endsWith('.tar.gz') || archiveName.endsWith('.tgz')) {
|
||||
onProgress({ decompId, stage: 'extracting', percent: 75, message: 'Extracting tar archive...' });
|
||||
execSync(`tar -xzf "${archivePath}" -C "${destDir}"`, { timeout: 300000 });
|
||||
} else if (archiveName.endsWith('.7z')) {
|
||||
onProgress({ decompId, stage: 'extracting', percent: 75, message: 'Extracting 7z archive...' });
|
||||
const sevenZip = join(require('app-root-path').toString(), 'node_modules', '7zip-bin', 'vendor', '7z');
|
||||
if (existsSync(sevenZip)) {
|
||||
// Try bundled 7za first, then system 7z
|
||||
let extracted = false;
|
||||
try {
|
||||
const sevenZip = require('7zip-bin').path7za;
|
||||
execSync(`"${sevenZip}" x "${archivePath}" -o"${destDir}" -y`, { timeout: 300000 });
|
||||
} else {
|
||||
extracted = true;
|
||||
} catch { /* bundled 7za failed */ }
|
||||
if (!extracted) {
|
||||
execSync(`7z x "${archivePath}" -o"${destDir}" -y`, { timeout: 300000 });
|
||||
}
|
||||
}
|
||||
|
||||
+44
-3
@@ -127,6 +127,48 @@ function get7zaPath(): string {
|
||||
}
|
||||
}
|
||||
|
||||
/** Extract a .7z archive, trying bundled 7za then system 7z */
|
||||
async function extract7z(archivePath: string, destDir: string): Promise<void> {
|
||||
// Try bundled 7za from 7zip-bin
|
||||
try {
|
||||
const sevenZa = get7zaPath();
|
||||
await runAsync(sevenZa, ['x', archivePath, `-o${destDir}`, '-y']);
|
||||
return;
|
||||
} catch { /* bundled binary failed, try system fallback */ }
|
||||
|
||||
// Try system-installed 7z
|
||||
try {
|
||||
await runAsync('7z', ['x', archivePath, `-o${destDir}`, '-y']);
|
||||
return;
|
||||
} catch { /* system 7z not available */ }
|
||||
|
||||
throw new Error('7z extraction failed — no working 7z binary found (bundled or system)');
|
||||
}
|
||||
|
||||
/** Extract a .zip archive with Windows fallback */
|
||||
async function extractZip(archivePath: string, destDir: string): Promise<void> {
|
||||
if (isWindows()) {
|
||||
// Windows: try PowerShell Expand-Archive first, then 7z, then bundled 7za
|
||||
try {
|
||||
const psPath = join(destDir);
|
||||
await runAsync('powershell', [
|
||||
'-NoProfile', '-Command',
|
||||
`Expand-Archive -Path '${archivePath}' -DestinationPath '${psPath}' -Force`,
|
||||
]);
|
||||
return;
|
||||
} catch { /* PowerShell Expand-Archive failed */ }
|
||||
|
||||
// Fallback: try 7z for zip extraction
|
||||
try {
|
||||
await extract7z(archivePath, destDir);
|
||||
return;
|
||||
} catch { /* 7z not available */ }
|
||||
}
|
||||
|
||||
// macOS/Linux: use unzip
|
||||
await runAsync('unzip', ['-o', archivePath, '-d', destDir]);
|
||||
}
|
||||
|
||||
async function extractArchive(
|
||||
archivePath: string,
|
||||
destDir: string,
|
||||
@@ -139,7 +181,7 @@ async function extractArchive(
|
||||
|
||||
switch (format) {
|
||||
case 'zip':
|
||||
await runAsync('unzip', ['-o', archivePath, '-d', destDir]);
|
||||
await extractZip(archivePath, destDir);
|
||||
break;
|
||||
case 'tar.gz':
|
||||
await runAsync('tar', ['-xzf', archivePath, '-C', destDir]);
|
||||
@@ -151,8 +193,7 @@ async function extractArchive(
|
||||
await runAsync('tar', ['-xJf', archivePath, '-C', destDir]);
|
||||
break;
|
||||
case '7z': {
|
||||
const sevenZa = get7zaPath();
|
||||
await runAsync(sevenZa, ['x', archivePath, `-o${destDir}`, '-y']);
|
||||
await extract7z(archivePath, destDir);
|
||||
break;
|
||||
}
|
||||
case 'dmg': {
|
||||
|
||||
+12
-2
@@ -41,6 +41,16 @@ function resolveRetroarchSaveDirs(): SaveDirConfig {
|
||||
|
||||
if (platform === 'win32') {
|
||||
candidates.push(join(process.env.APPDATA || join(home, 'AppData', 'Roaming'), 'RetroArch'));
|
||||
// Standalone/portable RetroArch on Windows: saves live next to retroarch.exe
|
||||
// Check the emulator's install directory from settings
|
||||
try {
|
||||
const emuDir = settings.get().emulatorsDirectory || join(home, 'OmniEmu', 'emulators');
|
||||
const portableRetroarch = join(emuDir, 'retroarch');
|
||||
if (existsSync(portableRetroarch)) candidates.push(portableRetroarch);
|
||||
} catch { /* ignore */ }
|
||||
// Also check common standalone locations
|
||||
candidates.push(join('C:', 'Program Files', 'RetroArch'));
|
||||
candidates.push(join('C:', 'Program Files (x86)', 'RetroArch'));
|
||||
} else if (platform === 'darwin') {
|
||||
candidates.push(join(home, 'Library', 'Application Support', 'RetroArch'));
|
||||
candidates.push(join(home, 'Documents', 'RetroArch'));
|
||||
@@ -65,13 +75,13 @@ function resolveRetroarchSaveDirs(): SaveDirConfig {
|
||||
let states: string | undefined;
|
||||
|
||||
if (saveDir && saveDir !== 'default') {
|
||||
saves = saveDir.startsWith('/') ? saveDir : join(dir, saveDir);
|
||||
saves = (saveDir.startsWith('/') || /^[A-Za-z]:\\/.test(saveDir)) ? saveDir : join(dir, saveDir);
|
||||
} else {
|
||||
saves = join(dir, 'saves');
|
||||
}
|
||||
|
||||
if (stateDir && stateDir !== 'default') {
|
||||
states = stateDir.startsWith('/') ? stateDir : join(dir, stateDir);
|
||||
states = (stateDir.startsWith('/') || /^[A-Za-z]:\\/.test(stateDir)) ? stateDir : join(dir, stateDir);
|
||||
} else {
|
||||
states = join(dir, 'states');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user