public static sFolder Unpack(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); sPCM pcm = new sPCM(); pcm.header_size = br.ReadUInt32(); // ALWAYS 0x10 pcm.file_size = br.ReadUInt32(); pcm.nFiles = br.ReadUInt32(); pcm.id = br.ReadChars(4); // ALWAYS LPCK pcm.files = new KCPL_File[pcm.nFiles]; sFolder unpacked = new sFolder(); unpacked.files = new List <sFile>(); for (int i = 0; i < pcm.nFiles; i++) { long f_offset = br.BaseStream.Position; pcm.files[i].header_size = br.ReadUInt32(); // ALWAYS 0x20 pcm.files[i].file_size = br.ReadUInt32(); // Include padding and header pcm.files[i].unknown = br.ReadUInt32(); // ALWAYS 0x00 pcm.files[i].data_size = br.ReadUInt32(); // Size of the file pcm.files[i].name = new String(br.ReadChars(16)).Replace("\0", ""); pcm.files[i].offset = (uint)(f_offset + pcm.files[i].header_size); br.BaseStream.Position = f_offset + pcm.files[i].file_size; sFile cfile = new sFile(); cfile.name = pcm.files[i].name; cfile.path = file; cfile.offset = pcm.files[i].offset; cfile.size = pcm.files[i].data_size; unpacked.files.Add(cfile); } br.Close(); br = null; return(unpacked); }
public static sFolder Unpack(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); sPCM pcm = new sPCM(); pcm.header_size = br.ReadUInt32(); // ALWAYS 0x10 pcm.file_size = br.ReadUInt32(); pcm.nFiles = br.ReadUInt32(); pcm.id = br.ReadChars(4); // ALWAYS LPCK pcm.files = new KCPL_File[pcm.nFiles]; sFolder unpacked = new sFolder(); unpacked.files = new List<sFile>(); for (int i = 0; i < pcm.nFiles; i++) { long f_offset = br.BaseStream.Position; pcm.files[i].header_size = br.ReadUInt32(); // ALWAYS 0x20 pcm.files[i].file_size = br.ReadUInt32(); // Include padding and header pcm.files[i].unknown = br.ReadUInt32(); // ALWAYS 0x00 pcm.files[i].data_size = br.ReadUInt32(); // Size of the file pcm.files[i].name = new String(br.ReadChars(16)).Replace("\0", ""); pcm.files[i].offset = (uint)(f_offset + pcm.files[i].header_size); br.BaseStream.Position = f_offset + pcm.files[i].file_size; sFile cfile = new sFile(); cfile.name = pcm.files[i].name; cfile.path = file; cfile.offset = pcm.files[i].offset; cfile.size = pcm.files[i].data_size; unpacked.files.Add(cfile); } br.Close(); br = null; return unpacked; }