Fix paths

Replaced backslashes in paths with slashes. I did
not touch function that do the same with paths.
Those can be removed manually.
Also dataDir() returns a path that ends with a
slash so I got rid of duplicated slashes.
This commit is contained in:
fnrir 2023-06-24 14:09:22 +02:00
parent 882bad370f
commit 3ba467d03b
11 changed files with 38 additions and 38 deletions

View File

@ -1,3 +1,3 @@
{ {
"rust-analyzer.linkedProjects": [".\\src-tauri\\Cargo.toml"] "rust-analyzer.linkedProjects": ["src-tauri/Cargo.toml"]
} }

View File

@ -1,5 +1,5 @@
{ {
"$schema": "..\\node_modules/@tauri-apps/cli\\schema.json", "$schema": "../node_modules/@tauri-apps/cli/schema.json",
"build": { "build": {
"beforeDevCommand": "yarn start", "beforeDevCommand": "yarn start",
"devPath": "http://localhost:3000", "devPath": "http://localhost:3000",

View File

@ -15,7 +15,7 @@ async function setProxyAddress(address: string) {
} }
async function startProxy() { async function startProxy() {
await invoke('connect', { port: 2222, certificatePath: (await dataDir()) + '\\cultivation\\ca' }) await invoke('connect', { port: 2222, certificatePath: (await dataDir()) + 'cultivation/ca' })
await invoke('open_in_browser', { url: 'https://hoyoverse.com' }) await invoke('open_in_browser', { url: 'https://hoyoverse.com' })
} }
@ -24,12 +24,12 @@ async function stopProxy() {
} }
async function generateCertificates() { async function generateCertificates() {
await invoke('generate_ca_files', { path: (await dataDir()) + '\\cultivation' }) await invoke('generate_ca_files', { path: (await dataDir()) + 'cultivation' })
} }
async function generateInfo() { async function generateInfo() {
console.log({ console.log({
certificatePath: (await dataDir()) + '\\cultivation\\ca', certificatePath: (await dataDir()) + 'cultivation/ca',
isAdmin: await invoke('is_elevated'), isAdmin: await invoke('is_elevated'),
connectingTo: proxyAddress, connectingTo: proxyAddress,
}) })

View File

@ -166,7 +166,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
addr: (this.state.httpsEnabled ? 'https' : 'http') + '://' + this.state.ip + ':' + this.state.port, addr: (this.state.httpsEnabled ? 'https' : 'http') + '://' + this.state.ip + ':' + this.state.port,
}) })
// Connect to proxy // Connect to proxy
await invoke('connect', { port: 8365, certificatePath: (await dataDir()) + '\\cultivation\\ca' }) await invoke('connect', { port: 8365, certificatePath: (await dataDir()) + 'cultivation/ca' })
} }
// Open server as well if the options are set // Open server as well if the options are set

View File

