mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 07:34:00 +08:00
implemented Ail 'LNK2' archives.
This commit is contained in:
parent
babe2d93d7
commit
d87ac53f9b
@ -49,16 +49,37 @@ namespace GameRes.Formats.Ail
|
||||
int count = file.View.ReadInt32 (0);
|
||||
if (!IsSaneCount (count))
|
||||
return null;
|
||||
long offset = 4+count*4;
|
||||
var dir = ReadIndex (file, 4, count);
|
||||
if (null == dir)
|
||||
return null;
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
|
||||
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||
{
|
||||
var input = arc.File.CreateStream (entry.Offset, entry.Size);
|
||||
var pentry = entry as PackedEntry;
|
||||
if (null == pentry || !pentry.IsPacked)
|
||||
return input;
|
||||
using (input)
|
||||
{
|
||||
byte[] data = new byte[pentry.UnpackedSize];
|
||||
LzssUnpack (input, data);
|
||||
return new BinMemoryStream (data, entry.Name);
|
||||
}
|
||||
}
|
||||
|
||||
internal List<Entry> ReadIndex (ArcView file, uint index_offset, int count)
|
||||
{
|
||||
var base_name = Path.GetFileNameWithoutExtension (file.Name);
|
||||
long offset = index_offset + count*4;
|
||||
if (offset >= file.MaxOffset)
|
||||
return null;
|
||||
var base_name = Path.GetFileNameWithoutExtension (file.Name);
|
||||
uint index_offset = 4;
|
||||
var dir = new List<Entry>();
|
||||
var dir = new List<Entry> (count/2);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
uint size = file.View.ReadUInt32 (index_offset);
|
||||
if (0 != size)
|
||||
if (size != 0 && size != uint.MaxValue)
|
||||
{
|
||||
var entry = new PackedEntry
|
||||
{
|
||||
@ -74,8 +95,14 @@ namespace GameRes.Formats.Ail
|
||||
}
|
||||
index_offset += 4;
|
||||
}
|
||||
if (offset != file.MaxOffset || 0 == dir.Count)
|
||||
if (0 == dir.Count)
|
||||
return null;
|
||||
DetectFileTypes (file, dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
internal void DetectFileTypes (ArcView file, List<Entry> dir)
|
||||
{
|
||||
byte[] preview = new byte[16];
|
||||
byte[] sign_buf = new byte[4];
|
||||
foreach (PackedEntry entry in dir)
|
||||
@ -111,21 +138,6 @@ namespace GameRes.Formats.Ail
|
||||
if (0 != signature)
|
||||
SetEntryType (entry, signature);
|
||||
}
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
|
||||
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||
{
|
||||
var input = arc.File.CreateStream (entry.Offset, entry.Size);
|
||||
var pentry = entry as PackedEntry;
|
||||
if (null == pentry || !pentry.IsPacked)
|
||||
return input;
|
||||
using (input)
|
||||
{
|
||||
byte[] data = new byte[pentry.UnpackedSize];
|
||||
LzssUnpack (input, data);
|
||||
return new BinMemoryStream (data, entry.Name);
|
||||
}
|
||||
}
|
||||
|
||||
static void SetEntryType (Entry entry, uint signature)
|
58
ArcFormats/Ail/ArcLNK2.cs
Normal file
58
ArcFormats/Ail/ArcLNK2.cs
Normal file
@ -0,0 +1,58 @@
|
||||
//! \file ArcLNK2.cs
|
||||
//! \date 2018 Jan 04
|
||||
//! \brief Ail resource archive.
|
||||
//
|
||||
// Copyright (C) 2018 by morkt
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
|
||||
namespace GameRes.Formats.Ail
|
||||
{
|
||||
[Export(typeof(ArchiveFormat))]
|
||||
public class Lnk2Opener : DatOpener
|
||||
{
|
||||
public override string Tag { get { return "DAT/LNK2"; } }
|
||||
public override string Description { get { return "Ail resource archive"; } }
|
||||
public override uint Signature { get { return 0x324B4E4C; } } // 'LNK2'
|
||||
public override bool IsHierarchic { get { return false; } }
|
||||
public override bool CanWrite { get { return false; } }
|
||||
|
||||
public Lnk2Opener ()
|
||||
{
|
||||
Extensions = new string[] { "dat" };
|
||||
}
|
||||
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
int count = file.View.ReadInt32 (4)*2;
|
||||
if (!IsSaneCount (count))
|
||||
return null;
|
||||
var dir = ReadIndex (file, 8, count);
|
||||
if (null == dir)
|
||||
return null;
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
}
|
||||
}
|
@ -81,6 +81,7 @@
|
||||
<Compile Include="Actgs\ArcDAT.cs" />
|
||||
<Compile Include="AdvSys\ArcAdvSys3.cs" />
|
||||
<Compile Include="AdvSys\ImageGWD.cs" />
|
||||
<Compile Include="Ail\ArcLNK2.cs" />
|
||||
<Compile Include="AliceSoft\ArcAAR.cs" />
|
||||
<Compile Include="AliceSoft\ArcAFA.cs" />
|
||||
<Compile Include="AliceSoft\ArcALK.cs" />
|
||||
@ -506,7 +507,7 @@
|
||||
<Compile Include="AdvSys\ArcAdvSysT.cs" />
|
||||
<Compile Include="Cri\ArcAFS.cs" />
|
||||
<Compile Include="elf\ArcAi5Win.cs" />
|
||||
<Compile Include="ArcAil.cs" />
|
||||
<Compile Include="Ail\ArcAil.cs" />
|
||||
<Compile Include="AliceSoft\ArcALD.cs" />
|
||||
<Compile Include="Amaterasu\ArcAMI.cs" />
|
||||
<Compile Include="Lilim\ArcAOS.cs" />
|
||||
@ -1003,7 +1004,9 @@
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Strings\arcStrings.ru-RU.resx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Folder Include="Bonk\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>perl "$(SolutionDir)inc-revision.pl" "$(ProjectPath)" $(ConfigurationName)
|
||||
|
Loading…
Reference in New Issue
Block a user