Add project restore files and NuGet cache for GsaViewer
- Created project.nuget.cache to store NuGet package cache information. - Added project.packagespec.json to define project restore settings and dependencies. - Included rider.project.restore.info for Rider IDE integration.
This commit is contained in:
27
GsaEditor.Core/Models/GsaArchive.cs
Normal file
27
GsaEditor.Core/Models/GsaArchive.cs
Normal file
@ -0,0 +1,27 @@
|
||||
namespace GsaEditor.Core.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a loaded GSA archive with its global header information and file entries.
|
||||
/// </summary>
|
||||
public class GsaArchive
|
||||
{
|
||||
/// <summary>
|
||||
/// The format variant of this archive (NARC or NARD).
|
||||
/// </summary>
|
||||
public GsaFormat Format { get; set; } = GsaFormat.NARC;
|
||||
|
||||
/// <summary>
|
||||
/// (NARD only) Byte alignment for data offsets. Zero or unused for NARC.
|
||||
/// </summary>
|
||||
public int OffsetPadding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (NARD only) Byte alignment for data sizes. Zero or unused for NARC.
|
||||
/// </summary>
|
||||
public int SizePadding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ordered list of file entries in the archive.
|
||||
/// </summary>
|
||||
public List<GsaEntry> Entries { get; set; } = new();
|
||||
}
|
||||
77
GsaEditor.Core/Models/GsaEntry.cs
Normal file
77
GsaEditor.Core/Models/GsaEntry.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using GsaEditor.Core.Compression;
|
||||
|
||||
namespace GsaEditor.Core.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a single file entry within a GSA archive.
|
||||
/// </summary>
|
||||
public class GsaEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Relative path (alias) of the file within the archive, using '/' as separator.
|
||||
/// Maximum 511 characters.
|
||||
/// </summary>
|
||||
public string Alias { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this entry's data is zlib-compressed.
|
||||
/// </summary>
|
||||
public bool IsCompressed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Original (decompressed) size of the file in bytes.
|
||||
/// </summary>
|
||||
public uint OriginalLength { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Compressed size of the file in bytes. Equal to <see cref="OriginalLength"/> if not compressed.
|
||||
/// </summary>
|
||||
public uint CompressedLength { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Raw data as stored in the archive (compressed bytes if <see cref="IsCompressed"/> is true).
|
||||
/// </summary>
|
||||
public byte[] RawData { get; set; } = Array.Empty<byte>();
|
||||
|
||||
/// <summary>
|
||||
/// Byte offset of this entry's data block within the archive file.
|
||||
/// </summary>
|
||||
public long DataOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the decompressed data for this entry.
|
||||
/// If the entry is not compressed, returns <see cref="RawData"/> directly.
|
||||
/// </summary>
|
||||
/// <returns>The decompressed file content.</returns>
|
||||
public byte[] GetDecompressedData()
|
||||
{
|
||||
if (!IsCompressed)
|
||||
return RawData;
|
||||
|
||||
return ZlibHelper.Decompress(RawData, OriginalLength);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the entry data from uncompressed bytes, optionally compressing with zlib.
|
||||
/// Updates <see cref="OriginalLength"/>, <see cref="CompressedLength"/>,
|
||||
/// <see cref="IsCompressed"/>, and <see cref="RawData"/>.
|
||||
/// </summary>
|
||||
/// <param name="uncompressedData">The uncompressed file content.</param>
|
||||
/// <param name="compress">Whether to compress the data with zlib.</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
GsaEditor.Core/Models/GsaFormat.cs
Normal file
18
GsaEditor.Core/Models/GsaFormat.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace GsaEditor.Core.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the archive format variant.
|
||||
/// </summary>
|
||||
public enum GsaFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// Legacy format with no padding support. Magic word = 0x4E415243 ("NARC").
|
||||
/// </summary>
|
||||
NARC,
|
||||
|
||||
/// <summary>
|
||||
/// Enhanced format with offset and size padding for console DVD alignment.
|
||||
/// Magic word = 0x4E415244 ("NARD").
|
||||
/// </summary>
|
||||
NARD
|
||||
}
|
||||
Reference in New Issue
Block a user