XmlGame - support an xml that refers to roms in archives

This commit is contained in:
adelikat 2015-05-17 16:30:39 +00:00
parent 5f2e2f39b2
commit bc1115d62d
1 changed files with 17 additions and 2 deletions

View File

@ -55,7 +55,7 @@ namespace BizHawk.Client.Common
foreach (XmlNode a in n.ChildNodes)
{
string filename = a.Attributes["FileName"].Value;
byte[] data;
byte[] data = new byte[0];
if (filename[0] == '|')
{
// in same archive
@ -83,7 +83,22 @@ namespace BizHawk.Client.Common
fullpath = Path.Combine(fullpath, filename.Split('|').First());
try
{
data = File.ReadAllBytes(fullpath.Split('|').First());
using (var hf = new HawkFile(fullpath))
{
if (hf.IsArchive)
{
var archiveItem = hf.ArchiveItems.First(ai => ai.Name == filename.Split('|').Skip(1).First());
hf.Unbind();
hf.BindArchiveMember(archiveItem);
data = hf.GetStream().ReadAllBytes();
}
else
{
data = File.ReadAllBytes(fullpath.Split('|').First());
}
}
}
catch
{