From ade3cdd6fecaf6e7f44d3c587348da286e90ba55 Mon Sep 17 00:00:00 2001 From: Lino Schmidt Date: Sun, 19 Jun 2022 01:05:32 +0200 Subject: [PATCH] Fixed paths on other platforms --- src/components/paths.ts | 8 ++++++++ src/components/ui/mainSide.tsx | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/paths.ts b/src/components/paths.ts index 50c5de6..254c2e5 100644 --- a/src/components/paths.ts +++ b/src/components/paths.ts @@ -16,6 +16,14 @@ if(process.platform === "win32") { platformFolder = "linux"; } +export function platformCharacter() { + let platformCharacterTEMP = "/"; + if (process.platform === "win32") { + platformCharacterTEMP = "\\"; + } + return platformCharacterTEMP; +} + export const blenderPath = path.join(appPath, "dependencies", platformFolder, "blender", "blender"); export const templatePath = path.join(appPath, "dependencies", "template.blend"); export const blenderScriptPath = path.join(appPath, "dependencies", "blenderScript.py"); \ No newline at end of file diff --git a/src/components/ui/mainSide.tsx b/src/components/ui/mainSide.tsx index 7918501..4bb05b3 100644 --- a/src/components/ui/mainSide.tsx +++ b/src/components/ui/mainSide.tsx @@ -4,6 +4,7 @@ import { settingList, updateSettings } from "../settings"; import logger from "../logger"; import {blender, blenderCmd} from "../blender-controller"; import openFolder from "../openFolder"; +import {platformCharacter} from "../paths"; function MainSide() { const [logs, setLogs] = useState(settingList.log); @@ -22,12 +23,12 @@ function MainSide() { const logListName:string[] = []; logList.forEach(log => { - logListName.push(log.split('\\')[log.split('\\').length - 1].split('/')[log.split('/').length - 1].replace(".csv", "")); + logListName.push(log.split(platformCharacter())[log.split(platformCharacter()).length - 1].replace(".csv", "")); }); setLogTable(logListName.map((log, index) => { return - openFolder(logList[index].substring(0, logList[index].lastIndexOf('\\')).substring(0, logList[index].lastIndexOf('/')))}>{index+1}. {log} + openFolder(logList[index].substring(0, logList[index].lastIndexOf(platformCharacter())))}>{index+1}. {log}