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:
@@ -97,7 +97,7 @@ namespace GameRes.Formats.Will
|
||||
|
||||
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||
{
|
||||
if (!entry.Name.EndsWith (".ws2", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (!IsScriptFile (entry.Name))
|
||||
return base.OpenEntry (arc, entry);
|
||||
var data = arc.File.View.ReadBytes (entry.Offset, entry.Size);
|
||||
for (int i = 0; i < data.Length; ++i)
|
||||
@@ -107,6 +107,11 @@ namespace GameRes.Formats.Will
|
||||
return new BinMemoryStream (data, entry.Name);
|
||||
}
|
||||
|
||||
static bool IsScriptFile (string name)
|
||||
{
|
||||
return name.HasAnyOfExtensions ("ws2", "json");
|
||||
}
|
||||
|
||||
public override void Create (Stream output, IEnumerable<Entry> list, ResourceOptions options,
|
||||
EntryCallback callback)
|
||||
{
|
||||
@@ -132,7 +137,7 @@ namespace GameRes.Formats.Will
|
||||
var size = input.Length;
|
||||
if (size > uint.MaxValue || current_offset + size > uint.MaxValue)
|
||||
throw new FileSizeException();
|
||||
if (entry.Name.EndsWith (".ws2", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (IsScriptFile (entry.Name))
|
||||
CopyScript (input, output);
|
||||
else
|
||||
input.CopyTo (output);
|
||||
|
||||
@@ -275,8 +275,7 @@ namespace GameRes.Formats.Will
|
||||
|
||||
private static bool IsScriptFile (string filename)
|
||||
{
|
||||
return filename.EndsWith (".scr", StringComparison.InvariantCultureIgnoreCase)
|
||||
|| filename.EndsWith (".wsc", StringComparison.InvariantCultureIgnoreCase);
|
||||
return filename.HasAnyOfExtensions ("scr", "wsc");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace GameRes.Formats.Will
|
||||
if (24 == meta.BPP)
|
||||
{
|
||||
byte[] raw = reader.Data;
|
||||
if (ApplyMask && !meta.FileName.EndsWith (".msk", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (ApplyMask && !meta.FileName.HasExtension (".msk"))
|
||||
{
|
||||
var mask_name = Path.ChangeExtension (meta.FileName, "msk");
|
||||
if (VFS.FileExists (mask_name))
|
||||
|
||||
Reference in New Issue
Block a user