From 53a150f15dc4f5df26bdd6b2c1361dae846d1607 Mon Sep 17 00:00:00 2001 From: Yoshi Askharoun Date: Sun, 7 Jul 2024 15:37:20 -0500 Subject: [PATCH] Better path handling for decompile command --- UIXC/Commands/DecompileCommand.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/UIXC/Commands/DecompileCommand.cs b/UIXC/Commands/DecompileCommand.cs index ef885dd..8121abd 100644 --- a/UIXC/Commands/DecompileCommand.cs +++ b/UIXC/Commands/DecompileCommand.cs @@ -75,9 +75,13 @@ public class DecompileCommand : Command { try { - var inputPath = ResolvePath(input, searchPaths); + if (!ResolvePath(input, searchPaths, out var inputPath)) + inputPath = input; - var uibLoadResult = MarkupSystem.Load($"file://{inputPath}", (uint)Random.Shared.Next()); + if (!inputPath.Contains("://")) + inputPath = $"file://{inputPath}"; + + var uibLoadResult = MarkupSystem.Load(inputPath, (uint)Random.Shared.Next()); uibLoadResult.FullLoad(); if (uibLoadResult.Status != LoadResultStatus.Success) @@ -120,7 +124,13 @@ public class DecompileCommand : Command private static string GetOutputPath(Settings settings, string inputFilePath) { - return Path.Combine(settings.OutputDir, Path.ChangeExtension(inputFilePath, settings.Language.GetExtension())); + var fileName = Path.GetFileName(inputFilePath);//.Replace('!', '/'); + var outputFile = Path.Combine(settings.OutputDir, Path.ChangeExtension(fileName, settings.Language.GetExtension())); + + var outputDir = Path.GetDirectoryName(outputFile); + Directory.CreateDirectory(outputDir); + + return outputFile; } private static string ResolvePath(string givenPath, ICollection searchPaths)