public static void 懒得起名(Stream output, UE_Reader reader, PakEntry entry) { if (entry.Encrypted || entry.Position < 0) { throw new Exception("把这个判断句复制到 caller"); } if (entry.Compression == CompressionMethod.None) { reader.BaseStream.Position = entry.Position + entry.HeaderSize; var _R = reader.ReadBytes((int)(entry.UncompressedSize)); output.Write(_R, 0, _R.Length); } else if (entry.Compression == CompressionMethod.Zlib) { for (int i = 0; i < entry.Blocks.Length; i++) { byte[] cnt = ReadBlock(reader, entry, entry.Blocks[i]); var _R = ZlibStream.UncompressBuffer(cnt); output.Write(_R, 0, _R.Length); } } else { throw new NotImplementedException($"Compression Method {entry.Compression} is not implemented."); } }
static byte[] ReadBlock(UE_Reader reader, PakEntry entry, PakCompressedBlock b_info) { reader.BaseStream.Position = entry.Position + b_info.CompressedStart; long length = b_info.CompressedEnd - b_info.CompressedStart; return(reader.ReadBytes((int)length)); }
public void Feed(PakEntry entry, string pathOverride = null) { string path = pathOverride ?? entry.Filename; int index_slash = path.IndexOf('/'); if (index_slash == 0) { throw new Exception($"Empty directory name: {path}"); } else if (index_slash > 0) { string directory_name = path.Substring(0, index_slash); if (!Directories.TryGetValue(directory_name, out DirectoryValue d_value)) { d_value = new DirectoryValue(); Directories.Add(directory_name, d_value); } d_value.Feed(entry, path.Substring(index_slash + 1)); } else { string file_name = path; if (Files.ContainsKey(file_name)) { throw new Exception($"File already exist: {entry.Filename}"); } Files.Add(file_name, entry); } }
public PakIndex(UE_Reader reader, PakFile pak) { Pak = pak; MountPoint = reader.ReadString(); PakEntryCount = reader.ReadInt32(); Entries = new PakEntry[PakEntryCount]; for (int i = 0; i < Entries.Length; i++) { Entries[i] = new PakEntry(reader, this); } }
static string GetFileInfo(PakEntry entry) { PakInfo info = entry.Index.Pak.Info; var sb = new StringBuilder(); sb.Append($"header_size:{entry.HeaderSize}"); if (entry.Position < 0) { sb.Append(" not_present"); return(sb.ToString()); } // https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings string str_size = String.Format(US_NumFormat, "{0:N0}", entry.UncompressedSize); sb.Append($" size:{str_size}"); if (entry.Encrypted) { sb.Append(" encrypted"); } sb.Append($" compression:{entry.Compression}"); sb.Append($" c_block_count:{entry.PakCompressedBlockCount}"); return(sb.ToString()); }