@ -85,15 +85,15 @@ export default class Downloads extends React.Component<IProps, IState> {
return return
} }
const path = gc_path.substring(0, gc_path.lastIndexOf('\\')) const path = gc_path.substring(0, gc_path.lastIndexOf('/'))
if (gc_path) { if (gc_path) {
const resources_exist: boolean = const resources_exist: boolean =
((await invoke('dir_exists', { ((await invoke('dir_exists', {
path: path + '\\resources', path: path + '/resources',
})) as boolean) && })) as boolean) &&
(!(await invoke('dir_is_empty', { (!(await invoke('dir_is_empty', {
path: path + '\\resources', path: path + '/resources',
})) as boolean) })) as boolean)
this.setState({ this.setState({
@ -110,7 +110,7 @@ export default class Downloads extends React.Component<IProps, IState> {
// Set to default if not set // Set to default if not set
if (!path || path === '') { if (!path || path === '') {
const appdata = await dataDir() const appdata = await dataDir()
folderPath = appdata + 'cultivation\\grasscutter' folderPath = appdata + 'cultivation/grasscutter'
// Early return since its formatted properly // Early return since its formatted properly
return folderPath return folderPath
@ -133,8 +133,8 @@ export default class Downloads extends React.Component<IProps, IState> {
async downloadGrasscutterFullBuild() { async downloadGrasscutterFullBuild() {
const folder = await this.getGrasscutterFolder() const folder = await this.getGrasscutterFolder()
this.props.downloadManager.addDownload(FULL_BUILD_DOWNLOAD, folder + '\\GrasscutterCulti.zip', async () => { this.props.downloadManager.addDownload(FULL_BUILD_DOWNLOAD, folder + '/GrasscutterCulti.zip', async () => {
await unzip(folder + '\\GrasscutterCulti.zip', folder + '\\', true) await unzip(folder + '/GrasscutterCulti.zip', folder + '/', true)
this.toggleButtons() this.toggleButtons()
}) })
@ -143,8 +143,8 @@ export default class Downloads extends React.Component<IProps, IState> {
async downloadGrasscutterFullQuest() { async downloadGrasscutterFullQuest() {
const folder = await this.getGrasscutterFolder() const folder = await this.getGrasscutterFolder()
this.props.downloadManager.addDownload(FULL_QUEST_DOWNLOAD, folder + '\\GrasscutterQuests.zip', async () => { this.props.downloadManager.addDownload(FULL_QUEST_DOWNLOAD, folder + '/GrasscutterQuests.zip', async () => {
await unzip(folder + '\\GrasscutterQuests.zip', folder + '\\', true) await unzip(folder + '/GrasscutterQuests.zip', folder + '/', true)
this.toggleButtons() this.toggleButtons()
}) })
@ -153,8 +153,8 @@ export default class Downloads extends React.Component<IProps, IState> {
async downloadGrasscutterStableRepo() { async downloadGrasscutterStableRepo() {
const folder = await this.getGrasscutterFolder() const folder = await this.getGrasscutterFolder()
this.props.downloadManager.addDownload(STABLE_REPO_DOWNLOAD, folder + '\\grasscutter_repo.zip', async () => { this.props.downloadManager.addDownload(STABLE_REPO_DOWNLOAD, folder + '/grasscutter_repo.zip', async () => {
await unzip(folder + '\\grasscutter_repo.zip', folder + '\\', true) await unzip(folder + '/grasscutter_repo.zip', folder + '/', true)
this.toggleButtons() this.toggleButtons()
}) })
@ -163,8 +163,8 @@ export default class Downloads extends React.Component<IProps, IState> {
async downloadGrasscutterDevRepo() { async downloadGrasscutterDevRepo() {
const folder = await this.getGrasscutterFolder() const folder = await this.getGrasscutterFolder()
this.props.downloadManager.addDownload(DEV_REPO_DOWNLOAD, folder + '\\grasscutter_repo.zip', async () => { this.props.downloadManager.addDownload(DEV_REPO_DOWNLOAD, folder + '/grasscutter_repo.zip', async () => {
await unzip(folder + '\\grasscutter_repo.zip', folder + '\\', true) await unzip(folder + '/grasscutter_repo.zip', folder + '/', true)
this.toggleButtons() this.toggleButtons()
}) })
@ -173,8 +173,8 @@ export default class Downloads extends React.Component<IProps, IState> {
async downloadGrasscutterLatest() { async downloadGrasscutterLatest() {
const folder = await this.getGrasscutterFolder() const folder = await this.getGrasscutterFolder()
this.props.downloadManager.addDownload(DEV_DOWNLOAD, folder + '\\grasscutter.zip', async () => { this.props.downloadManager.addDownload(DEV_DOWNLOAD, folder + '/grasscutter.zip', async () => {
await unzip(folder + '\\grasscutter.zip', folder + '\\', true) await unzip(folder + '/grasscutter.zip', folder + '/', true)
this.toggleButtons() this.toggleButtons()
}) })
@ -190,22 +190,22 @@ export default class Downloads extends React.Component<IProps, IState> {
'Extracting resources can take time! If your resources appear to be "stuck" extracting for less than 15-20 mins, they likely still are extracting.' 'Extracting resources can take time! If your resources appear to be "stuck" extracting for less than 15-20 mins, they likely still are extracting.'
) )
const folder = await this.getGrasscutterFolder() const folder = await this.getGrasscutterFolder()
this.props.downloadManager.addDownload(RESOURCES_DOWNLOAD, folder + '\\resources.zip', async () => { this.props.downloadManager.addDownload(RESOURCES_DOWNLOAD, folder + '/resources.zip', async () => {
// Delete the existing folder if it exists // Delete the existing folder if it exists
if ( if (
await invoke('dir_exists', { await invoke('dir_exists', {
path: folder + '\\resources', path: folder + '/resources',
}) })
) { ) {
await invoke('dir_delete', { await invoke('dir_delete', {
path: folder + '\\resources', path: folder + '/resources',
}) })
} }
await unzip(folder + '\\resources.zip', folder + '\\', true) await unzip(folder + '/resources.zip', folder + '/', true)
// Rename folder to resources // Rename folder to resources
invoke('rename', { invoke('rename', {
path: folder + '\\Resources', path: folder + '/Resources',
newName: 'resources', newName: 'resources',
}) })
@ -216,13 +216,13 @@ export default class Downloads extends React.Component<IProps, IState> {
} }
async downloadMigoto() { async downloadMigoto() {
const folder = (await this.getCultivationFolder()) + '\\3dmigoto' const folder = (await this.getCultivationFolder()) + '/3dmigoto'
await invoke('dir_create', { await invoke('dir_create', {
path: folder, path: folder,
}) })
this.props.downloadManager.addDownload(MIGOTO_DOWNLOAD, folder + '\\GIMI-3dmigoto.zip', async () => { this.props.downloadManager.addDownload(MIGOTO_DOWNLOAD, folder + '/GIMI-3dmigoto.zip', async () => {
await unzip(folder + '\\GIMI-3dmigoto.zip', folder + '\\', true) await unzip(folder + '/GIMI-3dmigoto.zip', folder + '/', true)
this.toggleButtons() this.toggleButtons()
}) })

View File

@ -45,8 +45,8 @@ export default class Downloads extends React.Component<IProps, IState> {
async downloadGame() { async downloadGame() {
const folder = this.state.gameDownloadFolder const folder = this.state.gameDownloadFolder
this.props.downloadManager.addDownload(GAME_DOWNLOAD, folder + '\\game.zip', async () => { this.props.downloadManager.addDownload(GAME_DOWNLOAD, folder + '/game.zip', async () => {
await unzip(folder + '\\game.zip', folder + '\\', true) await unzip(folder + '/game.zip', folder + '/', true)
this.setState({ this.setState({
gameDownloading: false, gameDownloading: false,
}) })

View File

@ -240,7 +240,7 @@ export default class Options extends React.Component<IProps, IState> {
if (!isUrl) { if (!isUrl) {
const filename = value.replace(/\\/g, '/').split('/').pop() const filename = value.replace(/\\/g, '/').split('/').pop()
const localBgPath = ((await dataDir()) as string).replace(/\\/g, '/') const localBgPath = (await dataDir()).replace(/\\/g, '/')
await setConfigOption('custom_background', `${localBgPath}/cultivation/bg/${filename}`) await setConfigOption('custom_background', `${localBgPath}/cultivation/bg/${filename}`)

View File

@ -118,7 +118,7 @@ async function readConfigFile() {
await fs.createDir(local + 'cultivation').catch((e) => console.log(e)) await fs.createDir(local + 'cultivation').catch((e) => console.log(e))
} }
const innerDirs = await fs.readDir(local + '/cultivation') const innerDirs = await fs.readDir(local + 'cultivation')
// Create grasscutter dir for potential installation // Create grasscutter dir for potential installation
if (!innerDirs.find((fileOrDir) => fileOrDir?.name === 'grasscutter')) { if (!innerDirs.find((fileOrDir) => fileOrDir?.name === 'grasscutter')) {

View File

@ -45,7 +45,7 @@ export async function getGameDataFolder() {
return null return null
} }
return (await getGameFolder()) + '\\' + gameExec.replace('.exe', '_Data') return (await getGameFolder()) + '/' + gameExec.replace('.exe', '_Data')
} }
export async function getGameVersion() { export async function getGameVersion() {
@ -57,7 +57,7 @@ export async function getGameVersion() {
const settings = JSON.parse( const settings = JSON.parse(
await invoke('read_file', { await invoke('read_file', {
path: GameData + '\\StreamingAssets\\asb_settings.json', path: GameData + '/StreamingAssets/asb_settings.json',
}) })
) )

View File

@ -3,11 +3,11 @@ import { getGameFolder } from './game'
// Patch file from: https://github.com/34736384/RSAPatch/ // Patch file from: https://github.com/34736384/RSAPatch/
export async function patchGame() { export async function patchGame() {
const patchPath = (await invoke('install_location')) + '\\patch\\version.dll' const patchPath = (await invoke('install_location')) + '/patch/version.dll'
// Are we already patched with mhypbase? If so, that's fine, just continue as normal // Are we already patched with mhypbase? If so, that's fine, just continue as normal
const gameIsPatched = await invoke('are_files_identical', { const gameIsPatched = await invoke('are_files_identical', {
path1: patchPath, path1: patchPath,
path2: (await getGameRSAPath()) + '\\mhypbase.dll', path2: (await getGameRSAPath()) + '/mhypbase.dll',
}) })
// Tell user they won't be unpatched with manual mhypbase patch // Tell user they won't be unpatched with manual mhypbase patch
@ -33,7 +33,7 @@ export async function patchGame() {
export async function unpatchGame() { export async function unpatchGame() {
// Just delete patch since it's not replacing any existing file // Just delete patch since it's not replacing any existing file
const deleted = await invoke('delete_file', { const deleted = await invoke('delete_file', {
path: (await getGameRSAPath()) + '\\version.dll', path: (await getGameRSAPath()) + '/version.dll',
}) })
return deleted return deleted

View File

@ -40,7 +40,7 @@ const defaultTheme = {
export async function getThemeList() { export async function getThemeList() {
// Do some invoke to backend to get the theme list // Do some invoke to backend to get the theme list
const themes = (await invoke('get_theme_list', { const themes = (await invoke('get_theme_list', {
dataDir: `${await dataDir()}/cultivation`, dataDir: `${await dataDir()}cultivation`,
})) as BackendThemeList[] })) as BackendThemeList[]
const list: ThemeList[] = [ const list: ThemeList[] = [
// ALWAYS include default theme // ALWAYS include default theme