mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[AaruFormat] Implement Close.
This commit is contained in:
@@ -6,7 +6,7 @@ namespace Aaru.Images;
|
||||
|
||||
/// <inheritdoc cref="Aaru.CommonTypes.Interfaces.IWritableOpticalImage" />
|
||||
/// <summary>Implements reading and writing AaruFormat media images</summary>
|
||||
public sealed partial class AaruFormat : IWritableOpticalImage, IVerifiableImage, IWritableTapeImage
|
||||
public sealed partial class AaruFormat : IWritableOpticalImage, IVerifiableImage, IWritableTapeImage, IDisposable
|
||||
{
|
||||
const string MODULE_NAME = "Aaru Format plugin";
|
||||
|
||||
|
||||
55
Aaru.Images/AaruFormat/Close.cs
Normal file
55
Aaru.Images/AaruFormat/Close.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Images;
|
||||
|
||||
public sealed partial class AaruFormat
|
||||
{
|
||||
#region IDisposable Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
ReleaseUnmanagedResources();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWritableOpticalImage Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Close()
|
||||
{
|
||||
if(_context == IntPtr.Zero) return false;
|
||||
|
||||
int res = aaruf_close(_context);
|
||||
|
||||
_context = IntPtr.Zero;
|
||||
|
||||
return res == 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
void ReleaseUnmanagedResources()
|
||||
{
|
||||
if(_context == IntPtr.Zero) return;
|
||||
|
||||
aaruf_close(_context);
|
||||
|
||||
_context = IntPtr.Zero;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
~AaruFormat()
|
||||
{
|
||||
ReleaseUnmanagedResources();
|
||||
}
|
||||
|
||||
// AARU_EXPORT int AARU_CALL aaruf_close(void *context)
|
||||
[LibraryImport("libaaruformat", EntryPoint = "aaruf_close", SetLastError = true)]
|
||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
|
||||
private static partial int aaruf_close(IntPtr context);
|
||||
}
|
||||
@@ -50,9 +50,6 @@ public sealed partial class AaruFormat
|
||||
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
|
||||
uint sectorSize) => throw new NotImplementedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Close() => throw new NotImplementedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SetMetadata(Metadata metadata) => throw new NotImplementedException();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user