本文整理汇总了C#中Ekona.sFolder类的典型用法代码示例。如果您正苦于以下问题:C# sFolder类的具体用法?C# sFolder怎么用?C# sFolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
sFolder类属于Ekona命名空间,在下文中一共展示了sFolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Unpack2
public static sFolder Unpack2(IPluginHost pluginHost, sFile file)
{
BinaryReader br = new BinaryReader(File.OpenRead(file.path));
sFolder unpack = new sFolder();
unpack.files = new List<sFile>();
// Read offset table
uint num_files = br.ReadUInt32() / 4;
br.BaseStream.Position -= 4;
for (int i = 0; i < num_files; i++)
{
sFile currFile = new sFile();
currFile.name = file.name + i.ToString();
if (i == 0)
currFile.name += ".ncer";
else if (i == 1)
currFile.name += ".nanr";
else if (i == 2)
currFile.name += ".ncgr";
currFile.offset = br.ReadUInt32();
currFile.path = file.path;
if (i + 1 == num_files) // Last file
currFile.size = (uint)br.BaseStream.Length - currFile.offset;
else
currFile.size = br.ReadUInt32() - currFile.offset;
br.BaseStream.Position -= 4;
unpack.files.Add(currFile);
}
br.Close();
return unpack;
}
示例2: Unpack
public static sFolder Unpack(IPluginHost pluginHost, sFile file)
{
BinaryReader br = new BinaryReader(File.OpenRead(file.path));
sFolder unpack = new sFolder();
unpack.files = new List<sFile>();
// Read offset table
uint currOffset = 0x00;
ushort size = 0x00;
for (int i = 0; ; i++)
{
currOffset = br.ReadUInt32();
size = br.ReadUInt16(); // Size of the file, if it's compressed, size of the decompressed file
br.ReadUInt16(); // Compress flag
if (size == 0x00)
break;
sFile currFile = new sFile();
currFile.name = file.name + '_' + i.ToString() + ".dbin";
currFile.offset = currOffset;
currFile.path = file.path;
currOffset = br.ReadUInt32();
currFile.size = currOffset - currFile.offset;
br.BaseStream.Position -= 4;
unpack.files.Add(currFile);
}
br.Close();
return unpack;
}
示例3: Pack
public string Pack(ref sFolder unpacked, sFile file)
{
string fileOut = pluginHost.Get_TempFile();
PAC.Pack(file.path, fileOut, ref unpacked);
return fileOut;
}
示例4: Unpack
public static sFolder Unpack(string file, IPluginHost pluginHost)
{
BinaryReader br = new BinaryReader(File.OpenRead(file));
sFolder unpacked = new sFolder();
unpacked.files = new List<sFile>();
uint num_files = (br.ReadUInt32() / 0x04) - 1;
br.ReadUInt32(); // Pointer table
for (int i = 0; i < num_files; i++)
{
uint startOffset = br.ReadUInt32();
long currPos = br.BaseStream.Position;
br.BaseStream.Position = startOffset;
sFile newFile = new sFile();
newFile.name = "File " + (i + 1).ToString("X") + ".bin";
newFile.offset = startOffset + 4;
newFile.path = file;
newFile.size = br.ReadUInt32();
br.BaseStream.Position = currPos;
unpacked.files.Add(newFile);
}
br.Close();
return unpacked;
}
示例5: Unpack
public static sFolder Unpack(sFile tableFile, string dataFile)
{
FileStream fs = new FileStream(tableFile.path, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
sFolder unpacked = new sFolder();
unpacked.files = new List<sFile>();
uint numFiles = br.ReadUInt32();
string baseName = Path.GetFileNameWithoutExtension(tableFile.name);
for (int i = 0; i < numFiles; i++)
{
sFile file = new sFile();
file.name = baseName + "_" + i.ToString() + ".bin";
file.path = dataFile;
file.offset = br.ReadUInt32();
file.size = br.ReadUInt32();
br.ReadUInt32(); // Decoded size
unpacked.files.Add(file);
}
br = null;
fs.Close();
fs.Dispose();
fs = null;
return unpacked;
}
示例6: Recursive_GetDirectories
/// <summary>
/// Get a "sFolder" variable with all files and folders from the main folder path.
/// </summary>
/// <param name="folderPath">Folder to read</param>
/// <param name="currFolder">Empty folder</param>
/// <returns></returns>
public static sFolder Recursive_GetDirectories(string folderPath, sFolder currFolder)
{
foreach (string file in Directory.GetFiles(folderPath))
{
sFile newFile = new sFile();
newFile.name = Path.GetFileName(file);
newFile.offset = 0x00;
newFile.path = file;
newFile.size = (uint)new FileInfo(file).Length;
if (!(currFolder.files is List<sFile>))
currFolder.files = new List<sFile>();
currFolder.files.Add(newFile);
}
foreach (string folder in Directory.GetDirectories(folderPath))
{
sFolder newFolder = new sFolder();
newFolder.name = new DirectoryInfo(folder).Name;
newFolder = Recursive_GetDirectories(folder, newFolder);
if (!(currFolder.folders is List<sFolder>))
currFolder.folders = new List<sFolder>();
currFolder.folders.Add(newFolder);
}
return currFolder;
}
示例7: Unpack
public static sFolder Unpack(sFile file)
{
BinaryReader br = new BinaryReader(File.OpenRead(file.path));
sFolder unpack = new sFolder();
unpack.files = new List<sFile>();
br.BaseStream.Position = 0x10; // Header
const int num_files = 0x1246;
for (int i = 0; i < num_files; i++)
{
sFile newFile = new sFile();
newFile.name = "File_" + i.ToString() + '.';
newFile.size = br.ReadUInt32();
newFile.offset = br.ReadUInt32();
newFile.path = file.path;
long currPos = br.BaseStream.Position;
br.BaseStream.Position = newFile.offset;
string ext = new String(br.ReadChars(3));
if (ext != "IMY" && ext != "MAP")
ext = "BIN";
newFile.name += ext;
br.BaseStream.Position = currPos;
unpack.files.Add(newFile);
}
br.Close();
return unpack;
}
示例8: EscribirFAT
public static void EscribirFAT(string salida, sFolder root, int nFiles, uint offsetFAT, uint offsetOverlay9,
uint offsetOverlay7)
{
BinaryWriter bw = new BinaryWriter(new FileStream(salida, FileMode.Create));
Console.Write("File Allocation Table (FAT)...");
UInt32 offset = (uint)(offsetFAT + nFiles * 0x08 + 0x240 + 0x600); // Comienzo de la sección de archivos (FAT+banner)
for (int i = 0; i < nFiles; i++)
{
sFile currFile = Search_File(i, root);
if (currFile.name.StartsWith("overlay9"))
{
bw.Write(offsetOverlay9);
offsetOverlay9 += currFile.size;
bw.Write(offsetOverlay9);
continue;
}
else if (currFile.name.StartsWith("overlay7"))
{
bw.Write(offsetOverlay7);
offsetOverlay7 += currFile.size;
bw.Write(offsetOverlay7);
continue;
}
bw.Write(offset); // Offset de inicio del archivo
offset += currFile.size;
bw.Write(offset); // Offset de fin del archivo
}
bw.Flush();
bw.Close();
Console.WriteLine(Tools.Helper.GetTranslation("Messages", "S09"), new FileInfo(salida).Length);
}
示例9: Decrypt
public static sFolder Decrypt(sFile item, int blockSize, IPluginHost pluginHost)
{
sFolder unpacked = new sFolder();
unpacked.files = new List<sFile>();
byte[] data = File.ReadAllBytes(item.path);
int numBlocks = data.Length / blockSize;
for (int i = 0; i < numBlocks; i++)
{
byte[] block = new byte[blockSize];
Array.Copy(data, i * blockSize, block, 0, blockSize);
Decrypt(ref block);
Array.Copy(block, 0, data, i * blockSize, blockSize);
}
string fileout = pluginHost.Get_TempFile();
File.WriteAllBytes(fileout, data);
sFile newItem = new sFile();
newItem.path = fileout;
newItem.offset = 0;
newItem.name = item.name;
newItem.size = (uint)data.Length;
unpacked.files.Add(newItem);
return unpacked;
}
示例10: Pack
public static string Pack(ref sFolder unpacked, string file, int id)
{
unpacked.files.Sort(SortFiles);
string fileOut = file + "new";
Unpack(file, DPK.pluginHost);
byte[] fileData;
uint numberOfFiles = (uint)unpacked.files.Count;
MemoryStream packedFiles = new MemoryStream();
MemoryStream headerData = new MemoryStream();
MemoryStream packedFile = new MemoryStream();
uint headerLength = 4 + 12 * numberOfFiles + Padding(numberOfFiles);
uint offset = headerLength;
for (int i = 0; i < numberOfFiles; i++)
{
byte[] subFile = new byte[unpacked.files[i].size];
fileData = Helper.ReadFile(unpacked.files[i].path);
for (uint j = 0, k = unpacked.files[i].offset; j < unpacked.files[i].size; j++, k++)
{
try
{
subFile[j] = fileData[k];
}
catch { }
}
sFile newFile = unpacked.files[i];
//newFile.name = unpacked.files[i].name.Remove(unpacked.files[i].name.LastIndexOf('.'));
newFile.size = (uint)subFile.Length;
newFile.offset = offset;
newFile.path = fileOut;
offset += newFile.size;
unpacked.files[i] = newFile;
packedFiles.Write(subFile, 0, subFile.Length);
}
BinaryWriter headerWriter = new BinaryWriter(headerData);
headerWriter.Write(numberOfFiles);
for (int i = 0; i < numberOfFiles; i++)
{
headerWriter.Write(uint.Parse(unpacked.files[i].name.Remove(unpacked.files[i].name.LastIndexOf('.'))));
headerWriter.Write(unpacked.files[i].offset);
headerWriter.Write(unpacked.files[i].size);
}
byte padding = 0xEE;
for (uint i = Padding(numberOfFiles); i > 0; i--)
{
headerWriter.Write(padding);
}
headerData.WriteTo(packedFile);
packedFiles.WriteTo(packedFile);
Helper.WriteFile(fileOut, packedFile.ToArray(), 0, (int)packedFile.Length);
return fileOut;
}
示例11: Unpack
static uint HEADER = 0x50414d57; // "WMAP"
#endregion Fields
#region Methods
public static sFolder Unpack(string fileIn, string name)
{
name = Path.GetFileNameWithoutExtension(name);
BinaryReader br = new BinaryReader(File.OpenRead(fileIn));
sFolder unpack = new sFolder();
unpack.files = new List<sFile>();
if (br.ReadUInt32() != HEADER)
{
br.Close();
br = null;
throw new FormatException("Invalid header!");
}
uint num_files = br.ReadUInt32();
br.ReadUInt32(); // Unknown 1
br.ReadUInt32(); // Unknown 2
for (int i = 0; i < num_files; i++)
{
sFile cfile = new sFile();
cfile.name = name + '_' + i.ToString() + ".bin";
cfile.offset = br.ReadUInt32();
cfile.size = br.ReadUInt32();
cfile.path = fileIn;
unpack.files.Add(cfile);
}
br.Close();
br = null;
return unpack;
}
示例12: Pack
public static void Pack(string output, ref sFolder unpackedFiles)
{
BinaryWriter bw = new BinaryWriter(File.OpenWrite(output));
// Write pointers
bw.Write((uint)((unpackedFiles.files.Count + 1) * 4)); // Pointer table size
uint currOffset = 0x00; // Pointer table offset
bw.Write(currOffset);
currOffset += (uint)(unpackedFiles.files.Count + 1) * 4 + 4;
List<byte> buffer = new List<byte>();
for (int i = 0; i < unpackedFiles.files.Count; i++)
{
BinaryReader br = new BinaryReader(File.OpenRead(unpackedFiles.files[i].path));
br.BaseStream.Position = unpackedFiles.files[i].offset;
buffer.AddRange(BitConverter.GetBytes((uint)unpackedFiles.files[i].size));
buffer.AddRange(br.ReadBytes((int)unpackedFiles.files[i].size));
br.Close();
sFile newFile = unpackedFiles.files[i];
newFile.offset = currOffset + 4;
newFile.path = output;
unpackedFiles.files[i] = newFile;
bw.Write(currOffset);
currOffset += unpackedFiles.files[i].size + 4;
}
// Write files
bw.Write(buffer.ToArray());
bw.Flush();
bw.Close();
}
示例13: Pack
public string Pack(ref sFolder unpacked, sFile file)
{
if (file.name.ToUpper().EndsWith(".DPK"))
return DPK.Pack(ref unpacked, file.path, file.id);
return null;
}
示例14: Unpack
public static sFolder Unpack(string file, string name)
{
BinaryReader br = new BinaryReader(File.OpenRead(file));
sFolder unpacked = new sFolder();
unpacked.files = new List<sFile>();
// Header
char[] type = br.ReadChars(4);
uint first_fileOffset = br.ReadUInt32();
uint num_files = br.ReadUInt32();
for (int i = 0; i < num_files; i++)
{
uint unknown = br.ReadUInt32();
sFile newFile = new sFile();
newFile.name = name + '_' + i.ToString() + ".bin";
newFile.offset = br.ReadUInt32();
newFile.size = br.ReadUInt32();
newFile.path = file;
unpacked.files.Add(newFile);
}
br.Close();
return unpacked;
}
示例15: Pack
public static void Pack(string fileOut, sFolder unpack)
{
string tempFile = Path.GetTempFileName();
BinaryWriter bw = new BinaryWriter(File.OpenWrite(tempFile));
BinaryReader br;
uint f_size;
byte[] name;
// Write file data
for (int i = 0; i < unpack.files.Count; i++)
{
f_size = unpack.files[i].size;
f_size += 0x10 - (f_size % 0x10);
// Write header
bw.Write(0x20);
bw.Write(f_size + 0x20);
bw.Write(0x00);
bw.Write(unpack.files[i].size);
name = Encoding.ASCII.GetBytes(unpack.files[i].name);
for (int j = 0; j < 0x10; j++)
if (j < name.Length)
bw.Write(name[j]);
else
bw.Write((byte)0x00);
br = new BinaryReader(File.OpenRead(unpack.files[i].path));
br.BaseStream.Position = unpack.files[i].offset;
bw.Write(br.ReadBytes((int)unpack.files[i].size));
br.Close();
br = null;
do
bw.Write((byte)0x00);
while (bw.BaseStream.Position % 0x10 != 0);
}
f_size = (uint)bw.BaseStream.Length;
bw.Flush();
bw.Close();
bw = null;
// Write final file
bw = new BinaryWriter(File.OpenWrite(fileOut));
bw.Write(0x10);
bw.Write(f_size + 0x10);
bw.Write(unpack.files.Count);
bw.Write(new char[] { 'L', 'P', 'C', 'K' });
bw.Write(File.ReadAllBytes(tempFile));
bw.Flush();
bw.Close();
bw = null;
File.Delete(tempFile);
}