(ArcOpener.IsScriptFile): separate method to check script filenames.

This commit is contained in:
morkt 2015-11-21 23:47:30 +04:00
parent c461da3cd7
commit 3110f78e6d

View File

@ -111,11 +111,9 @@ namespace GameRes.Formats.Will
public override Stream OpenEntry (ArcFile arc, Entry entry) public override Stream OpenEntry (ArcFile arc, Entry entry)
{ {
if (!entry.Name.EndsWith (".scr", StringComparison.InvariantCultureIgnoreCase) if (!IsScriptFile (entry.Name))
&& !entry.Name.EndsWith (".wsc", StringComparison.InvariantCultureIgnoreCase))
return arc.File.CreateStream (entry.Offset, entry.Size); return arc.File.CreateStream (entry.Offset, entry.Size);
var data = new byte[entry.Size]; var data = arc.File.View.ReadBytes (entry.Offset, entry.Size);
arc.File.View.Read (entry.Offset, data, 0, entry.Size);
DecodeScript (data); DecodeScript (data);
return new MemoryStream (data); return new MemoryStream (data);
} }
@ -249,7 +247,7 @@ namespace GameRes.Formats.Will
private uint WriteEntry (string filename, Stream output) private uint WriteEntry (string filename, Stream output)
{ {
if (!filename.EndsWith (".scr", StringComparison.InvariantCultureIgnoreCase)) if (!IsScriptFile (filename))
{ {
using (var input = File.OpenRead (filename)) using (var input = File.OpenRead (filename))
{ {
@ -268,5 +266,11 @@ namespace GameRes.Formats.Will
return (uint)input.Length; return (uint)input.Length;
} }
} }
private static bool IsScriptFile (string filename)
{
return filename.EndsWith (".scr", StringComparison.InvariantCultureIgnoreCase)
|| filename.EndsWith (".wsc", StringComparison.InvariantCultureIgnoreCase);
}
} }
} }