LPKWriter(uint file_count) : base() { m_Header = new LPKHeader(HashCount, file_count); m_HashEntries = new LPKHashEntry[m_Header.Hashcount]; for (int i = 0; i < m_Header.Hashcount; i++) m_HashEntries[i] = null; m_BlockEntries = new LPKBlockEntry[m_Header.BlockCount]; for (int i = 0; i < m_Header.BlockCount; i++) m_BlockEntries[i] = null; }
public LPK(string path) { if (path == null || path == string.Empty) Logging.Fatal("Path to packed file system cannot be empty."); if (!System.IO.File.Exists(path)) Logging.Fatal("Path to packed file system must exist"); m_Reader = InterXLib.Serialize.OpenReader(path); m_Header = new LPKHeader(m_Reader); m_HashEntries = new LPKHashEntry[m_Header.Hashcount]; if (m_Header.HashTableSizeCompressed != 0) { byte[] hash_table_compressed = m_Reader.ReadBytes((int)m_Header.HashTableSizeCompressed); byte[] hash_table = Compression.LZF.Decompress(hash_table_compressed, (int)m_Header.Hashcount * LPKHashEntry.SizeInBytes); using (MemoryStream mem_stream = new MemoryStream(hash_table)) { BinaryFileReader reader = new BinaryFileReader(mem_stream); for (int i = 0; i < m_Header.Hashcount; i++) m_HashEntries[i] = new LPKHashEntry(reader); } } else { for (int i = 0; i < m_Header.Hashcount; i++) m_HashEntries[i] = new LPKHashEntry(m_Reader); } m_BlockEntries = new LPKBlockEntry[m_Header.BlockCount]; if (m_Header.HashTableSizeCompressed != 0) { byte[] block_table_compressed = m_Reader.ReadBytes((int)m_Header.BlockTableSizeCompressed); byte[] block_table = Compression.LZF.Decompress(block_table_compressed, (int)m_Header.BlockCount * LPKBlockEntry.SizeInBytes); using (MemoryStream mem_stream = new MemoryStream(block_table)) { BinaryFileReader reader = new BinaryFileReader(mem_stream); for (int i = 0; i < m_Header.BlockCount; i++) m_BlockEntries[i] = new LPKBlockEntry(reader); } } else { for (int i = 0; i < m_Header.BlockCount; i++) m_BlockEntries[i] = new LPKBlockEntry(m_Reader); } }