mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
use HasExtension method instead of string.EndsWith.
This commit is contained in:
@@ -44,7 +44,7 @@ namespace GameRes.Formats.GameSystem
|
||||
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
if (!file.Name.EndsWith (".CHR", StringComparison.InvariantCultureIgnoreCase)
|
||||
if (!file.Name.HasExtension (".CHR")
|
||||
|| file.View.ReadUInt32 (0) != file.MaxOffset)
|
||||
return null;
|
||||
using (var input = file.CreateStream())
|
||||
|
||||
@@ -72,10 +72,7 @@ namespace GameRes.Formats.GameSystem
|
||||
entry.UnpackedSize = index.ReadUInt32();
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
return null;
|
||||
if (entry.Name.EndsWith (".CRGB", StringComparison.InvariantCultureIgnoreCase) ||
|
||||
entry.Name.EndsWith (".CHAR", StringComparison.InvariantCultureIgnoreCase) ||
|
||||
entry.Name.EndsWith (".rol", StringComparison.InvariantCultureIgnoreCase) ||
|
||||
entry.Name.EndsWith (".edg", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (entry.Name.HasAnyOfExtensions ("CRGB", "CHAR", "rol", "edg"))
|
||||
entry.Type = "image";
|
||||
entry.IsPacked = (flags & 0xFF0000) != 0;
|
||||
entry.StoredSize = (flags & 0x2000000) != 0;
|
||||
@@ -146,20 +143,19 @@ namespace GameRes.Formats.GameSystem
|
||||
|
||||
public override IImageDecoder OpenImage (ArcFile arc, Entry entry)
|
||||
{
|
||||
if (entry.Name.EndsWith (".BGD", StringComparison.InvariantCultureIgnoreCase) ||
|
||||
entry.Name.EndsWith (".CRGB", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (entry.Name.HasAnyOfExtensions (".BGD", ".CRGB"))
|
||||
{
|
||||
var input = OpenEntry (arc, entry);
|
||||
var info = new ImageMetaData { Width = 800, Height = 600, BPP = 24 };
|
||||
return new CgdReader (BinaryStream.FromStream (input, entry.Name), info);
|
||||
}
|
||||
else if (entry.Name.EndsWith (".edg", StringComparison.InvariantCultureIgnoreCase))
|
||||
else if (entry.Name.HasExtension (".edg"))
|
||||
{
|
||||
var input = OpenEntry (arc, entry);
|
||||
var info = new ImageMetaData { Width = 460, Height = 345, BPP = 24 };
|
||||
return new ImgReader (BinaryStream.FromStream (input, entry.Name), info);
|
||||
}
|
||||
else if (entry.Name.EndsWith (".rol", StringComparison.InvariantCultureIgnoreCase))
|
||||
else if (entry.Name.HasExtension (".rol"))
|
||||
{
|
||||
var input = OpenEntry (arc, entry);
|
||||
uint width = 202;
|
||||
@@ -167,7 +163,7 @@ namespace GameRes.Formats.GameSystem
|
||||
var info = new ImageMetaData { Width = width, Height = height, BPP = 24 };
|
||||
return new ImgReader (BinaryStream.FromStream (input, entry.Name), info);
|
||||
}
|
||||
else if (entry.Name.EndsWith (".CHAR", StringComparison.InvariantCultureIgnoreCase))
|
||||
else if (entry.Name.HasExtension (".CHAR"))
|
||||
{
|
||||
var input = OpenEntry (arc, entry);
|
||||
var info = new ChrMetaData {
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace GameRes.Formats.GameSystem
|
||||
|
||||
public override SoundInput TryOpen (IBinaryStream file)
|
||||
{
|
||||
bool is_adp4 = file.Name.EndsWith (".adp4", StringComparison.InvariantCultureIgnoreCase);
|
||||
bool is_adps = !is_adp4 && file.Name.EndsWith (".adps", StringComparison.InvariantCultureIgnoreCase);
|
||||
bool is_adp4 = file.Name.HasExtension (".adp4");
|
||||
bool is_adps = !is_adp4 && file.Name.HasExtension (".adps");
|
||||
if (!(is_adp4 || is_adps) || file.Length <= 4)
|
||||
return null;
|
||||
var decoder = new AdpDecoder (file);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace GameRes.Formats.GameSystem
|
||||
|
||||
public override ImageMetaData ReadMetaData (IBinaryStream file)
|
||||
{
|
||||
if (!file.Name.EndsWith (".alp", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (!file.Name.HasExtension (".alp"))
|
||||
return null;
|
||||
var header = file.ReadHeader (8);
|
||||
uint width = header.ToUInt32 (0);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace GameRes.Formats.GameSystem
|
||||
|
||||
public override ImageMetaData ReadMetaData (IBinaryStream file)
|
||||
{
|
||||
if (!file.Name.EndsWith (".texb", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (!file.Name.HasExtension (".texb"))
|
||||
return null;
|
||||
var header = file.ReadHeader (8);
|
||||
uint width = header.ToUInt32 (0);
|
||||
|
||||
Reference in New Issue
Block a user