From c4f9c1ed478fec8adeeeee1d29d5f7b874649f2f Mon Sep 17 00:00:00 2001 From: morkt Date: Fri, 5 Feb 2016 06:10:46 +0400 Subject: [PATCH] consider empty IResource.Extensions property. --- GUI/CreateArchive.xaml.cs | 2 +- GUI/GarConvert.cs | 2 +- GUI/GarExtract.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GUI/CreateArchive.xaml.cs b/GUI/CreateArchive.xaml.cs index 2f1eca6f..08f5bb52 100644 --- a/GUI/CreateArchive.xaml.cs +++ b/GUI/CreateArchive.xaml.cs @@ -89,7 +89,7 @@ namespace GARbro.GUI var filters = new StringBuilder(); var format = this.ArchiveFormat.SelectedItem as ArchiveFormat; - if (null != format) + if (null != format && format.Extensions.Any()) { var patterns = format.Extensions.Select (ext => "*."+ext); filters.Append (format.Description); diff --git a/GUI/GarConvert.cs b/GUI/GarConvert.cs index cadbd6c5..3b6a7ef0 100644 --- a/GUI/GarConvert.cs +++ b/GUI/GarConvert.cs @@ -194,7 +194,7 @@ namespace GARbro.GUI string source_ext = Path.GetExtension (filename).TrimStart ('.').ToLowerInvariant(); if (m_image_format.Extensions.Any (ext => ext == source_ext)) return; - string target_ext = m_image_format.Extensions.First(); + string target_ext = m_image_format.Extensions.FirstOrDefault(); string target_name = Path.ChangeExtension (filename, target_ext); using (var file = File.OpenRead (filename)) { diff --git a/GUI/GarExtract.cs b/GUI/GarExtract.cs index 7428d4d3..8c926862 100644 --- a/GUI/GarExtract.cs +++ b/GUI/GarExtract.cs @@ -312,7 +312,7 @@ namespace GARbro.GUI if (null == src_format) throw new InvalidFormatException (string.Format ("{1}: {0}", guiStrings.MsgUnableInterpretImage, entry.Name)); file.Position = 0; - string target_ext = target_format.Extensions.First(); + string target_ext = target_format.Extensions.FirstOrDefault() ?? ""; string outname = FindUniqueFileName (entry.Name, target_ext); if (src_format.Item1 == target_format) {