From bf336d85cf3fddebd6e790e2ca7e9b8f287d8d15 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 3 Dec 2021 15:50:06 +0100 Subject: [PATCH] Fix second issue mentioned in #2565: resource names such as path/to/file.ext are now properly handled as relative paths. --- .../CSharp/ProjectDecompiler/WholeProjectDecompiler.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs b/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs index ed60d54f5..1862dae39 100644 --- a/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs @@ -279,7 +279,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler Stream entryStream = (Stream)value; entryStream.Position = 0; individualResources.AddRange( - WriteResourceToFile(fileName, (string)name, entryStream)); + WriteResourceToFile(fileName, name, entryStream)); } decodedIntoIndividualFiles = true; } @@ -576,7 +576,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler /// /// Removes invalid characters from file names and reduces their length, - /// but keeps file extensions intact. + /// but keeps file extensions and path structure intact. /// public static string SanitizeFileName(string fileName) { @@ -649,6 +649,12 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler if (separateAtDots) currentSegmentLength = 0; } + else if (treatAsFileName && (c == '/' || c == '\\') && currentSegmentLength > 0) + { + // if we treat this as a file name, we've started a new segment + b.Append(c); + currentSegmentLength = 0; + } else { // if the current segment exceeds maxSegmentLength characters,