diff --git a/SpaceWizards.RsiLib/Extensions/FileExtensions.cs b/SpaceWizards.RsiLib/Extensions/FileExtensions.cs new file mode 100644 index 0000000..e22f3d5 --- /dev/null +++ b/SpaceWizards.RsiLib/Extensions/FileExtensions.cs @@ -0,0 +1,11 @@ +using System; + +namespace SpaceWizards.RsiLib.Extensions; + +public static class FileExtensions +{ + public static bool IsCaseInsensitive() + { + return OperatingSystem.IsWindows() || OperatingSystem.IsMacOS(); + } +} diff --git a/SpaceWizards.RsiLib/RSI/Rsi.cs b/SpaceWizards.RsiLib/RSI/Rsi.cs index 0844459..a8a26dd 100644 --- a/SpaceWizards.RsiLib/RSI/Rsi.cs +++ b/SpaceWizards.RsiLib/RSI/Rsi.cs @@ -2,11 +2,14 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text.Json; using JetBrains.Annotations; using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; using SpaceWizards.RsiLib.Directions; +using SpaceWizards.RsiLib.Extensions; +using static System.StringComparison; namespace SpaceWizards.RsiLib.RSI; @@ -121,12 +124,35 @@ public void SaveImagesToFolder(string rsiFolder) } else if (state.ImagePath != path) { - File.Copy(state.ImagePath, path, true); + if (FileExtensions.IsCaseInsensitive() && state.ImagePath.Equals(path, OrdinalIgnoreCase)) + { + File.Move(state.ImagePath, path, true); + } + else + { + File.Copy(state.ImagePath, path, true); + } } } foreach (var name in OriginalStateNames) { + if (FileExtensions.IsCaseInsensitive()) + { + var found = false; + foreach (var state in States) + { + if (state.Name.Equals(name, OrdinalIgnoreCase)) + { + found = true; + break; + } + } + + if (found) + continue; + } + var path = Path.Combine(rsiFolder, $"{name}.png"); File.Delete(path); }