Skip to content

Commit

Permalink
Move Close implementation to Dispose so using statements work properly
Browse files Browse the repository at this point in the history
  • Loading branch information
speige committed Jan 8, 2025
1 parent d9359e6 commit 45db2e0
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/War3Net.IO.Mpq/MpqStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,6 @@ public override void Write(byte[] buffer, int offset, int count)
throw new NotSupportedException("Write is not supported");
}

/// <inheritdoc/>
public override void Close()
{
base.Close();
if (_isStreamOwner)
{
_stream.Close();
}
}

/// <summary>
/// Copy the base stream, so that the contents do not get decompressed nor decrypted.
/// </summary>
Expand Down Expand Up @@ -760,5 +750,18 @@ private bool TryPeekCompressionType(int blockIndex, int expectedLength, out MpqC
mpqCompressionType = (MpqCompressionType)buffer[0];
return true;
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
if (_isStreamOwner)
{
_stream.Close();
}
}

base.Dispose(disposing);
}
}
}

0 comments on commit 45db2e0

Please sign in to comment.