Skip to content

Commit

Permalink
Fix dds conversion when file path has whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
iMrShadow committed Mar 19, 2024
1 parent 7ecfe4f commit b655584
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
6 changes: 1 addition & 5 deletions DDS_D3DTX_Converter_GUI/DDS_D3DTX_Converter/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,18 +296,14 @@ public static void ConvertTextureFromDdsToOthers(string? sourceFilePath, string
if (fixesDdsToGeneric)
options.outputSwizzle = new() { mask = "abgr" };

Console.WriteLine("EXEC1");
TexconvApp.RunTexconv(sourceFilePath, options);
Console.WriteLine("OUT1");
}
else if (d3dtxTextureType == D3DTX_Converter.TelltaleEnums.T3TextureType.eTxNormalXYMap)
{
Console.WriteLine("EXEC2");
if (fixesDdsToGeneric)
NormalMapProcessing.FromDDS_NormalMapReconstructZ(sourceFilePath, outputTextureFilePath);
else
NormalMapConvert.ConvertNormalMapToOthers(sourceFilePath, newFileType); //lol
Console.WriteLine("OUT2");
NormalMapConvert.ConvertNormalMapToOthers(sourceFilePath, newFileType);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ public static void RunTexconv(string inputFilePath, MasterOptions options)
string texconvApplicationDirectoryPath = Path.Combine(solutionDir, "ExternalDependencies", "texconv.exe");

ProcessStartInfo textconvProcessStartInfo = new();
textconvProcessStartInfo.CreateNoWindow = true;

// Check if the current OS is Linux
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// If it's not Linux, run the .exe file directly
// If it's not Unix-based OS, run the .exe file directly
textconvProcessStartInfo.FileName = texconvApplicationDirectoryPath;
textconvProcessStartInfo.Arguments = options.GetArguments(inputFilePath);
}
Expand All @@ -31,10 +32,8 @@ public static void RunTexconv(string inputFilePath, MasterOptions options)
// If it's Linux or OSX, use Wine to run the .exe file
textconvProcessStartInfo.FileName = "wine";
textconvProcessStartInfo.Arguments = $"{texconvApplicationDirectoryPath} {options.GetArguments(inputFilePath)}";

}

textconvProcessStartInfo.CreateNoWindow = true;
}

Process texconvProcess = new();
texconvProcess.StartInfo = textconvProcessStartInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public string GetArguments(string inputFilePath)
{
List<string> arguments = new();

if (inputFilePath.Contains(" "))
{
inputFilePath = $"\"{inputFilePath}\"";
}

arguments.Add(inputFilePath);
arguments.Add("-r");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ public class OutputDirectory
{
public string directory;

public string GetArgumentOutput() => string.Format("-o {0}", directory);
public string GetArgumentOutput()
{
if (directory.Contains(" "))
{
return string.Format("-o \"{0}\"", directory);
}
else
{
return string.Format("-o {0}", directory);
}
}
}
}

0 comments on commit b655584

Please sign in to comment.