代码拉取完成,页面将自动刷新
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);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。