mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 11:14:25 +00:00
84 lines
2.7 KiB
C#
84 lines
2.7 KiB
C#
// /***************************************************************************
|
|
// Aaru Data Preservation Suite
|
|
// ----------------------------------------------------------------------------
|
|
//
|
|
// Filename : Native.cs
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
//
|
|
// 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 <http://www.gnu.org/licenses/>.
|
|
//
|
|
// ----------------------------------------------------------------------------
|
|
// Copyright © 2011-2025 Natalia Portillo
|
|
// ****************************************************************************/
|
|
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
using Sentry;
|
|
|
|
namespace Aaru.Checksums;
|
|
|
|
/// <summary>Handles native implementations of compression algorithms</summary>
|
|
public static partial class Native
|
|
{
|
|
static bool _supported;
|
|
|
|
/// <summary>Set to return native as never supported</summary>
|
|
public static bool ForceManaged { get; set; }
|
|
|
|
/// <summary>
|
|
/// If set to <c>true</c> the native library was found and loaded correctly and its reported version is
|
|
/// compatible.
|
|
/// </summary>
|
|
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();
|
|
} |