Bienvenidos a Abandonsocios: El Portal de los Juegos Antiguos
0 Usuarios y 1 Visitante están viendo este tema.
using System;using System.Collections.Generic;namespace Format{ public class FAT { private byte[] salt; private List<Volume> volume; public List<Volume> Volume { get { return volume; } } public int Count { get { return volume.Count; } } public FAT(byte[] _salt) { reset(); salt = _salt; } private void reset() { salt = new byte[]{}; volume = new List<Volume>(); } public void addVolume(char[] _volName) { volume.Add(new Volume(_volName)); } }}
using System;using System.Collections.Generic;namespace Format{ public class Volume { private char[] name; private List<Chunk> chunk; public List<Chunk> Chunk { get{ return chunk; } } public int Count { get { return chunk.Count; } } public Volume(char[] _name) { reset(); name = _name; } private void reset() { name = new char[]{}; chunk = new List<Chunk>(); } public void addChunk(int _hash, uint _offset) { chunk.Add(new Chunk(_hash, _offset)); } }}
using System;namespace Format{ public class Chunk { private int hash; private uint offset; private char[] name; private byte[] data; public int Hash { get { return hash; } } public uint Offset { get { return offset; } } public Chunk(int _hash, uint _offset) { reset(); hash = _hash; offset = _offset; } private void reset() { hash = 0; offset = 0; name = new char[]{}; data = new byte[]{}; } public void addContent(char[] _name, byte[] _data) { name = _name; data = _data; } }}
using System;using System.IO;using Format;namespace Lib{ public static class Unpack { public static FAT FAT(string _filename) { const byte FILENAME_MAX = 12; FAT tmpFAT = null; MemoryStream data = new MemoryStream(File.ReadAllBytes(_filename)); ushort nVolumes, nChunks; using (BinaryReader reader = new BinaryReader(data)) { tmpFAT = new FAT(reader.ReadBytes(4)); nVolumes = reader.ReadUInt16(); for (int lVolume = 0; lVolume < nVolumes; lVolume++) { tmpFAT.addVolume(reader.ReadChars(FILENAME_MAX)); reader.BaseStream.Position++; nChunks = reader.ReadUInt16(); for (int lChunk = 0; lChunk < nChunks; lChunk++) { tmpFAT.Volume[lVolume].addChunk(reader.ReadInt32(), reader.ReadUInt32()); } } } return tmpFAT; } }}