checkpoint

This commit is contained in:
2020-04-29 23:47:06 -04:00
parent 64f7dd4b7d
commit 19a9fc06ba
31 changed files with 678 additions and 360 deletions

View File

@@ -0,0 +1,39 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
namespace Foodsoft.Alpm
{
internal class SafeFilePackageHandle : SafePackageHandle
{
internal SafeAlpmHandle SafeAlpmHandle { get; } = null!;
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
[PrePrepareMethod]
internal SafeFilePackageHandle(IntPtr ptr, SafeAlpmHandle parentHandle)
{
var success = false;
RuntimeHelpers.PrepareConstrainedRegions();
try { }
finally
{
parentHandle.DangerousAddRef(ref success);
if (success)
{
SafeAlpmHandle = parentHandle;
handle = ptr;
}
}
if (!success) throw new ObjectDisposedException(GetType().FullName);
}
protected override bool ReleaseHandle()
{
SafeAlpmHandle.DangerousRelease();
return true;
}
}
}