加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
AWBUnpack.cs 3.75 KB
一键复制 编辑 原始数据 按行查看 历史
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ArchiveUnpack
{
/// <summary>
/// 解包.awb包
/// <para>只解包不还原</para>
/// </summary>
public class AWBUnpack : FileUnpack
{
AWBHeaderOne[] Headers = null;
public AWBUnpack(string FilePath)
{
if (File.Exists(FilePath))
{
_File = new FileInfo(FilePath);
_File_FS = File.Open(_File.FullName, FileMode.Open);
}
else
{
Log("{0}.constructor:{1} is not exist.", GetType(), FilePath);
}
}
public string GetJSObject()
{
if (Headers == null)
{
ReadHeader();
}
int HeaderCount = Headers.Length;
string JS_Script = "var infiles=[";
for (int i = 0; i < HeaderCount; i++)
{
if (!Headers[i].Name.Contains(".png") && !Headers[i].Name.Contains(".jpg"))
{
JS_Script += "'" + Headers[i].Name + "'" + (i < HeaderCount - 1 ? "," : "];");
}
}
File.WriteAllText("jsobject.js",JS_Script);
return JS_Script;
}
public string GetTextObject()
{
if (Headers == null)
{
ReadHeader();
}
int HeaderCount = Headers.Length;
string JS_Script = "";
for (int i = 0; i < HeaderCount; i++)
{
JS_Script += Headers[i].Name + (i < HeaderCount - 1 ? "\n" : ""); ;
}
File.WriteAllText("PathList.txt", JS_Script);
return JS_Script;
}
public override void ReadHeader()
{
base.ReadHeader();
int ListCount = ReadInt32();
Headers = new AWBHeaderOne[ListCount];
for (int i = 0; i < ListCount; i++)
{
int NameCount = ReadByte();
Headers[i] = new AWBHeaderOne()
{
NameCount = NameCount,
Index = ReadInt32(),
Name = ReadString(NameCount),
//.Replace(".png",".mng").Replace(".jpg",".mpg"),
};
#if DEBUG
//Console.WriteLine(Headers[i].Name);
#endif
}
}
public override void Unpack()
{
base.Unpack();
if (Headers == null)
{
ReadHeader();
}
int HeaderCount = Headers.Length;
for (int i = 0; i < HeaderCount; i++)
{
try
{
int len = Headers[i].Index;
byte[] data = new byte[len];
Headers[i].Set();
if (!string.IsNullOrEmpty("Source/" + Headers[i].Path))
{
Directory.CreateDirectory("Source/" + Headers[i].Path);
}
_File_FS.Read(data, 0, len);
File.WriteAllBytes("Source/" + Headers[i].Name, data);
//if(Encoding.UTF8.GetString(data).Contains("IHDR"))
//{
// Log("IHDR find in {0}", Headers[i].Name);
//}
}catch(Exception e)
{
Log("{0} error: {1}", GetType(), e.Message);
}
}
Log("Read over on {0}.", _File_FS.Position);
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化