mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 21:55:34 +08:00
(HDatOpener): preserve filenames in external archive index.
This commit is contained in:
parent
6185af55cd
commit
337f238198
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user