public fileTableEntry readTableEntry(byte[] buffer, bool compressed) { fileTableEntry fte = new fileTableEntry(); if (compressed) { byte[] buf = new byte[276]; ZOutputStream zos = new ZOutputStream(new MemoryStream(buf)); CopyStream(new MemoryStream(buffer), zos, 276); buffer = buf; } BinaryReader br = new BinaryReader(new MemoryStream(buffer)); fte.filePath = Encoding.GetEncoding("GB2312").GetString(br.ReadBytes(260)).Split(new string[] { "\0" }, StringSplitOptions.RemoveEmptyEntries)[0].Replace("/", "\\"); fte.fullFilePath = string.Empty; fte.fileDataOffset = br.ReadUInt32(); fte.fileDataDecompressedSize = br.ReadInt32(); fte.fileDataCompressedSize = br.ReadInt32(); return(fte); }
public byte[] ReadFile(string path) { var file = files.Where(x => x.filePath.ToLower().Contains(path.ToLower())).ToList(); MemoryStream ms = new MemoryStream(); if (file.Count > 0) { fileTableEntry f = file.First(); PckReader br = new PckReader(pck_path); br.Seek(f.fileDataOffset, SeekOrigin.Begin); byte[] buffer = br.ReadBytes(f.fileDataCompressedSize); if (f.fileDataCompressedSize < f.fileDataDecompressedSize) { ZOutputStream zos = new ZOutputStream(ms); CopyStream(new MemoryStream(buffer), zos, f.fileDataCompressedSize); } else { return(buffer); } } return(ms.ToArray()); }