From 67aa9bfc6ac0b8998f9aec60537a82132792b31e Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Fri, 28 Apr 2023 20:18:19 -0400 Subject: [PATCH] Platform-specific directory slashes --- electron/index.ts | 19 +++++++++---------- electron/utils/getArguments.ts | 13 ++++++++----- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/electron/index.ts b/electron/index.ts index 7d6cc7d..6552508 100644 --- a/electron/index.ts +++ b/electron/index.ts @@ -43,6 +43,9 @@ let customModelsFolderPath: string | undefined = undefined; let outputFolderPath: string | undefined = undefined; let saveOutputFolder = false; +// Slashes for use in directory names +const slash: string = getPlatform() === "win" ? "\\" : "/"; + // Prepare the renderer once the app is ready let mainWindow: BrowserWindow; app.on("ready", async () => { @@ -330,15 +333,11 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => { const isDefaultModel = defaultModels.includes(model); // COPY IMAGE TO TMP FOLDER - const platform = getPlatform(); - const fullfileName = - platform === "win" - ? (payload.imagePath.split("\\").slice(-1)[0] as string) - : (payload.imagePath.split("/").slice(-1)[0] as string); + + const fullfileName = (payload.imagePath.split(slash).slice(-1)[0] as string); const fileName = parse(fullfileName).name; - const fileExt = parse(fullfileName).ext; const outFile = - outputDir + "/" + fileName + "_upscayl_16x_" + model + "." + saveImageAs; + outputDir + slash + fileName + "_upscayl_16x_" + model + "." + saveImageAs; // UPSCALE let upscayl = spawnUpscayl( @@ -462,7 +461,7 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => { const outFile = outputDir + - "/" + + slash + fileName + "_upscayl_" + scale + @@ -664,8 +663,8 @@ autoUpdater.on("update-downloaded", (event) => { // ffmpeg.path, // [ // "-i", -// inputDir + "/" + videoFileName, -// frameExtractionPath + "/" + "out%d.png", +// inputDir + slash + videoFileName, +// frameExtractionPath + slash + "out%d.png", // ], // { // cwd: undefined, diff --git a/electron/utils/getArguments.ts b/electron/utils/getArguments.ts index 1edb090..32d80dc 100644 --- a/electron/utils/getArguments.ts +++ b/electron/utils/getArguments.ts @@ -1,3 +1,6 @@ +import getPlatform from "../getPlatform"; +const slash: string = getPlatform() === "win" ? "\\" : "/"; + export const getSingleImageArguments = ( inputDir: string, fullfileName: string, @@ -10,7 +13,7 @@ export const getSingleImageArguments = ( ) => { return [ "-i", - inputDir + "/" + fullfileName, + inputDir + slash + fullfileName, "-o", outFile, "-s", @@ -37,14 +40,14 @@ export const getSingleImageSharpenArguments = ( ) => { return [ "-i", - inputDir + "/" + fullfileName, + inputDir + slash + fullfileName, "-o", outFile, "-s", scale, "-x", "-m", - modelsPath + "/" + model, + modelsPath + slash + model, gpuId ? `-g ${gpuId}` : "", "-f", saveImageAs, @@ -63,7 +66,7 @@ export const getDoubleUpscaleArguments = ( ) => { return [ "-i", - inputDir + "/" + fullfileName, + inputDir + slash + fullfileName, "-o", outFile, "-s", @@ -149,7 +152,7 @@ export const getBatchSharpenArguments = ( scale, "-x", "-m", - modelsPath + "/" + model, + modelsPath + slash + model, gpuId ? `-g ${gpuId}` : "", "-f", saveImageAs,