From 64f38255eef50e6b8ad2e2763ec12316762ef69e Mon Sep 17 00:00:00 2001 From: morkt Date: Tue, 29 Jul 2014 14:17:41 +0400 Subject: [PATCH] (TryOpen): check formats that match filename extension first. --- GameRes/ArcFile.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/GameRes/ArcFile.cs b/GameRes/ArcFile.cs index 434666fe..1c1bd98f 100644 --- a/GameRes/ArcFile.cs +++ b/GameRes/ArcFile.cs @@ -58,18 +58,22 @@ namespace GameRes /// /// Try to open as archive. - /// Returns: ArcFile object if file is opened successfully, null otherwise. /// + /// + /// ArcFile object if file is opened successfully, null otherwise. + /// public static ArcFile TryOpen (string filename) { var file = new ArcView (filename); + string ext = Path.GetExtension (filename).TrimStart ('.').ToLower(); try { uint signature = file.View.ReadUInt32 (0); for (;;) { var range = FormatCatalog.Instance.LookupSignature (signature); - foreach (var impl in range) + // check formats that match filename extension first + foreach (var impl in range.OrderByDescending (f => f.Extensions.First() == ext)) { try {