From e5ffd784c5cf640b6e901ca81e35274b99424021 Mon Sep 17 00:00:00 2001 From: Crsky Date: Mon, 2 Feb 2026 19:30:03 +0800 Subject: [PATCH] feat: Add Edoire's resource archive --- ArcFormats/ArcFormats.csproj | 1 + ArcFormats/Edoire/ArcARC.cs | 85 ++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 ArcFormats/Edoire/ArcARC.cs diff --git a/ArcFormats/ArcFormats.csproj b/ArcFormats/ArcFormats.csproj index 09a44aec..757307ed 100644 --- a/ArcFormats/ArcFormats.csproj +++ b/ArcFormats/ArcFormats.csproj @@ -156,6 +156,7 @@ WidgetDXA.xaml + diff --git a/ArcFormats/Edoire/ArcARC.cs b/ArcFormats/Edoire/ArcARC.cs new file mode 100644 index 00000000..f9131806 --- /dev/null +++ b/ArcFormats/Edoire/ArcARC.cs @@ -0,0 +1,85 @@ +//! \file ArcARC.cs +//! \date 2026 Feb 02 +//! \brief Edoire's 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.Text; + +namespace GameRes.Formats.Edoire +{ + [Export(typeof(ArchiveFormat))] + public class ArcOpener : ArchiveFormat + { + public override string Tag { get { return "ARC"; } } + public override string Description { get { return "Edoire's resource archive"; } } + public override uint Signature { get { return 0x43524140; } } // "@ARCH000" + public override bool IsHierarchic { get { return true; } } + public override bool CanWrite { get { return false; } } + + public ArcOpener () + { + Extensions = new string[] { "arc" }; + } + + public override ArcFile TryOpen (ArcView file) + { + if (!file.View.AsciiEqual (0, "@ARCH000")) + return null; + var index_offset = file.View.ReadInt64 (file.MaxOffset-8); + var count = file.View.ReadInt32 (index_offset); + if (!IsSaneCount (count)) + return null; + index_offset += 4; + var dir = new List (count); + for (var i = 0; i < count; i++) + { + var len = file.View.ReadByte (index_offset); + index_offset += 1; + var name = file.View.ReadString (index_offset, len, Encoding.UTF8); + index_offset += len; + var offset = file.View.ReadInt64 (index_offset); + index_offset += 8; + var size = file.View.ReadInt64 (index_offset); + index_offset += 9; + len = file.View.ReadByte (index_offset); + index_offset += 1; + var path = file.View.ReadString (index_offset, len, Encoding.UTF8); + index_offset += len; + if (path.StartsWith ("/")) + path = path.Substring (1); + if (!string.IsNullOrEmpty (path) && !path.EndsWith ("/")) + path += "/"; + var entry = Create (path+name); + entry.Offset = offset; + entry.Size = Convert.ToUInt32 (size); + if (!entry.CheckPlacement (file.MaxOffset)) + return null; + dir.Add (entry); + } + return new ArcFile (file, this, dir); + } + } +}