123456789101112131415161718192021222324252627282930313233343536373839 |
- using System.IO;
- using System.Text;
- namespace SongCore.Arcache
- {
- public class Lz4ArchiveEntry
- {
- public string FileName { get; set; }
- public long OriginalSize { get; set; }
- internal long Offset { get; set; }
- internal long CompressedSize { get; set; }
- internal void WriteToIndex(Stream stream)
- {
- using var bw = new BinaryWriter(stream, Encoding.UTF8, true);
- var nameBytes = Encoding.UTF8.GetBytes(FileName);
- bw.Write((short)nameBytes.Length);
- bw.Write(nameBytes);
- bw.Write(Offset);
- bw.Write(CompressedSize);
- bw.Write(OriginalSize);
- }
- internal void ReadFromStream(Stream stream)
- {
- using var br = new BinaryReader(stream, Encoding.UTF8, true);
- var nameByteCount = br.ReadInt16();
- var nameBytes = br.ReadBytes(nameByteCount);
- FileName = Encoding.UTF8.GetString(nameBytes);
- Offset = br.ReadInt64();
- CompressedSize = br.ReadInt64();
- OriginalSize = br.ReadInt64();
- }
- }
- }
|