fix funky paths

This commit is contained in:
SpikeHD
2022-07-13 18:19:55 -07:00
parent fd87adc1f6
commit 375e15e947
2 changed files with 21 additions and 5 deletions

View File

@@ -8,5 +8,20 @@ export async function getGameExecutable() {
}
const pathArr = config.game_install_path.replace(/\\/g, '/').split('/')
return pathArr[pathArr.length - 1].replace('.exe', '')
return pathArr[pathArr.length - 1]
}
export async function getGameFolder() {
const config = await getConfig()
if(!config.game_install_path) {
return null
}
const pathArr = config.game_install_path.replace(/\\/g, '/').split('/')
pathArr.pop()
const path = pathArr.join('/')
return path
}

View File

@@ -1,13 +1,15 @@
import { invoke } from '@tauri-apps/api'
import { dataDir } from '@tauri-apps/api/path'
import { getConfig } from './configuration'
import { getGameExecutable } from './game'
import { getGameExecutable, getGameFolder } from './game'
export async function patchMetadata() {
const metadataExists = await invoke('dir_exists', {
path: getGameMetadataPath() + '\\global-metadata.dat'
path: await getGameMetadataPath() + '\\global-metadata.dat'
})
console.log(await getGameMetadataPath())
if (!metadataExists) {
return false
}
@@ -164,14 +166,13 @@ export async function unpatchGame() {
}
export async function getGameMetadataPath() {
const config = await getConfig()
const gameExec = await getGameExecutable()
if (!gameExec) {
return null
}
return config.game_install_path + '\\' + gameExec.replace('.exe', '_Data') + '\\Managed\\Metadata'
return (await getGameFolder() + '\\' + gameExec.replace('.exe', '_Data') + '\\Managed\\Metadata').replace(/\\/g, '/')
}
export async function getBackupMetadataPath() {