using GsaEditor.Core.Compression; namespace GsaEditor.Core.Models; /// /// Represents a single file entry within a GSA archive. /// public class GsaEntry { /// /// Relative path (alias) of the file within the archive, using '/' as separator. /// Maximum 511 characters. /// public string Alias { get; set; } = string.Empty; /// /// Whether this entry's data is zlib-compressed. /// public bool IsCompressed { get; set; } /// /// Original (decompressed) size of the file in bytes. /// public uint OriginalLength { get; set; } /// /// Compressed size of the file in bytes. Equal to if not compressed. /// public uint CompressedLength { get; set; } /// /// Raw data as stored in the archive (compressed bytes if is true). /// public byte[] RawData { get; set; } = Array.Empty(); /// /// Byte offset of this entry's data block within the archive file. /// public long DataOffset { get; set; } /// /// Returns the decompressed data for this entry. /// If the entry is not compressed, returns directly. /// /// The decompressed file content. public byte[] GetDecompressedData() { if (!IsCompressed) return RawData; return ZlibHelper.Decompress(RawData, OriginalLength); } /// /// Sets the entry data from uncompressed bytes, optionally compressing with zlib. /// Updates , , /// , and . /// /// The uncompressed file content. /// Whether to compress the data with zlib. public void SetData(byte[] uncompressedData, bool compress) { OriginalLength = (uint)uncompressedData.Length; IsCompressed = compress; if (compress) { RawData = ZlibHelper.Compress(uncompressedData); CompressedLength = (uint)RawData.Length; } else { RawData = uncompressedData; CompressedLength = OriginalLength; } } }