(HDatOpener): preserve filenames in external archive index.

This commit is contained in:
morkt 2017-05-21 23:45:14 +04:00
parent 6185af55cd
commit 337f238198

View File

@ -74,10 +74,11 @@ namespace GameRes.Formats.YaneSDK
{
const int name_length = 0x100;
index.BaseStream.Position = 2;
var name_buf = new byte[name_length];
var dir = new List<Entry> (count);
for (int i = 0; i < count; ++i)
Func<int, Entry> read_entry;
if (null == toc_table)
{
var name_buf = new byte[name_length];
read_entry = i => {
if (name_length != index.Read (name_buf, 0, name_length))
return null;
var name = Binary.GetCString (name_buf, 0);
@ -85,11 +86,25 @@ namespace GameRes.Formats.YaneSDK
index.ReadUInt16();
entry.Size = index.ReadUInt32();
entry.Offset = index.ReadUInt32();
if (toc_table != null)
{
entry.Offset = toc_table[i].Offset;
entry.Size = toc_table[i].Size;
return entry;
};
}
else
{
read_entry = i => {
index.BaseStream.Seek (name_length + 6, SeekOrigin.Current);
index.ReadUInt32(); // throws in case of EOF
var toc_entry = toc_table[i];
var entry = FormatCatalog.Instance.Create<Entry> (toc_entry.Name);
entry.Offset = toc_entry.Offset;
entry.Size = toc_entry.Size;
return entry;
};
}
var dir = new List<Entry> (count);
for (int i = 0; i < count; ++i)
{
var entry = read_entry (i);
if (!entry.CheckPlacement (file.MaxOffset))
return null;
dir.Add (entry);
@ -173,13 +188,15 @@ namespace GameRes.Formats.YaneSDK
}
[Serializable]
public struct HibikiTocRecord
public class HibikiTocRecord
{
public string Name;
public uint Offset;
public uint Size;
public HibikiTocRecord (uint offset, uint size)
public HibikiTocRecord (string name, uint offset, uint size)
{
Name = name;
Offset = offset;
Size = size;
}