mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 07:34:00 +08:00
(HDatOpener): preserve filenames in external archive index.
This commit is contained in:
parent
6185af55cd
commit
337f238198
@ -74,22 +74,37 @@ namespace GameRes.Formats.YaneSDK
|
|||||||
{
|
{
|
||||||
const int name_length = 0x100;
|
const int name_length = 0x100;
|
||||||
index.BaseStream.Position = 2;
|
index.BaseStream.Position = 2;
|
||||||
var name_buf = new byte[name_length];
|
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);
|
||||||
|
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||||
|
index.ReadUInt16();
|
||||||
|
entry.Size = index.ReadUInt32();
|
||||||
|
entry.Offset = index.ReadUInt32();
|
||||||
|
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);
|
var dir = new List<Entry> (count);
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
if (name_length != index.Read (name_buf, 0, name_length))
|
var entry = read_entry (i);
|
||||||
return null;
|
|
||||||
var name = Binary.GetCString (name_buf, 0);
|
|
||||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
if (!entry.CheckPlacement (file.MaxOffset))
|
if (!entry.CheckPlacement (file.MaxOffset))
|
||||||
return null;
|
return null;
|
||||||
dir.Add (entry);
|
dir.Add (entry);
|
||||||
@ -173,13 +188,15 @@ namespace GameRes.Formats.YaneSDK
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public struct HibikiTocRecord
|
public class HibikiTocRecord
|
||||||
{
|
{
|
||||||
public uint Offset;
|
public string Name;
|
||||||
public uint Size;
|
public uint Offset;
|
||||||
|
public uint Size;
|
||||||
|
|
||||||
public HibikiTocRecord (uint offset, uint size)
|
public HibikiTocRecord (string name, uint offset, uint size)
|
||||||
{
|
{
|
||||||
|
Name = name;
|
||||||
Offset = offset;
|
Offset = offset;
|
||||||
Size = size;
|
Size = size;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user