use string.EndsWith() method instead of Path.GetExtension()

This commit is contained in:
morkt 2015-05-15 18:49:37 +04:00
parent 8640e34c27
commit a2051e6752
6 changed files with 6 additions and 9 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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))
{

View File

@ -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;

View File

@ -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;

View File

@ -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;
}