From a2051e6752731a4b08064b1b618aedf0be46397f Mon Sep 17 00:00:00 2001 From: morkt Date: Fri, 15 May 2015 18:49:37 +0400 Subject: [PATCH] use string.EndsWith() method instead of Path.GetExtension() --- ArcFormats/ArcAMI.cs | 3 +-- ArcFormats/ArcAZSys.cs | 2 +- ArcFormats/ArcBlackPackage.cs | 2 +- ArcFormats/ArcNSA.cs | 3 +-- ArcFormats/ArcPD.cs | 2 +- ArcFormats/ArcXP3.cs | 3 +-- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ArcFormats/ArcAMI.cs b/ArcFormats/ArcAMI.cs index f1491eb8..5202940e 100644 --- a/ArcFormats/ArcAMI.cs +++ b/ArcFormats/ArcAMI.cs @@ -240,8 +240,7 @@ namespace GameRes.Formats int update_count = 0; foreach (var entry in list) { - string ext = Path.GetExtension (entry.Name).ToLower(); - if (entry.Type != "image" && ext != ".scr") + if (entry.Type != "image" && !entry.Name.EndsWith (".scr", StringComparison.InvariantCultureIgnoreCase)) continue; uint id; if (!uint.TryParse (Path.GetFileNameWithoutExtension (entry.Name), NumberStyles.HexNumber, diff --git a/ArcFormats/ArcAZSys.cs b/ArcFormats/ArcAZSys.cs index ac3beee8..753fa651 100644 --- a/ArcFormats/ArcAZSys.cs +++ b/ArcFormats/ArcAZSys.cs @@ -89,7 +89,7 @@ namespace GameRes.Formats.AZSys public override Stream OpenEntry (ArcFile arc, Entry entry) { if (entry.Size < 20 - || ".asb" != Path.GetExtension (entry.Name).ToLowerInvariant() + || !entry.Name.EndsWith (".asb", StringComparison.InvariantCultureIgnoreCase) || !arc.File.View.AsciiEqual (entry.Offset, "ASB\x1a")) return arc.File.CreateStream (entry.Offset, entry.Size); uint packed = arc.File.View.ReadUInt32 (entry.Offset+4); diff --git a/ArcFormats/ArcBlackPackage.cs b/ArcFormats/ArcBlackPackage.cs index 89545bd0..5155da8f 100644 --- a/ArcFormats/ArcBlackPackage.cs +++ b/ArcFormats/ArcBlackPackage.cs @@ -76,7 +76,7 @@ namespace GameRes.Formats.Ffa public override Stream OpenEntry (ArcFile arc, Entry entry) { var input = arc.File.CreateStream (entry.Offset, entry.Size); - if (entry.Size <= 8 || Path.GetExtension (entry.Name).ToLowerInvariant() != ".so4") + if (entry.Size <= 8 || !entry.Name.EndsWith (".so4", StringComparison.InvariantCultureIgnoreCase)) return input; using (var header = new ArcView.Reader (input)) { diff --git a/ArcFormats/ArcNSA.cs b/ArcFormats/ArcNSA.cs index b0980e96..11893c08 100644 --- a/ArcFormats/ArcNSA.cs +++ b/ArcFormats/ArcNSA.cs @@ -296,8 +296,7 @@ namespace GameRes.Formats.ONScripter var header_entry = new NsaEntry { Name = entry.Name }; if (Compression.None != ons_options.CompressionType) { - string ext = Path.GetExtension (entry.Name).ToLower(); - if (".bmp" == ext) + if (entry.Name.EndsWith (".bmp", StringComparison.InvariantCultureIgnoreCase)) header_entry.CompressionType = ons_options.CompressionType; } index_size += 13; diff --git a/ArcFormats/ArcPD.cs b/ArcFormats/ArcPD.cs index 5978827a..ed027e22 100644 --- a/ArcFormats/ArcPD.cs +++ b/ArcFormats/ArcPD.cs @@ -76,7 +76,7 @@ namespace GameRes.Formats.Fs entry.Size = file.View.ReadUInt32 (cur_offset+0x88); if (!entry.CheckPlacement (file.MaxOffset)) return null; - if (Path.GetExtension (name).Equals (".dsf", System.StringComparison.OrdinalIgnoreCase)) + if (name.EndsWith (".dsf", System.StringComparison.InvariantCultureIgnoreCase)) entry.Type = "script"; dir.Add (entry); cur_offset += 0x90; diff --git a/ArcFormats/ArcXP3.cs b/ArcFormats/ArcXP3.cs index f0ce6350..09aeb323 100644 --- a/ArcFormats/ArcXP3.cs +++ b/ArcFormats/ArcXP3.cs @@ -610,8 +610,7 @@ NextEntry: { if ("image" == entry.Type || "archive" == entry.Type) return false; - var ext = Path.GetExtension (entry.Name); - if (!string.IsNullOrEmpty (ext) && ext.Equals (".ogg", StringComparison.OrdinalIgnoreCase)) + if (entry.Name.EndsWith (".ogg", StringComparison.InvariantCultureIgnoreCase)) return false; return true; }