[AaruFormat] Implement Open

This commit is contained in:
2025-10-11 16:57:19 +01:00
parent f2b421a6b3
commit 57b60bc7dd
4 changed files with 206 additions and 160 deletions

View File

@@ -1,3 +1,4 @@
using System;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
@@ -7,7 +8,10 @@ namespace Aaru.Images;
/// <summary>Implements reading and writing AaruFormat media images</summary>
public sealed partial class AaruFormat : IWritableOpticalImage, IVerifiableImage, IWritableTapeImage
{
const string MODULE_NAME = "Aaru Format plugin";
readonly ImageInfo _imageInfo;
IntPtr _context;
public AaruFormat() => _imageInfo = new ImageInfo
{

View File

@@ -0,0 +1,42 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.Logging;
namespace Aaru.Images;
public sealed partial class AaruFormat
{
#region IWritableOpticalImage Members
/// <inheritdoc />
public ErrorNumber Open(IFilter imageFilter)
{
string imagePath = imageFilter.BasePath;
_context = aaruf_open(imagePath);
if(_context != IntPtr.Zero) return ErrorNumber.NoError;
int errno = Marshal.GetLastWin32Error();
AaruLogging.Debug(MODULE_NAME,
"Failed to open AaruFormat image {0}, libaaruformat returned error number {1}",
imagePath,
errno);
return (ErrorNumber)errno;
}
#endregion
// AARU_EXPORT void AARU_CALL *aaruf_open(const char *filepath)
[LibraryImport("libaaruformat",
EntryPoint = "aaruf_open",
StringMarshalling = StringMarshalling.Utf8,
SetLastError = true)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
private static partial IntPtr aaruf_open(string filepath);
}

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using TapeFile = Aaru.CommonTypes.Structs.TapeFile;
using TapePartition = Aaru.CommonTypes.Structs.TapePartition;
@@ -22,9 +21,6 @@ public sealed partial class AaruFormat
#region IWritableOpticalImage Members
/// <inheritdoc />
public ErrorNumber Open(IFilter imageFilter) => throw new NotImplementedException();
/// <inheritdoc />
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer) => throw new NotImplementedException();

View File

@@ -1,4 +1,7 @@
<wpf:ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml:space="preserve">
<wpf:ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:System;assembly=mscorlib"
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xml:space="preserve">
<s:String x:Key="/Default/CodeInspection/CppInitialization/DefaultPointerInitializer/@EntryValue">Null</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=858398D1_002D7321_002D4763_002D8BAB_002D56BBFEC74E29_002Fd_003Acuetools_002Enet/@EntryIndexedValue">ExplicitlyExcluded</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=AnnotateCanBeNullTypeMember/@EntryIndexedValue"></s:String>
@@ -1316,6 +1319,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=legacyesx/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Legendia/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=LEOT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=libaaruformat/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=libc/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=libudev/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=lisafs/@EntryIndexedValue">True</s:Boolean>