From c015ac9c9cb8bed019653f1314a7b5ca0cc9cebd Mon Sep 17 00:00:00 2001 From: Mehmet Akif Date: Tue, 2 Jun 2020 00:59:10 +0300 Subject: [PATCH 1/2] fix Error loading dir --- AionClientViewer/Controls/ImageViewerControl.cs | 3 +++ Common/DirManager.cs | 5 +++-- Common/FileFormats/BrushLstLoader.cs | 3 ++- Common/FileFormats/Pak/PakUtil.cs | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/AionClientViewer/Controls/ImageViewerControl.cs b/AionClientViewer/Controls/ImageViewerControl.cs index aa01c13..246ca28 100644 --- a/AionClientViewer/Controls/ImageViewerControl.cs +++ b/AionClientViewer/Controls/ImageViewerControl.cs @@ -43,6 +43,7 @@ private bool TryLoadFromKnownMonoImageFormats(Stream s, out Texture2D result) } catch (InvalidOperationException e) { + Log.WriteLine("TryLoadFromKnownMonoImageFormats : " + e.Message); result = null; } return (result != null); @@ -88,6 +89,8 @@ private bool TryLoadDds(Stream s, out Texture2D result) result = tex; } catch (Exception e) { + + Log.WriteLine("TryLoadDds : " + e.Message); result = null; } return (result != null); diff --git a/Common/DirManager.cs b/Common/DirManager.cs index 9ac0028..4a7e695 100644 --- a/Common/DirManager.cs +++ b/Common/DirManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using monono2.Common.FileFormats.Pak; @@ -27,7 +28,7 @@ public DirManager(string rootPath, IEnumerable subdirs) private void SetRootPath(string rootPath) { - m_rootPath = rootPath.ToLower(); + m_rootPath = rootPath.ToLower(new CultureInfo("en_US", false)); if (!Directory.Exists(m_rootPath)) throw new DirectoryNotFoundException(); } @@ -140,7 +141,7 @@ private SortedDictionary GenerateFileListing(string subpath) private string NormalizePath(string path) { - return path.ToLower().Replace('/', '\\'); + return path.ToLower(new CultureInfo("en_US", false)).Replace('/', '\\'); } private string GetRelativePath(string path) diff --git a/Common/FileFormats/BrushLstLoader.cs b/Common/FileFormats/BrushLstLoader.cs index 74f5293..782c461 100644 --- a/Common/FileFormats/BrushLstLoader.cs +++ b/Common/FileFormats/BrushLstLoader.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Text; using Microsoft.Xna.Framework; @@ -80,7 +81,7 @@ private void Load(BinaryReader meshInputStream) // int dw1 = meshInputStream.readInt(); meshInputStream.Read(fileNameBytes, 0, 128); - info.filename = Encoding.UTF8.GetString(fileNameBytes).Trim().Trim('\0').ToLower().Replace('\\', '/'); + info.filename = Encoding.UTF8.GetString(fileNameBytes).Trim().Trim('\0').ToLower(new CultureInfo("en_US", false)).Replace('\\', '/'); meshInputStream.ReadInt32(); // skip - usually 1, sometimes 3 diff --git a/Common/FileFormats/Pak/PakUtil.cs b/Common/FileFormats/Pak/PakUtil.cs index 7b45a02..35d686c 100644 --- a/Common/FileFormats/Pak/PakUtil.cs +++ b/Common/FileFormats/Pak/PakUtil.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Text; @@ -10,7 +11,7 @@ public static class PakUtil { public static string NormalizeFilename(string originalFilename) { - return originalFilename.ToLower().Replace('\\', '/'); + return originalFilename.ToLower(new CultureInfo("en_US", false)).Replace('\\', '/'); } public static string ReadFilename(BinaryReader br, int length) From 959e4202c2e2373324625c2982046f70bf563fce Mon Sep 17 00:00:00 2001 From: Mehmet Akif Date: Sat, 6 Jun 2020 17:01:46 +0300 Subject: [PATCH 2/2] small update --- Common/DirManager.cs | 4 ++-- Common/FileFormats/BrushLstLoader.cs | 2 +- Common/FileFormats/Pak/PakUtil.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Common/DirManager.cs b/Common/DirManager.cs index 4a7e695..f07b547 100644 --- a/Common/DirManager.cs +++ b/Common/DirManager.cs @@ -28,7 +28,7 @@ public DirManager(string rootPath, IEnumerable subdirs) private void SetRootPath(string rootPath) { - m_rootPath = rootPath.ToLower(new CultureInfo("en_US", false)); + m_rootPath = rootPath.ToLower(new CultureInfo("en-US", false)); if (!Directory.Exists(m_rootPath)) throw new DirectoryNotFoundException(); } @@ -141,7 +141,7 @@ private SortedDictionary GenerateFileListing(string subpath) private string NormalizePath(string path) { - return path.ToLower(new CultureInfo("en_US", false)).Replace('/', '\\'); + return path.ToLower(new CultureInfo("en-US", false)).Replace('/', '\\'); } private string GetRelativePath(string path) diff --git a/Common/FileFormats/BrushLstLoader.cs b/Common/FileFormats/BrushLstLoader.cs index 782c461..c3efde5 100644 --- a/Common/FileFormats/BrushLstLoader.cs +++ b/Common/FileFormats/BrushLstLoader.cs @@ -81,7 +81,7 @@ private void Load(BinaryReader meshInputStream) // int dw1 = meshInputStream.readInt(); meshInputStream.Read(fileNameBytes, 0, 128); - info.filename = Encoding.UTF8.GetString(fileNameBytes).Trim().Trim('\0').ToLower(new CultureInfo("en_US", false)).Replace('\\', '/'); + info.filename = Encoding.UTF8.GetString(fileNameBytes).Trim().Trim('\0').ToLower(new CultureInfo("en-US", false)).Replace('\\', '/'); meshInputStream.ReadInt32(); // skip - usually 1, sometimes 3 diff --git a/Common/FileFormats/Pak/PakUtil.cs b/Common/FileFormats/Pak/PakUtil.cs index 35d686c..059eddd 100644 --- a/Common/FileFormats/Pak/PakUtil.cs +++ b/Common/FileFormats/Pak/PakUtil.cs @@ -11,7 +11,7 @@ public static class PakUtil { public static string NormalizeFilename(string originalFilename) { - return originalFilename.ToLower(new CultureInfo("en_US", false)).Replace('\\', '/'); + return originalFilename.ToLower(new CultureInfo("en-US", false)).Replace('\\', '/'); } public static string ReadFilename(BinaryReader br, int length)