Try to fix bugs.

This commit is contained in:
Bruce
2026-04-10 10:50:22 +08:00
parent 19757502ae
commit f563f97f12
17 changed files with 231 additions and 332 deletions

View File

@@ -6,14 +6,12 @@ using System;
namespace PriFileFormat
{
public class PriFile: IDisposable
public class PriFile
{
public string Version { get; private set; }
public uint TotalFileSize { get; private set; }
public IReadOnlyList <TocEntry> TableOfContents { get; private set; }
public IReadOnlyList <Section> Sections { get; private set; }
private bool _disposed = false;
private Stream _internalStream; // 跟踪内部流
private PriFile ()
{
}
@@ -37,7 +35,6 @@ namespace PriFileFormat
private void ParseInternal (Stream stream, bool ownStream)
{
if (ownStream) { _internalStream = stream; }
using (BinaryReader binaryReader = new BinaryReader (stream, Encoding.ASCII, true))
{
long fileStartOffset = binaryReader.BaseStream.Position;
@@ -112,48 +109,6 @@ namespace PriFileFormat
}
}
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
if (_disposed) return;
if (disposing)
{
// 释放托管资源
if (_internalStream != null)
{
_internalStream.Dispose ();
_internalStream = null;
}
// 释放 section 内容
if (Sections != null)
{
foreach (var section in Sections)
{
var unknown = section as UnknownSection;
if (unknown != null)
unknown.ClearContent ();
var dataSection = section as DataItemSection;
if (dataSection != null)
dataSection.ClearData ();
}
Sections = null;
}
}
_disposed = true;
}
~PriFile ()
{
Dispose (false);
}
PriDescriptorSection priDescriptorSection;
public PriDescriptorSection PriDescriptorSection