// /*************************************************************************** // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // // Filename : Native.cs // Author(s) : Natalia Portillo // // Component : Checksums. // // --[ Description ] ---------------------------------------------------------- // // Checks that Aaru.Checksums.Native library is available and usable. // // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 2.1 of the // License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, see . // // ---------------------------------------------------------------------------- // Copyright © 2011-2025 Natalia Portillo // ****************************************************************************/ using System; using System.Runtime.InteropServices; using Sentry; namespace Aaru.Checksums; /// Handles native implementations of compression algorithms public static partial class Native { static bool _supported; /// Set to return native as never supported public static bool ForceManaged { get; set; } /// /// If set to true the native library was found and loaded correctly and its reported version is /// compatible. /// public static bool IsSupported { get { if(ForceManaged) return false; if(field) return _supported; ulong version; field = true; try { version = get_acn_version(); } catch(Exception ex) { _supported = false; SentrySdk.CaptureException(ex); return false; } // TODO: Check version compatibility _supported = version >= 0x06000000; return _supported; } } [LibraryImport("libAaru.Checksums.Native", SetLastError = true)] private static partial ulong get_acn_version(); }