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; int update_count = 0;
foreach (var entry in list) foreach (var entry in list)
{ {
string ext = Path.GetExtension (entry.Name).ToLower(); if (entry.Type != "image" && !entry.Name.EndsWith (".scr", StringComparison.InvariantCultureIgnoreCase))
if (entry.Type != "image" && ext != ".scr")
continue; continue;
uint id; uint id;
if (!uint.TryParse (Path.GetFileNameWithoutExtension (entry.Name), NumberStyles.HexNumber, 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) public override Stream OpenEntry (ArcFile arc, Entry entry)
{ {
if (entry.Size < 20 if (entry.Size < 20
|| ".asb" != Path.GetExtension (entry.Name).ToLowerInvariant() || !entry.Name.EndsWith (".asb", StringComparison.InvariantCultureIgnoreCase)
|| !arc.File.View.AsciiEqual (entry.Offset, "ASB\x1a")) || !arc.File.View.AsciiEqual (entry.Offset, "ASB\x1a"))
return arc.File.CreateStream (entry.Offset, entry.Size); return arc.File.CreateStream (entry.Offset, entry.Size);
uint packed = arc.File.View.ReadUInt32 (entry.Offset+4); 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) public override Stream OpenEntry (ArcFile arc, Entry entry)
{ {
var input = arc.File.CreateStream (entry.Offset, entry.Size); 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; return input;
using (var header = new ArcView.Reader (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 }; var header_entry = new NsaEntry { Name = entry.Name };
if (Compression.None != ons_options.CompressionType) if (Compression.None != ons_options.CompressionType)
{ {
string ext = Path.GetExtension (entry.Name).ToLower(); if (entry.Name.EndsWith (".bmp", StringComparison.InvariantCultureIgnoreCase))
if (".bmp" == ext)
header_entry.CompressionType = ons_options.CompressionType; header_entry.CompressionType = ons_options.CompressionType;
} }
index_size += 13; index_size += 13;

View File

@ -76,7 +76,7 @@ namespace GameRes.Formats.Fs
entry.Size = file.View.ReadUInt32 (cur_offset+0x88); entry.Size = file.View.ReadUInt32 (cur_offset+0x88);
if (!entry.CheckPlacement (file.MaxOffset)) if (!entry.CheckPlacement (file.MaxOffset))
return null; return null;
if (Path.GetExtension (name).Equals (".dsf", System.StringComparison.OrdinalIgnoreCase)) if (name.EndsWith (".dsf", System.StringComparison.InvariantCultureIgnoreCase))
entry.Type = "script"; entry.Type = "script";
dir.Add (entry); dir.Add (entry);
cur_offset += 0x90; cur_offset += 0x90;

View File

@ -610,8 +610,7 @@ NextEntry:
{ {
if ("image" == entry.Type || "archive" == entry.Type) if ("image" == entry.Type || "archive" == entry.Type)
return false; return false;
var ext = Path.GetExtension (entry.Name); if (entry.Name.EndsWith (".ogg", StringComparison.InvariantCultureIgnoreCase))
if (!string.IsNullOrEmpty (ext) && ext.Equals (".ogg", StringComparison.OrdinalIgnoreCase))
return false; return false;
return true; return true;
} }