From f3f6b72f5a9429de7f426955c49fbd714277bcd8 Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 27 Dec 2012 18:41:46 +0000 Subject: [PATCH] fix bug in loading roms with no extension --- BizHawk.Util/7z/Formats.cs | 50 ++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/BizHawk.Util/7z/Formats.cs b/BizHawk.Util/7z/Formats.cs index 9b71bc1744..bd978baf18 100644 --- a/BizHawk.Util/7z/Formats.cs +++ b/BizHawk.Util/7z/Formats.cs @@ -508,31 +508,33 @@ namespace SevenZip { InSignatureFormatsReversed.Add(pair.Value, pair.Key); } - } + } - /// - /// Gets InArchiveFormat for specified archive file name - /// - /// Archive file name - /// Indicates whether to throw exceptions - /// InArchiveFormat recognized by the file name extension - /// - public static InArchiveFormat FormatByFileName(string fileName, bool reportErrors) - { - if (String.IsNullOrEmpty(fileName) && reportErrors) - { - throw new ArgumentException("File name is null or empty string!"); - } - string extension = Path.GetExtension(fileName).Substring(1); - if (!InExtensionFormats.ContainsKey(extension) && reportErrors) - { - if (FileChecker.ThrowExceptions) - throw new ArgumentException("Extension \"" + extension + "\" is not a supported archive file name extension."); - else return InArchiveFormat.None; + /// + /// Gets InArchiveFormat for specified archive file name + /// + /// Archive file name + /// Indicates whether to throw exceptions + /// InArchiveFormat recognized by the file name extension + /// + public static InArchiveFormat FormatByFileName(string fileName, bool reportErrors) + { + if (String.IsNullOrEmpty(fileName) && reportErrors) + { + throw new ArgumentException("File name is null or empty string!"); + } + string extension = Path.GetExtension(fileName); + if (extension.StartsWith(".")) + extension = extension.Substring(1); + if (!InExtensionFormats.ContainsKey(extension) && reportErrors) + { + if (FileChecker.ThrowExceptions) + throw new ArgumentException("Extension \"" + extension + "\" is not a supported archive file name extension."); + else return InArchiveFormat.None; - } - return InExtensionFormats[extension]; - } - } + } + return InExtensionFormats[extension]; + } + } #endif } \ No newline at end of file