本文整理汇总了C#中IPluginHost.Get_Files方法的典型用法代码示例。如果您正苦于以下问题:C# IPluginHost.Get_Files方法的具体用法?C# IPluginHost.Get_Files怎么用?C# IPluginHost.Get_Files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPluginHost
的用法示例。
在下文中一共展示了IPluginHost.Get_Files方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public static sFolder Read(string file, int id, IPluginHost pluginHost)
{
pluginHost.Decompress(file);
string dec_file = pluginHost.Get_Files().files[0].path;
BinaryReader br = new BinaryReader(File.OpenRead(dec_file));
sFolder decompressed = new sFolder();
sPCK2 pck2 = new sPCK2();
pck2.file_id = id;
// Read the header
pck2.header.header_size = br.ReadUInt32();
pck2.header.file_size = br.ReadUInt32();
pck2.header.id = br.ReadChars(4);
pck2.header.unknown = br.ReadUInt32();
// Read all files
decompressed.files = new List<sFile>();
br.BaseStream.Position = pck2.header.header_size;
while (br.BaseStream.Position != br.BaseStream.Length)
{
long pos = br.BaseStream.Position;
sPCK2.File newFile = new sPCK2.File();
newFile.header_size = br.ReadUInt32();
newFile.size = br.ReadUInt32();
newFile.unknown = br.ReadUInt32();
newFile.data_size = br.ReadUInt32();
newFile.name = "";
char c = br.ReadChar();
while (c != '\x0')
{
newFile.name += c;
c = br.ReadChar();
}
br.BaseStream.Position = pos + newFile.header_size;
newFile.data = br.ReadBytes((int)newFile.data_size);
br.BaseStream.Position = pos + newFile.size;
// Save the new file
sFile savedFile = new sFile();
savedFile.name = newFile.name;
savedFile.offset = 0x00;
savedFile.size = newFile.data_size;
savedFile.path = Path.GetTempPath() + Path.DirectorySeparatorChar + newFile.name;
File.WriteAllBytes(savedFile.path, newFile.data);
decompressed.files.Add(savedFile);
}
br.Close();
return decompressed;
}
示例2: Decompress
public static sFile Decompress(string file, IPluginHost pluginHost)
{
sFile decompressed;
string parent_name = Path.GetFileNameWithoutExtension(file).Substring(12);
string temp = parent_name + ".resc";
Byte[] compressFile = new Byte[(new FileInfo(file).Length) - 0x10];
Array.Copy(File.ReadAllBytes(file), 0x10, compressFile, 0, compressFile.Length); ;
File.WriteAllBytes(temp, compressFile);
pluginHost.Decompress(temp);
decompressed = pluginHost.Get_Files().files[0];
File.Delete(temp);
return decompressed;
}
示例3: Unpack
public static sFolder Unpack(sFile file, IPluginHost pluginHost)
{
string filename = Path.GetFileNameWithoutExtension(file.name);
BinaryReader br = new BinaryReader(File.OpenRead(file.path));
string decodedPath = file.path;
byte b = br.ReadByte();
br.Close();
if (b == 0x10)
{
pluginHost.Decompress(file.path);
decodedPath = pluginHost.Get_Files().files[0].path;
}
br = new BinaryReader(File.OpenRead(decodedPath));
sFolder unpacked = new sFolder();
unpacked.files = new List<sFile>();
uint numFiles = br.ReadUInt32();
for (int i = 0; i < numFiles; i++)
{
br.BaseStream.Position = 4 + i * 8;
sFile newFile = new sFile();
newFile.path = decodedPath;
newFile.name = filename + "_" + i.ToString();
newFile.offset = br.ReadUInt32();
newFile.size = br.ReadUInt32();
if (IsPack(br.BaseStream, newFile.offset, newFile.size))
newFile.name += ".pack";
else
newFile.name += ".bin";
unpacked.files.Add(newFile);
}
br.Close();
br = null;
return unpacked;
}