mirror of
https://github.com/aaru-dps/AaruBenchmark.git
synced 2025-12-16 19:24:36 +00:00
Reorganize all files and use nuget packages for Aaru 5.3 algorithms.
This commit is contained in:
@@ -1 +0,0 @@
|
||||
,claunia,serket,22.09.2021 05:20,file:///home/claunia/.config/libreoffice/4;
|
||||
@@ -1,132 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{CC48B324-A532-4A45-87A6-6F91F7141E8D}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Aaru.Checksums</RootNamespace>
|
||||
<AssemblyName>Aaru.Checksums</AssemblyName>
|
||||
<ReleaseVersion>$(Version)</ReleaseVersion>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>6.0.0-alpha6</Version>
|
||||
<Company>Claunia.com</Company>
|
||||
<Copyright>Copyright © 2011-2021 Natalia Portillo</Copyright>
|
||||
<Product>Aaru Data Preservation Suite</Product>
|
||||
<Title>Aaru.Checksums</Title>
|
||||
<ApplicationVersion>$(Version)</ApplicationVersion>
|
||||
<TargetFramework>net6</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<Description>C# implementation of CRC16, CRC32, CRC64, Fletcher, MD5, SHA1, SHA2 and SpamSum.</Description>
|
||||
<PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl>
|
||||
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
|
||||
<RepositoryUrl>https://github.com/aaru-dps/Aaru.Checksums</RepositoryUrl>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<Authors>Natalia Portillo <claunia@claunia.com></Authors>
|
||||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
|
||||
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
|
||||
<NrtShowRevision>true</NrtShowRevision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CRC16CCITTContext.cs" />
|
||||
<Compile Include="CRC16IBMContext.cs" />
|
||||
<Compile Include="Register.cs" />
|
||||
<Compile Include="SpamSumContext.cs" />
|
||||
<Compile Include="Adler32Context.cs" />
|
||||
<Compile Include="CDChecksums.cs" />
|
||||
<Compile Include="CRC16Context.cs" />
|
||||
<Compile Include="CRC32Context.cs" />
|
||||
<Compile Include="CRC64Context.cs" />
|
||||
<Compile Include="FletcherContext.cs" />
|
||||
<Compile Include="MD5Context.cs" />
|
||||
<Compile Include="ReedSolomon.cs" />
|
||||
<Compile Include="SHA1Context.cs" />
|
||||
<Compile Include="SHA256Context.cs" />
|
||||
<Compile Include="SHA384Context.cs" />
|
||||
<Compile Include="SHA512Context.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj">
|
||||
<Project>{F8BDF57B-1571-4CD0-84B3-B422088D359A}</Project>
|
||||
<Name>Aaru.Helpers</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj">
|
||||
<Project>{CCAA7AFE-C094-4D82-A66D-630DE8A3F545}</Project>
|
||||
<Name>Aaru.Console</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\LICENSE.LGPL">
|
||||
<Link>LICENSE.LGPL</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="..\LICENSE">
|
||||
<Link>LICENSE</Link>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.1" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************
Aaru Data Preservation Suite
----------------------------------------------------------------------------
 
Filename : ${FileName}
Author(s) : ${AuthorName} <${AuthorEmail}>

Component : Component
 
--[ Description ] ----------------------------------------------------------
 
 Description
 
--[ 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-${Year} ${CopyrightHolder}
****************************************************************************/" />
|
||||
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp" />
|
||||
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4')) and '$(OS)' == 'Unix'">
|
||||
<!-- When compiling .NET SDK 2.0 projects targeting .NET 4.x on Mono using 'dotnet build' you -->
|
||||
<!-- have to teach MSBuild where the Mono copy of the reference asssemblies is -->
|
||||
<!-- Look in the standard install locations -->
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/Library/Frameworks/Mono.framework/Versions/Current/lib/mono')">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<!-- If we found Mono reference assemblies, then use them -->
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net40'">$(BaseFrameworkPathOverrideForMono)/4.0-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net45'">$(BaseFrameworkPathOverrideForMono)/4.5-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net451'">$(BaseFrameworkPathOverrideForMono)/4.5.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net452'">$(BaseFrameworkPathOverrideForMono)/4.5.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net46'">$(BaseFrameworkPathOverrideForMono)/4.6-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net461'">$(BaseFrameworkPathOverrideForMono)/4.6.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net462'">$(BaseFrameworkPathOverrideForMono)/4.6.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net471'">$(BaseFrameworkPathOverrideForMono)/4.7.1-api</FrameworkPathOverride>
|
||||
<EnableFrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">true</EnableFrameworkPathOverride>
|
||||
<!-- Add the Facades directory. Not sure how else to do this. Necessary at least for .NET 4.5 -->
|
||||
<AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,648 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : CDChecksums.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Implements CD checksums.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program 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 General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program.If not, see<http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ECC algorithm from ECM(c) 2002-2011 Neill Corlett
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.Console;
|
||||
using Aaru.Helpers;
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <summary>Implements ReedSolomon and CRC32 algorithms as used by CD-ROM</summary>
|
||||
public static class CdChecksums
|
||||
{
|
||||
static byte[] _eccFTable;
|
||||
static byte[] _eccBTable;
|
||||
static uint[] _edcTable;
|
||||
|
||||
/// <summary>Checks the EDC and ECC of a CD sector</summary>
|
||||
/// <param name="buffer">CD sector</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if all checks were correct, <c>false</c> if any of them weren't, and <c>null</c> if none of them
|
||||
/// are present.
|
||||
/// </returns>
|
||||
public static bool? CheckCdSector(byte[] buffer) => CheckCdSector(buffer, out _, out _, out _);
|
||||
|
||||
/// <summary>Checks the EDC and ECC of a CD sector</summary>
|
||||
/// <param name="buffer">CD sector</param>
|
||||
/// <param name="correctEccP">
|
||||
/// <c>true</c> if ECC P is correct, <c>false</c> if it isn't, and <c>null</c> if there is no ECC
|
||||
/// P in sector.
|
||||
/// </param>
|
||||
/// <param name="correctEccQ">
|
||||
/// <c>true</c> if ECC Q is correct, <c>false</c> if it isn't, and <c>null</c> if there is no ECC
|
||||
/// Q in sector.
|
||||
/// </param>
|
||||
/// <param name="correctEdc">
|
||||
/// <c>true</c> if EDC is correct, <c>false</c> if it isn't, and <c>null</c> if there is no EDC in
|
||||
/// sector.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if all checks were correct, <c>false</c> if any of them weren't, and <c>null</c> if none of them
|
||||
/// are present.
|
||||
/// </returns>
|
||||
public static bool? CheckCdSector(byte[] buffer, out bool? correctEccP, out bool? correctEccQ,
|
||||
out bool? correctEdc)
|
||||
{
|
||||
correctEccP = null;
|
||||
correctEccQ = null;
|
||||
correctEdc = null;
|
||||
|
||||
switch(buffer.Length)
|
||||
{
|
||||
case 2448:
|
||||
{
|
||||
byte[] subchannel = new byte[96];
|
||||
byte[] channel = new byte[2352];
|
||||
|
||||
Array.Copy(buffer, 0, channel, 0, 2352);
|
||||
Array.Copy(buffer, 2352, subchannel, 0, 96);
|
||||
|
||||
bool? channelStatus =
|
||||
CheckCdSectorChannel(channel, out correctEccP, out correctEccQ, out correctEdc);
|
||||
|
||||
bool? subchannelStatus = CheckCdSectorSubChannel(subchannel);
|
||||
bool? status = null;
|
||||
|
||||
if(channelStatus == false ||
|
||||
subchannelStatus == false)
|
||||
status = false;
|
||||
|
||||
switch(channelStatus)
|
||||
{
|
||||
case null when subchannelStatus == true:
|
||||
status = true;
|
||||
|
||||
break;
|
||||
case true when subchannelStatus == null:
|
||||
status = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
case 2352: return CheckCdSectorChannel(buffer, out correctEccP, out correctEccQ, out correctEdc);
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
static void EccInit()
|
||||
{
|
||||
_eccFTable = new byte[256];
|
||||
_eccBTable = new byte[256];
|
||||
_edcTable = new uint[256];
|
||||
|
||||
for(uint i = 0; i < 256; i++)
|
||||
{
|
||||
uint edc = i;
|
||||
uint j = (uint)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0));
|
||||
_eccFTable[i] = (byte)j;
|
||||
_eccBTable[i ^ j] = (byte)i;
|
||||
|
||||
for(j = 0; j < 8; j++)
|
||||
edc = (edc >> 1) ^ ((edc & 1) > 0 ? 0xD8018001 : 0);
|
||||
|
||||
_edcTable[i] = edc;
|
||||
}
|
||||
}
|
||||
|
||||
static bool CheckEcc(byte[] address, byte[] data, uint majorCount, uint minorCount, uint majorMult,
|
||||
uint minorInc, byte[] ecc)
|
||||
{
|
||||
uint size = majorCount * minorCount;
|
||||
uint major;
|
||||
|
||||
for(major = 0; major < majorCount; major++)
|
||||
{
|
||||
uint index = ((major >> 1) * majorMult) + (major & 1);
|
||||
byte eccA = 0;
|
||||
byte eccB = 0;
|
||||
uint minor;
|
||||
|
||||
for(minor = 0; minor < minorCount; minor++)
|
||||
{
|
||||
byte temp = index < 4 ? address[index] : data[index - 4];
|
||||
index += minorInc;
|
||||
|
||||
if(index >= size)
|
||||
index -= size;
|
||||
|
||||
eccA ^= temp;
|
||||
eccB ^= temp;
|
||||
eccA = _eccFTable[eccA];
|
||||
}
|
||||
|
||||
eccA = _eccBTable[_eccFTable[eccA] ^ eccB];
|
||||
|
||||
if(ecc[major] != eccA ||
|
||||
ecc[major + majorCount] != (eccA ^ eccB))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool? CheckCdSectorChannel(byte[] channel, out bool? correctEccP, out bool? correctEccQ,
|
||||
out bool? correctEdc)
|
||||
{
|
||||
EccInit();
|
||||
|
||||
correctEccP = null;
|
||||
correctEccQ = null;
|
||||
correctEdc = null;
|
||||
|
||||
if(channel[0x000] != 0x00 ||
|
||||
channel[0x001] != 0xFF ||
|
||||
channel[0x002] != 0xFF ||
|
||||
channel[0x003] != 0xFF ||
|
||||
channel[0x004] != 0xFF ||
|
||||
channel[0x005] != 0xFF ||
|
||||
channel[0x006] != 0xFF ||
|
||||
channel[0x007] != 0xFF ||
|
||||
channel[0x008] != 0xFF ||
|
||||
channel[0x009] != 0xFF ||
|
||||
channel[0x00A] != 0xFF ||
|
||||
channel[0x00B] != 0x00)
|
||||
return null;
|
||||
|
||||
//AaruConsole.DebugWriteLine("CD checksums", "Data sector, address {0:X2}:{1:X2}:{2:X2}", channel[0x00C],
|
||||
// channel[0x00D], channel[0x00E]);
|
||||
|
||||
if((channel[0x00F] & 0x03) == 0x00) // mode (1 byte)
|
||||
{
|
||||
//AaruConsole.DebugWriteLine("CD checksums", "Mode 0 sector at address {0:X2}:{1:X2}:{2:X2}",
|
||||
// channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
for(int i = 0x010; i < 0x930; i++)
|
||||
if(channel[i] != 0x00)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("CD checksums",
|
||||
"Mode 0 sector with error at address: {0:X2}:{1:X2}:{2:X2}",
|
||||
channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if((channel[0x00F] & 0x03) == 0x01) // mode (1 byte)
|
||||
{
|
||||
//AaruConsole.DebugWriteLine("CD checksums", "Mode 1 sector at address {0:X2}:{1:X2}:{2:X2}",
|
||||
// channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
if(channel[0x814] != 0x00 || // reserved (8 bytes)
|
||||
channel[0x815] != 0x00 ||
|
||||
channel[0x816] != 0x00 ||
|
||||
channel[0x817] != 0x00 ||
|
||||
channel[0x818] != 0x00 ||
|
||||
channel[0x819] != 0x00 ||
|
||||
channel[0x81A] != 0x00 ||
|
||||
channel[0x81B] != 0x00)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("CD checksums",
|
||||
"Mode 1 sector with data in reserved bytes at address: {0:X2}:{1:X2}:{2:X2}",
|
||||
channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] address = new byte[4];
|
||||
byte[] data = new byte[2060];
|
||||
byte[] data2 = new byte[2232];
|
||||
byte[] eccP = new byte[172];
|
||||
byte[] eccQ = new byte[104];
|
||||
|
||||
Array.Copy(channel, 0x0C, address, 0, 4);
|
||||
Array.Copy(channel, 0x10, data, 0, 2060);
|
||||
Array.Copy(channel, 0x10, data2, 0, 2232);
|
||||
Array.Copy(channel, 0x81C, eccP, 0, 172);
|
||||
Array.Copy(channel, 0x8C8, eccQ, 0, 104);
|
||||
|
||||
bool failedEccP = !CheckEcc(address, data, 86, 24, 2, 86, eccP);
|
||||
bool failedEccQ = !CheckEcc(address, data2, 52, 43, 86, 88, eccQ);
|
||||
|
||||
correctEccP = !failedEccP;
|
||||
correctEccQ = !failedEccQ;
|
||||
|
||||
if(failedEccP)
|
||||
AaruConsole.DebugWriteLine("CD checksums",
|
||||
"Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC P check",
|
||||
channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
if(failedEccQ)
|
||||
AaruConsole.DebugWriteLine("CD checksums",
|
||||
"Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC Q check",
|
||||
channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
uint storedEdc = BitConverter.ToUInt32(channel, 0x810);
|
||||
uint calculatedEdc = ComputeEdc(0, channel, 0x810);
|
||||
|
||||
correctEdc = calculatedEdc == storedEdc;
|
||||
|
||||
if(calculatedEdc == storedEdc)
|
||||
return !failedEccP && !failedEccQ;
|
||||
|
||||
AaruConsole.DebugWriteLine("CD checksums",
|
||||
"Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}",
|
||||
channel[0x00C], channel[0x00D], channel[0x00E], calculatedEdc, storedEdc);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if((channel[0x00F] & 0x03) == 0x02) // mode (1 byte)
|
||||
{
|
||||
//AaruConsole.DebugWriteLine("CD checksums", "Mode 2 sector at address {0:X2}:{1:X2}:{2:X2}",
|
||||
// channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
byte[] mode2Sector = new byte[channel.Length - 0x10];
|
||||
Array.Copy(channel, 0x10, mode2Sector, 0, mode2Sector.Length);
|
||||
|
||||
if((channel[0x012] & 0x20) == 0x20) // mode 2 form 2
|
||||
{
|
||||
if(channel[0x010] != channel[0x014] ||
|
||||
channel[0x011] != channel[0x015] ||
|
||||
channel[0x012] != channel[0x016] ||
|
||||
channel[0x013] != channel[0x017])
|
||||
AaruConsole.DebugWriteLine("CD checksums",
|
||||
"Subheader copies differ in mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}",
|
||||
channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
uint storedEdc = BitConverter.ToUInt32(mode2Sector, 0x91C);
|
||||
|
||||
// No CRC stored!
|
||||
if(storedEdc == 0x00000000)
|
||||
return true;
|
||||
|
||||
uint calculatedEdc = ComputeEdc(0, mode2Sector, 0x91C);
|
||||
|
||||
correctEdc = calculatedEdc == storedEdc || storedEdc == 0;
|
||||
|
||||
if(calculatedEdc == storedEdc ||
|
||||
storedEdc == 0x00000000)
|
||||
return true;
|
||||
|
||||
AaruConsole.DebugWriteLine("CD checksums",
|
||||
"Mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}",
|
||||
channel[0x00C], channel[0x00D], channel[0x00E], calculatedEdc,
|
||||
storedEdc);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(channel[0x010] != channel[0x014] ||
|
||||
channel[0x011] != channel[0x015] ||
|
||||
channel[0x012] != channel[0x016] ||
|
||||
channel[0x013] != channel[0x017])
|
||||
AaruConsole.DebugWriteLine("CD checksums",
|
||||
"Subheader copies differ in mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}",
|
||||
channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
byte[] address = new byte[4];
|
||||
byte[] eccP = new byte[172];
|
||||
byte[] eccQ = new byte[104];
|
||||
|
||||
Array.Copy(mode2Sector, 0x80C, eccP, 0, 172);
|
||||
Array.Copy(mode2Sector, 0x8B8, eccQ, 0, 104);
|
||||
|
||||
bool failedEccP = !CheckEcc(address, mode2Sector, 86, 24, 2, 86, eccP);
|
||||
bool failedEccQ = !CheckEcc(address, mode2Sector, 52, 43, 86, 88, eccQ);
|
||||
|
||||
correctEccP = !failedEccP;
|
||||
correctEccQ = !failedEccQ;
|
||||
|
||||
if(failedEccP)
|
||||
AaruConsole.DebugWriteLine("CD checksums",
|
||||
"Mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC P check",
|
||||
channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
if(failedEccQ)
|
||||
AaruConsole.DebugWriteLine("CD checksums",
|
||||
"Mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC Q check",
|
||||
channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
uint storedEdc = BitConverter.ToUInt32(mode2Sector, 0x808);
|
||||
uint calculatedEdc = ComputeEdc(0, mode2Sector, 0x808);
|
||||
|
||||
correctEdc = calculatedEdc == storedEdc;
|
||||
|
||||
if(calculatedEdc == storedEdc)
|
||||
return !failedEccP && !failedEccQ;
|
||||
|
||||
AaruConsole.DebugWriteLine("CD checksums",
|
||||
"Mode 2 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}",
|
||||
channel[0x00C], channel[0x00D], channel[0x00E], calculatedEdc,
|
||||
storedEdc);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("CD checksums", "Unknown mode {0} sector at address: {1:X2}:{2:X2}:{3:X2}",
|
||||
channel[0x00F], channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static uint ComputeEdc(uint edc, IReadOnlyList<byte> src, int size)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
for(; size > 0; size--)
|
||||
edc = (edc >> 8) ^ _edcTable[(edc ^ src[pos++]) & 0xFF];
|
||||
|
||||
return edc;
|
||||
}
|
||||
|
||||
static bool? CheckCdSectorSubChannel(IReadOnlyList<byte> subchannel)
|
||||
{
|
||||
bool? status = true;
|
||||
byte[] qSubChannel = new byte[12];
|
||||
byte[] cdTextPack1 = new byte[18];
|
||||
byte[] cdTextPack2 = new byte[18];
|
||||
byte[] cdTextPack3 = new byte[18];
|
||||
byte[] cdTextPack4 = new byte[18];
|
||||
byte[] cdSubRwPack1 = new byte[24];
|
||||
byte[] cdSubRwPack2 = new byte[24];
|
||||
byte[] cdSubRwPack3 = new byte[24];
|
||||
byte[] cdSubRwPack4 = new byte[24];
|
||||
|
||||
int i = 0;
|
||||
|
||||
for(int j = 0; j < 12; j++)
|
||||
qSubChannel[j] = 0;
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack1[j] = 0;
|
||||
cdTextPack2[j] = 0;
|
||||
cdTextPack3[j] = 0;
|
||||
cdTextPack4[j] = 0;
|
||||
}
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
{
|
||||
cdSubRwPack1[j] = 0;
|
||||
cdSubRwPack2[j] = 0;
|
||||
cdSubRwPack3[j] = 0;
|
||||
cdSubRwPack4[j] = 0;
|
||||
}
|
||||
|
||||
for(int j = 0; j < 12; j++)
|
||||
{
|
||||
qSubChannel[j] = (byte)(qSubChannel[j] | ((subchannel[i++] & 0x40) << 1));
|
||||
qSubChannel[j] = (byte)(qSubChannel[j] | (subchannel[i++] & 0x40));
|
||||
qSubChannel[j] = (byte)(qSubChannel[j] | ((subchannel[i++] & 0x40) >> 1));
|
||||
qSubChannel[j] = (byte)(qSubChannel[j] | ((subchannel[i++] & 0x40) >> 2));
|
||||
qSubChannel[j] = (byte)(qSubChannel[j] | ((subchannel[i++] & 0x40) >> 3));
|
||||
qSubChannel[j] = (byte)(qSubChannel[j] | ((subchannel[i++] & 0x40) >> 4));
|
||||
qSubChannel[j] = (byte)(qSubChannel[j] | ((subchannel[i++] & 0x40) >> 5));
|
||||
qSubChannel[j] = (byte)(qSubChannel[j] | ((subchannel[i++] & 0x40) >> 6));
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
|
||||
if(j < 17)
|
||||
cdTextPack1[j] = (byte)(cdTextPack1[j++] | ((subchannel[i] & 0xC0) >> 4));
|
||||
|
||||
cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x0F) << 4));
|
||||
|
||||
if(j < 17)
|
||||
cdTextPack1[j] = (byte)(cdTextPack1[j++] | ((subchannel[i] & 0x3C) >> 2));
|
||||
|
||||
cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x03) << 6));
|
||||
|
||||
cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
|
||||
if(j < 17)
|
||||
cdTextPack2[j] = (byte)(cdTextPack2[j++] | ((subchannel[i] & 0xC0) >> 4));
|
||||
|
||||
cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x0F) << 4));
|
||||
|
||||
if(j < 17)
|
||||
cdTextPack2[j] = (byte)(cdTextPack2[j++] | ((subchannel[i] & 0x3C) >> 2));
|
||||
|
||||
cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x03) << 6));
|
||||
|
||||
cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
|
||||
if(j < 17)
|
||||
cdTextPack3[j] = (byte)(cdTextPack3[j++] | ((subchannel[i] & 0xC0) >> 4));
|
||||
|
||||
cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x0F) << 4));
|
||||
|
||||
if(j < 17)
|
||||
cdTextPack3[j] = (byte)(cdTextPack3[j++] | ((subchannel[i] & 0x3C) >> 2));
|
||||
|
||||
cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x03) << 6));
|
||||
|
||||
cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
|
||||
if(j < 17)
|
||||
cdTextPack4[j] = (byte)(cdTextPack4[j++] | ((subchannel[i] & 0xC0) >> 4));
|
||||
|
||||
cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x0F) << 4));
|
||||
|
||||
if(j < 17)
|
||||
cdTextPack4[j] = (byte)(cdTextPack4[j++] | ((subchannel[i] & 0x3C) >> 2));
|
||||
|
||||
cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x03) << 6));
|
||||
|
||||
cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
switch(cdSubRwPack1[0])
|
||||
{
|
||||
case 0x00:
|
||||
AaruConsole.DebugWriteLine("CD checksums", "Detected Zero Pack in subchannel");
|
||||
|
||||
break;
|
||||
case 0x08:
|
||||
AaruConsole.DebugWriteLine("CD checksums", "Detected Line Graphics Pack in subchannel");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
AaruConsole.DebugWriteLine("CD checksums", "Detected CD+G Pack in subchannel");
|
||||
|
||||
break;
|
||||
case 0x0A:
|
||||
AaruConsole.DebugWriteLine("CD checksums", "Detected CD+EG Pack in subchannel");
|
||||
|
||||
break;
|
||||
case 0x14:
|
||||
AaruConsole.DebugWriteLine("CD checksums", "Detected CD-TEXT Pack in subchannel");
|
||||
|
||||
break;
|
||||
case 0x18:
|
||||
AaruConsole.DebugWriteLine("CD checksums", "Detected CD+MIDI Pack in subchannel");
|
||||
|
||||
break;
|
||||
case 0x38:
|
||||
AaruConsole.DebugWriteLine("CD checksums", "Detected User Pack in subchannel");
|
||||
|
||||
break;
|
||||
default:
|
||||
AaruConsole.DebugWriteLine("CD checksums",
|
||||
"Detected unknown Pack type in subchannel: mode {0}, item {1}",
|
||||
Convert.ToString(cdSubRwPack1[0] & 0x38, 2),
|
||||
Convert.ToString(cdSubRwPack1[0] & 0x07, 2));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
ushort qSubChannelCrc = BigEndianBitConverter.ToUInt16(qSubChannel, 10);
|
||||
byte[] qSubChannelForCrc = new byte[10];
|
||||
Array.Copy(qSubChannel, 0, qSubChannelForCrc, 0, 10);
|
||||
ushort calculatedQcrc = CRC16CCITTContext.Calculate(qSubChannelForCrc);
|
||||
|
||||
if(qSubChannelCrc != calculatedQcrc)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("CD checksums", "Q subchannel CRC 0x{0:X4}, expected 0x{1:X4}",
|
||||
calculatedQcrc, qSubChannelCrc);
|
||||
|
||||
status = false;
|
||||
}
|
||||
|
||||
if((cdTextPack1[0] & 0x80) == 0x80)
|
||||
{
|
||||
ushort cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16);
|
||||
byte[] cdTextPack1ForCrc = new byte[16];
|
||||
Array.Copy(cdTextPack1, 0, cdTextPack1ForCrc, 0, 16);
|
||||
ushort calculatedCdtp1Crc = CRC16CCITTContext.Calculate(cdTextPack1ForCrc);
|
||||
|
||||
if(cdTextPack1Crc != calculatedCdtp1Crc &&
|
||||
cdTextPack1Crc != 0)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("CD checksums", "CD-Text Pack 1 CRC 0x{0:X4}, expected 0x{1:X4}",
|
||||
cdTextPack1Crc, calculatedCdtp1Crc);
|
||||
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
|
||||
if((cdTextPack2[0] & 0x80) == 0x80)
|
||||
{
|
||||
ushort cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16);
|
||||
byte[] cdTextPack2ForCrc = new byte[16];
|
||||
Array.Copy(cdTextPack2, 0, cdTextPack2ForCrc, 0, 16);
|
||||
ushort calculatedCdtp2Crc = CRC16CCITTContext.Calculate(cdTextPack2ForCrc);
|
||||
|
||||
AaruConsole.DebugWriteLine("CD checksums", "Cyclic CDTP2 0x{0:X4}, Calc CDTP2 0x{1:X4}", cdTextPack2Crc,
|
||||
calculatedCdtp2Crc);
|
||||
|
||||
if(cdTextPack2Crc != calculatedCdtp2Crc &&
|
||||
cdTextPack2Crc != 0)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("CD checksums", "CD-Text Pack 2 CRC 0x{0:X4}, expected 0x{1:X4}",
|
||||
cdTextPack2Crc, calculatedCdtp2Crc);
|
||||
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
|
||||
if((cdTextPack3[0] & 0x80) == 0x80)
|
||||
{
|
||||
ushort cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16);
|
||||
byte[] cdTextPack3ForCrc = new byte[16];
|
||||
Array.Copy(cdTextPack3, 0, cdTextPack3ForCrc, 0, 16);
|
||||
ushort calculatedCdtp3Crc = CRC16CCITTContext.Calculate(cdTextPack3ForCrc);
|
||||
|
||||
AaruConsole.DebugWriteLine("CD checksums", "Cyclic CDTP3 0x{0:X4}, Calc CDTP3 0x{1:X4}", cdTextPack3Crc,
|
||||
calculatedCdtp3Crc);
|
||||
|
||||
if(cdTextPack3Crc != calculatedCdtp3Crc &&
|
||||
cdTextPack3Crc != 0)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("CD checksums", "CD-Text Pack 3 CRC 0x{0:X4}, expected 0x{1:X4}",
|
||||
cdTextPack3Crc, calculatedCdtp3Crc);
|
||||
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
|
||||
if((cdTextPack4[0] & 0x80) != 0x80)
|
||||
return status;
|
||||
|
||||
ushort cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16);
|
||||
byte[] cdTextPack4ForCrc = new byte[16];
|
||||
Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16);
|
||||
ushort calculatedCdtp4Crc = CRC16CCITTContext.Calculate(cdTextPack4ForCrc);
|
||||
|
||||
AaruConsole.DebugWriteLine("CD checksums", "Cyclic CDTP4 0x{0:X4}, Calc CDTP4 0x{1:X4}", cdTextPack4Crc,
|
||||
calculatedCdtp4Crc);
|
||||
|
||||
if(cdTextPack4Crc == calculatedCdtp4Crc ||
|
||||
cdTextPack4Crc == 0)
|
||||
return status;
|
||||
|
||||
AaruConsole.DebugWriteLine("CD checksums", "CD-Text Pack 4 CRC 0x{0:X4}, expected 0x{1:X4}", cdTextPack4Crc,
|
||||
calculatedCdtp4Crc);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : CRC16CCITTContext.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Implements a CRC16 algorithm with the CCITT polynomial.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements the CRC16 algorithm with CCITT polynomial and seed</summary>
|
||||
public sealed class CRC16CCITTContext : Crc16Context
|
||||
{
|
||||
/// <summary>CCITT CRC16 polynomial</summary>
|
||||
public const ushort CRC16_CCITT_POLY = 0x8408;
|
||||
/// <summary>CCITT CRC16 seed</summary>
|
||||
public const ushort CRC16_CCITT_SEED = 0x0000;
|
||||
static readonly ushort[] _ccittCrc16Table =
|
||||
{
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c,
|
||||
0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318,
|
||||
0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4,
|
||||
0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630,
|
||||
0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4,
|
||||
0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969,
|
||||
0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf,
|
||||
0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
|
||||
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13,
|
||||
0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9,
|
||||
0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046,
|
||||
0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2,
|
||||
0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2,
|
||||
0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e,
|
||||
0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e,
|
||||
0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
|
||||
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1,
|
||||
0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07,
|
||||
0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9,
|
||||
0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
|
||||
};
|
||||
|
||||
/// <summary>Initializes an instance of the CRC16 with CCITT polynomial and seed.</summary>
|
||||
/// <inheritdoc />
|
||||
public CRC16CCITTContext() : base(CRC16_CCITT_POLY, CRC16_CCITT_SEED, _ccittCrc16Table, true) {}
|
||||
|
||||
/// <summary>Gets the hash of a file</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
File(filename, out byte[] hash);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file in hexadecimal and as a byte array.</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string File(string filename, out byte[] hash) =>
|
||||
File(filename, out hash, CRC16_CCITT_POLY, CRC16_CCITT_SEED, _ccittCrc16Table, true);
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash) =>
|
||||
Data(data, len, out hash, CRC16_CCITT_POLY, CRC16_CCITT_SEED, _ccittCrc16Table, true);
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
|
||||
|
||||
/// <summary>Calculates the CCITT CRC16 of the specified buffer with the specified parameters</summary>
|
||||
/// <param name="buffer">Buffer</param>
|
||||
public static ushort Calculate(byte[] buffer) =>
|
||||
Calculate(buffer, CRC16_CCITT_POLY, CRC16_CCITT_SEED, _ccittCrc16Table, true);
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : CRC16IBMContext.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Implements a CRC16 algorithm with the IBM polynomial.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements the CRC16 algorithm with IBM polynomial and seed</summary>
|
||||
public sealed class CRC16IBMContext : Crc16Context
|
||||
{
|
||||
const ushort CRC16_IBM_POLY = 0xA001;
|
||||
const ushort CRC16_IBM_SEED = 0x0000;
|
||||
|
||||
static readonly ushort[] _ibmCrc16Table =
|
||||
{
|
||||
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500,
|
||||
0xC5C1, 0xC481, 0x0440, 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, 0x0A00, 0xCAC1,
|
||||
0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81,
|
||||
0x1A40, 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, 0x1400, 0xD4C1, 0xD581, 0x1540,
|
||||
0xD701, 0x17C0, 0x1680, 0xD641, 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, 0xF001,
|
||||
0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0,
|
||||
0x3480, 0xF441, 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, 0xFA01, 0x3AC0, 0x3B80,
|
||||
0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
|
||||
0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700,
|
||||
0xE7C1, 0xE681, 0x2640, 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041, 0xA001, 0x60C0,
|
||||
0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480,
|
||||
0xA441, 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, 0xAA01, 0x6AC0, 0x6B80, 0xAB41,
|
||||
0x6900, 0xA9C1, 0xA881, 0x6840, 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, 0xBE01,
|
||||
0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1,
|
||||
0xB681, 0x7640, 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, 0x5000, 0x90C1, 0x9181,
|
||||
0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
|
||||
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901,
|
||||
0x59C0, 0x5880, 0x9841, 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, 0x4E00, 0x8EC1,
|
||||
0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680,
|
||||
0x8641, 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
||||
};
|
||||
|
||||
/// <summary>Initializes an instance of the CRC16 with IBM polynomial and seed.</summary>
|
||||
/// <inheritdoc />
|
||||
public CRC16IBMContext() : base(CRC16_IBM_POLY, CRC16_IBM_SEED, _ibmCrc16Table, false) {}
|
||||
|
||||
/// <summary>Gets the hash of a file</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
File(filename, out byte[] hash);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file in hexadecimal and as a byte array.</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string File(string filename, out byte[] hash) =>
|
||||
File(filename, out hash, CRC16_IBM_POLY, CRC16_IBM_SEED, _ibmCrc16Table, false);
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash) =>
|
||||
Data(data, len, out hash, CRC16_IBM_POLY, CRC16_IBM_SEED, _ibmCrc16Table, false);
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
|
||||
|
||||
/// <summary>Calculates the IBM CRC16 of the specified buffer with the specified parameters</summary>
|
||||
/// <param name="buffer">Buffer</param>
|
||||
public static ushort Calculate(byte[] buffer) =>
|
||||
Calculate(buffer, CRC16_IBM_POLY, CRC16_IBM_SEED, _ibmCrc16Table, false);
|
||||
}
|
||||
}
|
||||
@@ -1,234 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : CRC32Context.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Implements a CRC32 algorithm.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Helpers;
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements a CRC32 algorithm</summary>
|
||||
public sealed class Crc32Context : IChecksum
|
||||
{
|
||||
const uint CRC32_ISO_POLY = 0xEDB88320;
|
||||
const uint CRC32_ISO_SEED = 0xFFFFFFFF;
|
||||
|
||||
readonly uint _finalSeed;
|
||||
readonly uint[] _table;
|
||||
uint _hashInt;
|
||||
|
||||
/// <summary>Initializes the CRC32 table and seed as CRC32-ISO</summary>
|
||||
public Crc32Context()
|
||||
{
|
||||
_hashInt = CRC32_ISO_SEED;
|
||||
_finalSeed = CRC32_ISO_SEED;
|
||||
|
||||
_table = new uint[256];
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
uint entry = (uint)i;
|
||||
|
||||
for(int j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ CRC32_ISO_POLY;
|
||||
else
|
||||
entry >>= 1;
|
||||
|
||||
_table[i] = entry;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Initializes the CRC32 table with a custom polynomial and seed</summary>
|
||||
public Crc32Context(uint polynomial, uint seed)
|
||||
{
|
||||
_hashInt = seed;
|
||||
_finalSeed = seed;
|
||||
|
||||
_table = new uint[256];
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
uint entry = (uint)i;
|
||||
|
||||
for(int j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ polynomial;
|
||||
else
|
||||
entry >>= 1;
|
||||
|
||||
_table[i] = entry;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of buffer to hash.</param>
|
||||
public void Update(byte[] data, uint len)
|
||||
{
|
||||
for(int i = 0; i < len; i++)
|
||||
_hashInt = (_hashInt >> 8) ^ _table[data[i] ^ (_hashInt & 0xff)];
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
public void Update(byte[] data) => Update(data, (uint)data.Length);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a byte array of the hash value.</summary>
|
||||
public byte[] Final() => BigEndianBitConverter.GetBytes(_hashInt ^ _finalSeed);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a hexadecimal representation of the hash value.</summary>
|
||||
public string End()
|
||||
{
|
||||
var crc32Output = new StringBuilder();
|
||||
|
||||
for(int i = 0; i < BigEndianBitConverter.GetBytes(_hashInt ^ _finalSeed).Length; i++)
|
||||
crc32Output.Append(BigEndianBitConverter.GetBytes(_hashInt ^ _finalSeed)[i].ToString("x2"));
|
||||
|
||||
return crc32Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
File(filename, out byte[] hash);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file in hexadecimal and as a byte array.</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string File(string filename, out byte[] hash) =>
|
||||
File(filename, out hash, CRC32_ISO_POLY, CRC32_ISO_SEED);
|
||||
|
||||
/// <summary>Gets the hash of a file in hexadecimal and as a byte array.</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
/// <param name="polynomial">CRC polynomial</param>
|
||||
/// <param name="seed">CRC seed</param>
|
||||
public static string File(string filename, out byte[] hash, uint polynomial, uint seed)
|
||||
{
|
||||
var fileStream = new FileStream(filename, FileMode.Open);
|
||||
|
||||
uint localHashInt = seed;
|
||||
|
||||
uint[] localTable = new uint[256];
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
uint entry = (uint)i;
|
||||
|
||||
for(int j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ polynomial;
|
||||
else
|
||||
entry >>= 1;
|
||||
|
||||
localTable[i] = entry;
|
||||
}
|
||||
|
||||
for(int i = 0; i < fileStream.Length; i++)
|
||||
localHashInt = (localHashInt >> 8) ^ localTable[fileStream.ReadByte() ^ (localHashInt & 0xff)];
|
||||
|
||||
localHashInt ^= seed;
|
||||
hash = BigEndianBitConverter.GetBytes(localHashInt);
|
||||
|
||||
var crc32Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
crc32Output.Append(h.ToString("x2"));
|
||||
|
||||
fileStream.Close();
|
||||
|
||||
return crc32Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash) =>
|
||||
Data(data, len, out hash, CRC32_ISO_POLY, CRC32_ISO_SEED);
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
/// <param name="polynomial">CRC polynomial</param>
|
||||
/// <param name="seed">CRC seed</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash, uint polynomial, uint seed)
|
||||
{
|
||||
uint localHashInt = seed;
|
||||
|
||||
uint[] localTable = new uint[256];
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
uint entry = (uint)i;
|
||||
|
||||
for(int j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ polynomial;
|
||||
else
|
||||
entry >>= 1;
|
||||
|
||||
localTable[i] = entry;
|
||||
}
|
||||
|
||||
for(int i = 0; i < len; i++)
|
||||
localHashInt = (localHashInt >> 8) ^ localTable[data[i] ^ (localHashInt & 0xff)];
|
||||
|
||||
localHashInt ^= seed;
|
||||
hash = BigEndianBitConverter.GetBytes(localHashInt);
|
||||
|
||||
var crc32Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
crc32Output.Append(h.ToString("x2"));
|
||||
|
||||
return crc32Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
|
||||
}
|
||||
}
|
||||
@@ -1,238 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : CRC64Context.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Implements a CRC64 algorithm.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Helpers;
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements a CRC64 algorithm</summary>
|
||||
public sealed class Crc64Context : IChecksum
|
||||
{
|
||||
/// <summary>ECMA CRC64 polynomial</summary>
|
||||
public const ulong CRC64_ECMA_POLY = 0xC96C5795D7870F42;
|
||||
/// <summary>ECMA CRC64 seed</summary>
|
||||
public const ulong CRC64_ECMA_SEED = 0xFFFFFFFFFFFFFFFF;
|
||||
|
||||
readonly ulong _finalSeed;
|
||||
readonly ulong[] _table;
|
||||
ulong _hashInt;
|
||||
|
||||
/// <summary>Initializes the CRC64 table and seed as CRC64-ECMA</summary>
|
||||
public Crc64Context()
|
||||
{
|
||||
_hashInt = CRC64_ECMA_SEED;
|
||||
|
||||
_table = new ulong[256];
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
ulong entry = (ulong)i;
|
||||
|
||||
for(int j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ CRC64_ECMA_POLY;
|
||||
else
|
||||
entry >>= 1;
|
||||
|
||||
_table[i] = entry;
|
||||
}
|
||||
|
||||
_finalSeed = CRC64_ECMA_SEED;
|
||||
}
|
||||
|
||||
/// <summary>Initializes the CRC16 table with a custom polynomial and seed</summary>
|
||||
public Crc64Context(ulong polynomial, ulong seed)
|
||||
{
|
||||
_hashInt = seed;
|
||||
|
||||
_table = new ulong[256];
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
ulong entry = (ulong)i;
|
||||
|
||||
for(int j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ polynomial;
|
||||
else
|
||||
entry >>= 1;
|
||||
|
||||
_table[i] = entry;
|
||||
}
|
||||
|
||||
_finalSeed = seed;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of buffer to hash.</param>
|
||||
public void Update(byte[] data, uint len)
|
||||
{
|
||||
for(int i = 0; i < len; i++)
|
||||
_hashInt = (_hashInt >> 8) ^ _table[data[i] ^ (_hashInt & 0xff)];
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
public void Update(byte[] data) => Update(data, (uint)data.Length);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a byte array of the hash value.</summary>
|
||||
public byte[] Final() => BigEndianBitConverter.GetBytes(_hashInt ^= _finalSeed);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a hexadecimal representation of the hash value.</summary>
|
||||
public string End()
|
||||
{
|
||||
var crc64Output = new StringBuilder();
|
||||
|
||||
for(int i = 0; i < BigEndianBitConverter.GetBytes(_hashInt ^= _finalSeed).Length; i++)
|
||||
crc64Output.Append(BigEndianBitConverter.GetBytes(_hashInt ^= _finalSeed)[i].ToString("x2"));
|
||||
|
||||
return crc64Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
File(filename, out byte[] localHash);
|
||||
|
||||
return localHash;
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file in hexadecimal and as a byte array.</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string File(string filename, out byte[] hash) =>
|
||||
File(filename, out hash, CRC64_ECMA_POLY, CRC64_ECMA_SEED);
|
||||
|
||||
/// <summary>Gets the hash of a file in hexadecimal and as a byte array.</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
/// <param name="polynomial">CRC polynomial</param>
|
||||
/// <param name="seed">CRC seed</param>
|
||||
public static string File(string filename, out byte[] hash, ulong polynomial, ulong seed)
|
||||
{
|
||||
var fileStream = new FileStream(filename, FileMode.Open);
|
||||
|
||||
ulong localHashInt = seed;
|
||||
|
||||
ulong[] localTable = new ulong[256];
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
ulong entry = (ulong)i;
|
||||
|
||||
for(int j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ polynomial;
|
||||
else
|
||||
entry >>= 1;
|
||||
|
||||
localTable[i] = entry;
|
||||
}
|
||||
|
||||
for(int i = 0; i < fileStream.Length; i++)
|
||||
localHashInt = (localHashInt >> 8) ^ localTable[(ulong)fileStream.ReadByte() ^ (localHashInt & 0xffL)];
|
||||
|
||||
localHashInt ^= seed;
|
||||
hash = BigEndianBitConverter.GetBytes(localHashInt);
|
||||
|
||||
var crc64Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
crc64Output.Append(h.ToString("x2"));
|
||||
|
||||
fileStream.Close();
|
||||
|
||||
return crc64Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash) =>
|
||||
Data(data, len, out hash, CRC64_ECMA_POLY, CRC64_ECMA_SEED);
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
/// <param name="polynomial">CRC polynomial</param>
|
||||
/// <param name="seed">CRC seed</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash, ulong polynomial, ulong seed)
|
||||
{
|
||||
ulong localHashInt = seed;
|
||||
|
||||
ulong[] localTable = new ulong[256];
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
ulong entry = (ulong)i;
|
||||
|
||||
for(int j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ polynomial;
|
||||
else
|
||||
entry >>= 1;
|
||||
|
||||
localTable[i] = entry;
|
||||
}
|
||||
|
||||
for(int i = 0; i < len; i++)
|
||||
localHashInt = (localHashInt >> 8) ^ localTable[data[i] ^ (localHashInt & 0xff)];
|
||||
|
||||
localHashInt ^= seed;
|
||||
hash = BigEndianBitConverter.GetBytes(localHashInt);
|
||||
|
||||
var crc64Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
crc64Output.Append(h.ToString("x2"));
|
||||
|
||||
return crc64Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : MD5Context.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Wraps up .NET MD5 implementation to a Init(), Update(), Final() context.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <summary>Wraps up .NET MD5 implementation to a Init(), Update(), Final() context.</summary>
|
||||
public sealed class Md5Context : IChecksum
|
||||
{
|
||||
readonly MD5 _provider;
|
||||
|
||||
/// <summary>Initializes the MD5 hash provider</summary>
|
||||
public Md5Context() => _provider = MD5.Create();
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of buffer to hash.</param>
|
||||
public void Update(byte[] data, uint len) => _provider.TransformBlock(data, 0, (int)len, data, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
public void Update(byte[] data) => Update(data, (uint)data.Length);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a byte array of the hash value.</summary>
|
||||
public byte[] Final()
|
||||
{
|
||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||
|
||||
return _provider.Hash;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a hexadecimal representation of the hash value.</summary>
|
||||
public string End()
|
||||
{
|
||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||
var md5Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in _provider.Hash)
|
||||
md5Output.Append(h.ToString("x2"));
|
||||
|
||||
return md5Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
var localMd5Provider = MD5.Create();
|
||||
var fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = localMd5Provider.ComputeHash(fileStream);
|
||||
fileStream.Close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file in hexadecimal and as a byte array.</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string File(string filename, out byte[] hash)
|
||||
{
|
||||
var localMd5Provider = MD5.Create();
|
||||
var fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = localMd5Provider.ComputeHash(fileStream);
|
||||
var md5Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
md5Output.Append(h.ToString("x2"));
|
||||
|
||||
fileStream.Close();
|
||||
|
||||
return md5Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||
{
|
||||
var localMd5Provider = MD5.Create();
|
||||
hash = localMd5Provider.ComputeHash(data, 0, (int)len);
|
||||
var md5Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
md5Output.Append(h.ToString("x2"));
|
||||
|
||||
return md5Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
|
||||
}
|
||||
}
|
||||
@@ -1,730 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ReedSolomon.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Calculates a Reed-Solomon.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// Copyright (C) 1996 Phil Karn
|
||||
// Copyright (C) 1995 Robert Morelos-Zaragoza
|
||||
// Copyright (C) 1995 Hari Thirumoorthy
|
||||
// ****************************************************************************/
|
||||
|
||||
/*
|
||||
* Reed-Solomon coding and decoding
|
||||
* Phil Karn (karn at ka9q.ampr.org) September 1996
|
||||
*
|
||||
* This file is derived from the program "new_rs_erasures.c" by Robert
|
||||
* Morelos-Zaragoza (robert at spectra.eng.hawaii.edu) and Hari Thirumoorthy
|
||||
* (harit at spectra.eng.hawaii.edu), Aug 1995
|
||||
*
|
||||
* I've made changes to improve performance, clean up the code and make it
|
||||
* easier to follow. Data is now passed to the encoding and decoding functions
|
||||
* through arguments rather than in global arrays. The decode function returns
|
||||
* the number of corrected symbols, or -1 if the word is uncorrectable.
|
||||
*
|
||||
* This code supports a symbol size from 2 bits up to 16 bits,
|
||||
* implying a block size of 3 2-bit symbols (6 bits) up to 65535
|
||||
* 16-bit symbols (1,048,560 bits). The code parameters are set in rs.h.
|
||||
*
|
||||
* Note that if symbols larger than 8 bits are used, the type of each
|
||||
* data array element switches from unsigned char to unsigned int. The
|
||||
* caller must ensure that elements larger than the symbol range are
|
||||
* not passed to the encoder or decoder.
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <summary>Implements the Reed-Solomon algorithm</summary>
|
||||
public class ReedSolomon
|
||||
{
|
||||
/// <summary>Alpha exponent for the first root of the generator polynomial</summary>
|
||||
const int B0 = 1;
|
||||
/// <summary>No legal value in index form represents zero, so we need a special value for this purpose</summary>
|
||||
int _a0;
|
||||
/// <summary>index->polynomial form conversion table</summary>
|
||||
int[] _alphaTo;
|
||||
/// <summary>Generator polynomial g(x) Degree of g(x) = 2*TT has roots @**B0, @**(B0+1), ... ,@^(B0+2*TT-1)</summary>
|
||||
int[] _gg;
|
||||
/// <summary>Polynomial->index form conversion table</summary>
|
||||
int[] _indexOf;
|
||||
bool _initialized;
|
||||
int _mm, _kk, _nn;
|
||||
/// <summary>
|
||||
/// Primitive polynomials - see Lin & Costello, Error Control Coding Appendix A, and Lee & Messerschmitt, Digital
|
||||
/// Communication p. 453.
|
||||
/// </summary>
|
||||
int[] _pp;
|
||||
|
||||
/// <summary>Initializes the Reed-Solomon with RS(n,k) with GF(2^m)</summary>
|
||||
public void InitRs(int n, int k, int m)
|
||||
{
|
||||
switch(m)
|
||||
{
|
||||
case 2:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 1, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 3:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 1, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 4:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 1, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 5:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 0, 1, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 6:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 1, 0, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 7:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 0, 0, 1, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 8:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 0, 1, 1, 1, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 9:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 0, 0, 0, 1, 0, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 10:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 11:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 12:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 13:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 14:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 15:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
case 16:
|
||||
_pp = new[]
|
||||
{
|
||||
1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
break;
|
||||
default: throw new ArgumentOutOfRangeException(nameof(m), "m must be between 2 and 16 inclusive");
|
||||
}
|
||||
|
||||
_mm = m;
|
||||
_kk = k;
|
||||
_nn = n;
|
||||
_a0 = n;
|
||||
_alphaTo = new int[n + 1];
|
||||
_indexOf = new int[n + 1];
|
||||
|
||||
_gg = new int[_nn - _kk + 1];
|
||||
|
||||
generate_gf();
|
||||
gen_poly();
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
int Modnn(int x)
|
||||
{
|
||||
while(x >= _nn)
|
||||
{
|
||||
x -= _nn;
|
||||
x = (x >> _mm) + (x & _nn);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
static int Min(int a, int b) => a < b ? a : b;
|
||||
|
||||
static void Clear(ref int[] a, int n)
|
||||
{
|
||||
int ci;
|
||||
|
||||
for(ci = n - 1; ci >= 0; ci--)
|
||||
a[ci] = 0;
|
||||
}
|
||||
|
||||
static void Copy(ref int[] a, ref int[] b, int n)
|
||||
{
|
||||
int ci;
|
||||
|
||||
for(ci = n - 1; ci >= 0; ci--)
|
||||
a[ci] = b[ci];
|
||||
}
|
||||
|
||||
static void Copydown(ref int[] a, ref int[] b, int n)
|
||||
{
|
||||
int ci;
|
||||
|
||||
for(ci = n - 1; ci >= 0; ci--)
|
||||
a[ci] = b[ci];
|
||||
}
|
||||
|
||||
/* generate GF(2**m) from the irreducible polynomial p(X) in p[0]..p[m]
|
||||
lookup tables: index->polynomial form alpha_to[] contains j=alpha**i;
|
||||
polynomial form -> index form index_of[j=alpha**i] = i
|
||||
alpha=2 is the primitive element of GF(2**m)
|
||||
HARI's COMMENT: (4/13/94) alpha_to[] can be used as follows:
|
||||
Let @ represent the primitive element commonly called "alpha" that
|
||||
is the root of the primitive polynomial p(x). Then in GF(2^m), for any
|
||||
0 <= i <= 2^m-2,
|
||||
@^i = a(0) + a(1) @ + a(2) @^2 + ... + a(m-1) @^(m-1)
|
||||
where the binary vector (a(0),a(1),a(2),...,a(m-1)) is the representation
|
||||
of the integer "alpha_to[i]" with a(0) being the LSB and a(m-1) the MSB. Thus for
|
||||
example the polynomial representation of @^5 would be given by the binary
|
||||
representation of the integer "alpha_to[5]".
|
||||
Similarily, index_of[] can be used as follows:
|
||||
As above, let @ represent the primitive element of GF(2^m) that is
|
||||
the root of the primitive polynomial p(x). In order to find the power
|
||||
of @ (alpha) that has the polynomial representation
|
||||
a(0) + a(1) @ + a(2) @^2 + ... + a(m-1) @^(m-1)
|
||||
we consider the integer "i" whose binary representation with a(0) being LSB
|
||||
and a(m-1) MSB is (a(0),a(1),...,a(m-1)) and locate the entry
|
||||
"index_of[i]". Now, @^index_of[i] is that element whose polynomial
|
||||
representation is (a(0),a(1),a(2),...,a(m-1)).
|
||||
NOTE:
|
||||
The element alpha_to[2^m-1] = 0 always signifying that the
|
||||
representation of "@^infinity" = 0 is (0,0,0,...,0).
|
||||
Similarily, the element index_of[0] = A0 always signifying
|
||||
that the power of alpha which has the polynomial representation
|
||||
(0,0,...,0) is "infinity".
|
||||
|
||||
*/
|
||||
void generate_gf()
|
||||
{
|
||||
int i;
|
||||
|
||||
int mask = 1;
|
||||
_alphaTo[_mm] = 0;
|
||||
|
||||
for(i = 0; i < _mm; i++)
|
||||
{
|
||||
_alphaTo[i] = mask;
|
||||
_indexOf[_alphaTo[i]] = i;
|
||||
|
||||
/* If Pp[i] == 1 then, term @^i occurs in poly-repr of @^MM */
|
||||
if(_pp[i] != 0)
|
||||
_alphaTo[_mm] ^= mask; /* Bit-wise EXOR operation */
|
||||
|
||||
mask <<= 1; /* single left-shift */
|
||||
}
|
||||
|
||||
_indexOf[_alphaTo[_mm]] = _mm;
|
||||
/*
|
||||
* Have obtained poly-repr of @^MM. Poly-repr of @^(i+1) is given by
|
||||
* poly-repr of @^i shifted left one-bit and accounting for any @^MM
|
||||
* term that may occur when poly-repr of @^i is shifted.
|
||||
*/
|
||||
mask >>= 1;
|
||||
|
||||
for(i = _mm + 1; i < _nn; i++)
|
||||
{
|
||||
if(_alphaTo[i - 1] >= mask)
|
||||
_alphaTo[i] = _alphaTo[_mm] ^ ((_alphaTo[i - 1] ^ mask) << 1);
|
||||
else
|
||||
_alphaTo[i] = _alphaTo[i - 1] << 1;
|
||||
|
||||
_indexOf[_alphaTo[i]] = i;
|
||||
}
|
||||
|
||||
_indexOf[0] = _a0;
|
||||
_alphaTo[_nn] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Obtain the generator polynomial of the TT-error correcting, length
|
||||
* NN=(2**MM -1) Reed Solomon code from the product of (X+@**(B0+i)), i = 0,
|
||||
* ... ,(2*TT-1)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* If B0 = 1, TT = 1. deg(g(x)) = 2*TT = 2.
|
||||
* g(x) = (x+@) (x+@**2)
|
||||
*
|
||||
* If B0 = 0, TT = 2. deg(g(x)) = 2*TT = 4.
|
||||
* g(x) = (x+1) (x+@) (x+@**2) (x+@**3)
|
||||
*/
|
||||
void gen_poly()
|
||||
{
|
||||
int i;
|
||||
|
||||
_gg[0] = _alphaTo[B0];
|
||||
_gg[1] = 1; /* g(x) = (X+@**B0) initially */
|
||||
|
||||
for(i = 2; i <= _nn - _kk; i++)
|
||||
{
|
||||
_gg[i] = 1;
|
||||
|
||||
/*
|
||||
* Below multiply (Gg[0]+Gg[1]*x + ... +Gg[i]x^i) by
|
||||
* (@**(B0+i-1) + x)
|
||||
*/
|
||||
for(int j = i - 1; j > 0; j--)
|
||||
if(_gg[j] != 0)
|
||||
_gg[j] = _gg[j - 1] ^ _alphaTo[Modnn(_indexOf[_gg[j]] + B0 + i - 1)];
|
||||
else
|
||||
_gg[j] = _gg[j - 1];
|
||||
|
||||
/* Gg[0] can never be zero */
|
||||
_gg[0] = _alphaTo[Modnn(_indexOf[_gg[0]] + B0 + i - 1)];
|
||||
}
|
||||
|
||||
/* convert Gg[] to index form for quicker encoding */
|
||||
for(i = 0; i <= _nn - _kk; i++)
|
||||
_gg[i] = _indexOf[_gg[i]];
|
||||
}
|
||||
|
||||
/*
|
||||
* take the string of symbols in data[i], i=0..(k-1) and encode
|
||||
* systematically to produce NN-KK parity symbols in bb[0]..bb[NN-KK-1] data[]
|
||||
* is input and bb[] is output in polynomial form. Encoding is done by using
|
||||
* a feedback shift register with appropriate connections specified by the
|
||||
* elements of Gg[], which was generated above. Codeword is c(X) =
|
||||
* data(X)*X**(NN-KK)+ b(X)
|
||||
*/
|
||||
/// <summary>Takes the symbols in data to output parity in bb.</summary>
|
||||
/// <returns>Returns -1 if an illegal symbol is found.</returns>
|
||||
/// <param name="data">Data symbols.</param>
|
||||
/// <param name="bb">Outs parity symbols.</param>
|
||||
public int encode_rs(int[] data, out int[] bb)
|
||||
{
|
||||
if(!_initialized)
|
||||
throw new UnauthorizedAccessException("Trying to calculate RS without initializing!");
|
||||
|
||||
int i;
|
||||
bb = new int[_nn - _kk];
|
||||
|
||||
Clear(ref bb, _nn - _kk);
|
||||
|
||||
for(i = _kk - 1; i >= 0; i--)
|
||||
{
|
||||
if(_mm != 8)
|
||||
if(data[i] > _nn)
|
||||
return -1; /* Illegal symbol */
|
||||
|
||||
int feedback = _indexOf[data[i] ^ bb[_nn - _kk - 1]];
|
||||
|
||||
if(feedback != _a0)
|
||||
{
|
||||
/* feedback term is non-zero */
|
||||
for(int j = _nn - _kk - 1; j > 0; j--)
|
||||
if(_gg[j] != _a0)
|
||||
bb[j] = bb[j - 1] ^ _alphaTo[Modnn(_gg[j] + feedback)];
|
||||
else
|
||||
bb[j] = bb[j - 1];
|
||||
|
||||
bb[0] = _alphaTo[Modnn(_gg[0] + feedback)];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* feedback term is zero. encoder becomes a
|
||||
* single-byte shifter */
|
||||
for(int j = _nn - _kk - 1; j > 0; j--)
|
||||
bb[j] = bb[j - 1];
|
||||
|
||||
bb[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Performs ERRORS+ERASURES decoding of RS codes. If decoding is successful,
|
||||
* writes the codeword into data[] itself. Otherwise data[] is unaltered.
|
||||
*
|
||||
* Return number of symbols corrected, or -1 if codeword is illegal
|
||||
* or uncorrectable.
|
||||
*
|
||||
* First "no_eras" erasures are declared by the calling program. Then, the
|
||||
* maximum # of errors correctable is t_after_eras = floor((NN-KK-no_eras)/2).
|
||||
* If the number of channel errors is not greater than "t_after_eras" the
|
||||
* transmitted codeword will be recovered. Details of algorithm can be found
|
||||
* in R. Blahut's "Theory ... of Error-Correcting Codes".
|
||||
*/
|
||||
/// <summary>Decodes the RS. If decoding is successful outputs corrected data symbols.</summary>
|
||||
/// <returns>Returns corrected symbols, -1 if illegal or uncorrectable</returns>
|
||||
/// <param name="data">Data symbols.</param>
|
||||
/// <param name="erasPos">Position of erasures.</param>
|
||||
/// <param name="noEras">Number of erasures.</param>
|
||||
public int eras_dec_rs(ref int[] data, out int[] erasPos, int noEras)
|
||||
{
|
||||
if(!_initialized)
|
||||
throw new UnauthorizedAccessException("Trying to calculate RS without initializing!");
|
||||
|
||||
erasPos = new int[_nn - _kk];
|
||||
int i, j;
|
||||
int q, tmp;
|
||||
int[] recd = new int[_nn];
|
||||
int[] lambda = new int[_nn - _kk + 1]; /* Err+Eras Locator poly */
|
||||
int[] s = new int[_nn - _kk + 1]; /* syndrome poly */
|
||||
int[] b = new int[_nn - _kk + 1];
|
||||
int[] t = new int[_nn - _kk + 1];
|
||||
int[] omega = new int[_nn - _kk + 1];
|
||||
int[] root = new int[_nn - _kk];
|
||||
int[] reg = new int[_nn - _kk + 1];
|
||||
int[] loc = new int[_nn - _kk];
|
||||
int count;
|
||||
|
||||
/* data[] is in polynomial form, copy and convert to index form */
|
||||
for(i = _nn - 1; i >= 0; i--)
|
||||
{
|
||||
if(_mm != 8)
|
||||
if(data[i] > _nn)
|
||||
return -1; /* Illegal symbol */
|
||||
|
||||
recd[i] = _indexOf[data[i]];
|
||||
}
|
||||
|
||||
/* first form the syndromes; i.e., evaluate recd(x) at roots of g(x)
|
||||
* namely @**(B0+i), i = 0, ... ,(NN-KK-1)
|
||||
*/
|
||||
int synError = 0;
|
||||
|
||||
for(i = 1; i <= _nn - _kk; i++)
|
||||
{
|
||||
tmp = 0;
|
||||
|
||||
for(j = 0; j < _nn; j++)
|
||||
if(recd[j] != _a0) /* recd[j] in index form */
|
||||
tmp ^= _alphaTo[Modnn(recd[j] + ((B0 + i - 1) * j))];
|
||||
|
||||
synError |= tmp; /* set flag if non-zero syndrome =>
|
||||
* error */
|
||||
|
||||
/* store syndrome in index form */
|
||||
s[i] = _indexOf[tmp];
|
||||
}
|
||||
|
||||
if(synError == 0)
|
||||
return 0;
|
||||
|
||||
Clear(ref lambda, _nn - _kk);
|
||||
lambda[0] = 1;
|
||||
|
||||
if(noEras > 0)
|
||||
{
|
||||
/* Init lambda to be the erasure locator polynomial */
|
||||
lambda[1] = _alphaTo[erasPos[0]];
|
||||
|
||||
for(i = 1; i < noEras; i++)
|
||||
{
|
||||
int u = erasPos[i];
|
||||
|
||||
for(j = i + 1; j > 0; j--)
|
||||
{
|
||||
tmp = _indexOf[lambda[j - 1]];
|
||||
|
||||
if(tmp != _a0)
|
||||
lambda[j] ^= _alphaTo[Modnn(u + tmp)];
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
/* find roots of the erasure location polynomial */
|
||||
for(i = 1; i <= noEras; i++)
|
||||
reg[i] = _indexOf[lambda[i]];
|
||||
|
||||
count = 0;
|
||||
|
||||
for(i = 1; i <= _nn; i++)
|
||||
{
|
||||
q = 1;
|
||||
|
||||
for(j = 1; j <= noEras; j++)
|
||||
if(reg[j] != _a0)
|
||||
{
|
||||
reg[j] = Modnn(reg[j] + j);
|
||||
q ^= _alphaTo[reg[j]];
|
||||
}
|
||||
|
||||
if(q != 0)
|
||||
continue;
|
||||
|
||||
/* store root and error location
|
||||
* number indices
|
||||
*/
|
||||
root[count] = i;
|
||||
loc[count] = _nn - i;
|
||||
count++;
|
||||
}
|
||||
|
||||
if(count != noEras)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Reed Solomon", "\n lambda(x) is WRONG\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("Reed Solomon",
|
||||
"\n Erasure positions as determined by roots of Eras Loc Poly:\n");
|
||||
|
||||
for(i = 0; i < count; i++)
|
||||
AaruConsole.DebugWriteLine("Reed Solomon", "{0} ", loc[i]);
|
||||
|
||||
AaruConsole.DebugWriteLine("Reed Solomon", "\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
for(i = 0; i < _nn - _kk + 1; i++)
|
||||
b[i] = _indexOf[lambda[i]];
|
||||
|
||||
/*
|
||||
* Begin Berlekamp-Massey algorithm to determine error+erasure
|
||||
* locator polynomial
|
||||
*/
|
||||
int r = noEras;
|
||||
int el = noEras;
|
||||
|
||||
while(++r <= _nn - _kk)
|
||||
{
|
||||
/* r is the step number */
|
||||
/* Compute discrepancy at the r-th step in poly-form */
|
||||
int discrR = 0;
|
||||
|
||||
for(i = 0; i < r; i++)
|
||||
if(lambda[i] != 0 &&
|
||||
s[r - i] != _a0)
|
||||
discrR ^= _alphaTo[Modnn(_indexOf[lambda[i]] + s[r - i])];
|
||||
|
||||
discrR = _indexOf[discrR]; /* Index form */
|
||||
|
||||
if(discrR == _a0)
|
||||
{
|
||||
/* 2 lines below: B(x) <-- x*B(x) */
|
||||
Copydown(ref b, ref b, _nn - _kk);
|
||||
b[0] = _a0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */
|
||||
t[0] = lambda[0];
|
||||
|
||||
for(i = 0; i < _nn - _kk; i++)
|
||||
if(b[i] != _a0)
|
||||
t[i + 1] = lambda[i + 1] ^ _alphaTo[Modnn(discrR + b[i])];
|
||||
else
|
||||
t[i + 1] = lambda[i + 1];
|
||||
|
||||
if(2 * el <= r + noEras - 1)
|
||||
{
|
||||
el = r + noEras - el;
|
||||
|
||||
/*
|
||||
* 2 lines below: B(x) <-- inv(discr_r) *
|
||||
* lambda(x)
|
||||
*/
|
||||
for(i = 0; i <= _nn - _kk; i++)
|
||||
b[i] = lambda[i] == 0 ? _a0 : Modnn(_indexOf[lambda[i]] - discrR + _nn);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 2 lines below: B(x) <-- x*B(x) */
|
||||
Copydown(ref b, ref b, _nn - _kk);
|
||||
b[0] = _a0;
|
||||
}
|
||||
|
||||
Copy(ref lambda, ref t, _nn - _kk + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert lambda to index form and compute deg(lambda(x)) */
|
||||
int degLambda = 0;
|
||||
|
||||
for(i = 0; i < _nn - _kk + 1; i++)
|
||||
{
|
||||
lambda[i] = _indexOf[lambda[i]];
|
||||
|
||||
if(lambda[i] != _a0)
|
||||
degLambda = i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find roots of the error+erasure locator polynomial. By Chien
|
||||
* Search
|
||||
*/
|
||||
int temp = reg[0];
|
||||
Copy(ref reg, ref lambda, _nn - _kk);
|
||||
reg[0] = temp;
|
||||
count = 0; /* Number of roots of lambda(x) */
|
||||
|
||||
for(i = 1; i <= _nn; i++)
|
||||
{
|
||||
q = 1;
|
||||
|
||||
for(j = degLambda; j > 0; j--)
|
||||
if(reg[j] != _a0)
|
||||
{
|
||||
reg[j] = Modnn(reg[j] + j);
|
||||
q ^= _alphaTo[reg[j]];
|
||||
}
|
||||
|
||||
if(q != 0)
|
||||
continue;
|
||||
|
||||
/* store root (index-form) and error location number */
|
||||
root[count] = i;
|
||||
loc[count] = _nn - i;
|
||||
count++;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
AaruConsole.DebugWriteLine("Reed Solomon", "\n Final error positions:\t");
|
||||
|
||||
for(i = 0; i < count; i++)
|
||||
AaruConsole.DebugWriteLine("Reed Solomon", "{0} ", loc[i]);
|
||||
|
||||
AaruConsole.DebugWriteLine("Reed Solomon", "\n");
|
||||
#endif
|
||||
|
||||
if(degLambda != count)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
|
||||
* x**(NN-KK)). in index form. Also find deg(omega).
|
||||
*/
|
||||
int degOmega = 0;
|
||||
|
||||
for(i = 0; i < _nn - _kk; i++)
|
||||
{
|
||||
tmp = 0;
|
||||
j = degLambda < i ? degLambda : i;
|
||||
|
||||
for(; j >= 0; j--)
|
||||
if(s[i + 1 - j] != _a0 &&
|
||||
lambda[j] != _a0)
|
||||
tmp ^= _alphaTo[Modnn(s[i + 1 - j] + lambda[j])];
|
||||
|
||||
if(tmp != 0)
|
||||
degOmega = i;
|
||||
|
||||
omega[i] = _indexOf[tmp];
|
||||
}
|
||||
|
||||
omega[_nn - _kk] = _a0;
|
||||
|
||||
/*
|
||||
* Compute error values in poly-form. num1 = omega(inv(X(l))), num2 =
|
||||
* inv(X(l))**(B0-1) and den = lambda_pr(inv(X(l))) all in poly-form
|
||||
*/
|
||||
for(j = count - 1; j >= 0; j--)
|
||||
{
|
||||
int num1 = 0;
|
||||
|
||||
for(i = degOmega; i >= 0; i--)
|
||||
if(omega[i] != _a0)
|
||||
num1 ^= _alphaTo[Modnn(omega[i] + (i * root[j]))];
|
||||
|
||||
int num2 = _alphaTo[Modnn((root[j] * (B0 - 1)) + _nn)];
|
||||
int den = 0;
|
||||
|
||||
/* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
|
||||
for(i = Min(degLambda, _nn - _kk - 1) & ~1; i >= 0; i -= 2)
|
||||
if(lambda[i + 1] != _a0)
|
||||
den ^= _alphaTo[Modnn(lambda[i + 1] + (i * root[j]))];
|
||||
|
||||
if(den == 0)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Reed Solomon", "\n ERROR: denominator = 0\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Apply error to data */
|
||||
if(num1 != 0)
|
||||
data[loc[j]] ^= _alphaTo[Modnn(_indexOf[num1] + _indexOf[num2] + _nn - _indexOf[den])];
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Register.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Core algorithms.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Registers all plugins in this assembly.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public sealed class Register : IPluginRegister
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllChecksumPlugins() => Assembly.GetExecutingAssembly().GetTypes().
|
||||
Where(t => t.GetInterfaces().Contains(typeof(IChecksum))).
|
||||
Where(t => t.IsClass).ToList();
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllFilesystemPlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllFilterPlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllFloppyImagePlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllMediaImagePlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllPartitionPlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllReadOnlyFilesystemPlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllWritableFloppyImagePlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllWritableImagePlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllArchivePlugins() => null;
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : SHA1Context.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Wraps up .NET SHA1 implementation to a Init(), Update(), Final() context.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Wraps up .NET SHA1 implementation to a Init(), Update(), Final() context.</summary>
|
||||
public sealed class Sha1Context : IChecksum
|
||||
{
|
||||
readonly SHA1 _provider;
|
||||
|
||||
/// <summary>Initializes the SHA1 hash provider</summary>
|
||||
public Sha1Context() => _provider = SHA1.Create();
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of buffer to hash.</param>
|
||||
public void Update(byte[] data, uint len) => _provider.TransformBlock(data, 0, (int)len, data, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
public void Update(byte[] data) => Update(data, (uint)data.Length);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a byte array of the hash value.</summary>
|
||||
public byte[] Final()
|
||||
{
|
||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||
|
||||
return _provider.Hash;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a hexadecimal representation of the hash value.</summary>
|
||||
public string End()
|
||||
{
|
||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||
var sha1Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in _provider.Hash)
|
||||
sha1Output.Append(h.ToString("x2"));
|
||||
|
||||
return sha1Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
var localSha1Provider = SHA1.Create();
|
||||
var fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = localSha1Provider.ComputeHash(fileStream);
|
||||
fileStream.Close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file in hexadecimal and as a byte array.</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string File(string filename, out byte[] hash)
|
||||
{
|
||||
var localSha1Provider = SHA1.Create();
|
||||
var fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = localSha1Provider.ComputeHash(fileStream);
|
||||
var sha1Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
sha1Output.Append(h.ToString("x2"));
|
||||
|
||||
fileStream.Close();
|
||||
|
||||
return sha1Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||
{
|
||||
var localSha1Provider = SHA1.Create();
|
||||
hash = localSha1Provider.ComputeHash(data, 0, (int)len);
|
||||
var sha1Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
sha1Output.Append(h.ToString("x2"));
|
||||
|
||||
return sha1Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : SHA256Context.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Wraps up .NET SHA256 implementation to a Init(), Update(), Final() context.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Wraps up .NET SHA256 implementation to a Init(), Update(), Final() context.</summary>
|
||||
public sealed class Sha256Context : IChecksum
|
||||
{
|
||||
readonly SHA256 _provider;
|
||||
|
||||
/// <summary>Initializes the SHA256 hash provider</summary>
|
||||
public Sha256Context() => _provider = SHA256.Create();
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of buffer to hash.</param>
|
||||
public void Update(byte[] data, uint len) => _provider.TransformBlock(data, 0, (int)len, data, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
public void Update(byte[] data) => Update(data, (uint)data.Length);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a byte array of the hash value.</summary>
|
||||
public byte[] Final()
|
||||
{
|
||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||
|
||||
return _provider.Hash;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a hexadecimal representation of the hash value.</summary>
|
||||
public string End()
|
||||
{
|
||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||
var sha256Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in _provider.Hash)
|
||||
sha256Output.Append(h.ToString("x2"));
|
||||
|
||||
return sha256Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
var localSha256Provider = SHA256.Create();
|
||||
var fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = localSha256Provider.ComputeHash(fileStream);
|
||||
fileStream.Close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file in hexadecimal and as a byte array.</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string File(string filename, out byte[] hash)
|
||||
{
|
||||
var localSha256Provider = SHA256.Create();
|
||||
var fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = localSha256Provider.ComputeHash(fileStream);
|
||||
var sha256Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
sha256Output.Append(h.ToString("x2"));
|
||||
|
||||
fileStream.Close();
|
||||
|
||||
return sha256Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||
{
|
||||
var localSha256Provider = SHA256.Create();
|
||||
hash = localSha256Provider.ComputeHash(data, 0, (int)len);
|
||||
var sha256Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
sha256Output.Append(h.ToString("x2"));
|
||||
|
||||
return sha256Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : SHA384Context.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Wraps up .NET SHA384 implementation to a Init(), Update(), Final() context.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Wraps up .NET SHA384 implementation to a Init(), Update(), Final() context.</summary>
|
||||
public sealed class Sha384Context : IChecksum
|
||||
{
|
||||
readonly SHA384 _provider;
|
||||
|
||||
/// <summary>Initializes the SHA384 hash provider</summary>
|
||||
public Sha384Context() => _provider = SHA384.Create();
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of buffer to hash.</param>
|
||||
public void Update(byte[] data, uint len) => _provider.TransformBlock(data, 0, (int)len, data, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
public void Update(byte[] data) => Update(data, (uint)data.Length);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a byte array of the hash value.</summary>
|
||||
public byte[] Final()
|
||||
{
|
||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||
|
||||
return _provider.Hash;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a hexadecimal representation of the hash value.</summary>
|
||||
public string End()
|
||||
{
|
||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||
var sha384Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in _provider.Hash)
|
||||
sha384Output.Append(h.ToString("x2"));
|
||||
|
||||
return sha384Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
var localSha384Provider = SHA384.Create();
|
||||
var fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = localSha384Provider.ComputeHash(fileStream);
|
||||
fileStream.Close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file in hexadecimal and as a byte array.</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string File(string filename, out byte[] hash)
|
||||
{
|
||||
var localSha384Provider = SHA384.Create();
|
||||
var fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = localSha384Provider.ComputeHash(fileStream);
|
||||
var sha384Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
sha384Output.Append(h.ToString("x2"));
|
||||
|
||||
fileStream.Close();
|
||||
|
||||
return sha384Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||
{
|
||||
var localSha384Provider = SHA384.Create();
|
||||
hash = localSha384Provider.ComputeHash(data, 0, (int)len);
|
||||
var sha384Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
sha384Output.Append(h.ToString("x2"));
|
||||
|
||||
return sha384Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : SHA512Context.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Wraps up .NET SHA512 implementation to a Init(), Update(), Final() context.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Wraps up .NET SHA512 implementation to a Init(), Update(), Final() context.</summary>
|
||||
public sealed class Sha512Context : IChecksum
|
||||
{
|
||||
readonly SHA512 _provider;
|
||||
|
||||
/// <summary>Initializes the SHA512 hash provider</summary>
|
||||
public Sha512Context() => _provider = SHA512.Create();
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of buffer to hash.</param>
|
||||
public void Update(byte[] data, uint len) => _provider.TransformBlock(data, 0, (int)len, data, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
public void Update(byte[] data) => Update(data, (uint)data.Length);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a byte array of the hash value.</summary>
|
||||
public byte[] Final()
|
||||
{
|
||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||
|
||||
return _provider.Hash;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a hexadecimal representation of the hash value.</summary>
|
||||
public string End()
|
||||
{
|
||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||
var sha512Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in _provider.Hash)
|
||||
sha512Output.Append(h.ToString("x2"));
|
||||
|
||||
return sha512Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
var localSha512Provider = SHA512.Create();
|
||||
var fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = localSha512Provider.ComputeHash(fileStream);
|
||||
fileStream.Close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file in hexadecimal and as a byte array.</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string File(string filename, out byte[] hash)
|
||||
{
|
||||
var localSha512Provider = SHA512.Create();
|
||||
var fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = localSha512Provider.ComputeHash(fileStream);
|
||||
var sha512Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
sha512Output.Append(h.ToString("x2"));
|
||||
|
||||
fileStream.Close();
|
||||
|
||||
return sha512Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||
{
|
||||
var localSha512Provider = SHA512.Create();
|
||||
hash = localSha512Provider.ComputeHash(data, 0, (int)len);
|
||||
var sha512Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash)
|
||||
sha512Output.Append(h.ToString("x2"));
|
||||
|
||||
return sha512Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
|
||||
}
|
||||
}
|
||||
@@ -1,527 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : SpamSumContext.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Implements the SpamSum fuzzy hashing algorithm.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
// Based on ssdeep
|
||||
// Copyright (C) 2002 Andrew Tridgell <tridge@samba.org>
|
||||
// Copyright (C) 2006 ManTech International Corporation
|
||||
// Copyright (C) 2013 Helmut Grohne <helmut@subdivi.de>
|
||||
//
|
||||
// Earlier versions of this code were named fuzzy.c and can be found at:
|
||||
// http://www.samba.org/ftp/unpacked/junkcode/spamsum/
|
||||
// http://ssdeep.sf.net/
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements the SpamSum fuzzy hashing algorithm.</summary>
|
||||
public sealed class SpamSumContext : IChecksum
|
||||
{
|
||||
const uint ROLLING_WINDOW = 7;
|
||||
const uint MIN_BLOCKSIZE = 3;
|
||||
const uint HASH_PRIME = 0x01000193;
|
||||
const uint HASH_INIT = 0x28021967;
|
||||
const uint NUM_BLOCKHASHES = 31;
|
||||
const uint SPAMSUM_LENGTH = 64;
|
||||
const uint FUZZY_MAX_RESULT = (2 * SPAMSUM_LENGTH) + 20;
|
||||
|
||||
//"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
readonly byte[] _b64 =
|
||||
{
|
||||
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
|
||||
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A,
|
||||
0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31,
|
||||
0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F
|
||||
};
|
||||
|
||||
FuzzyState _self;
|
||||
|
||||
/// <summary>Initializes the SpamSum structures</summary>
|
||||
public SpamSumContext()
|
||||
{
|
||||
_self = new FuzzyState
|
||||
{
|
||||
Bh = new BlockhashContext[NUM_BLOCKHASHES]
|
||||
};
|
||||
|
||||
for(int i = 0; i < NUM_BLOCKHASHES; i++)
|
||||
_self.Bh[i].Digest = new byte[SPAMSUM_LENGTH];
|
||||
|
||||
_self.Bhstart = 0;
|
||||
_self.Bhend = 1;
|
||||
_self.Bh[0].H = HASH_INIT;
|
||||
_self.Bh[0].Halfh = HASH_INIT;
|
||||
_self.Bh[0].Digest[0] = 0;
|
||||
_self.Bh[0].Halfdigest = 0;
|
||||
_self.Bh[0].Dlen = 0;
|
||||
_self.TotalSize = 0;
|
||||
roll_init();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of buffer to hash.</param>
|
||||
public void Update(byte[] data, uint len)
|
||||
{
|
||||
_self.TotalSize += len;
|
||||
|
||||
for(int i = 0; i < len; i++)
|
||||
fuzzy_engine_step(data[i]);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
public void Update(byte[] data) => Update(data, (uint)data.Length);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a byte array of the hash value.</summary>
|
||||
public byte[] Final() => throw new NotImplementedException("SpamSum does not have a binary representation.");
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Returns a base64 representation of the hash value.</summary>
|
||||
public string End()
|
||||
{
|
||||
FuzzyDigest(out byte[] result);
|
||||
|
||||
return CToString(result);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void roll_init() => _self.Roll = new RollState
|
||||
{
|
||||
Window = new byte[ROLLING_WINDOW]
|
||||
};
|
||||
|
||||
/*
|
||||
* a rolling hash, based on the Adler checksum. By using a rolling hash
|
||||
* we can perform auto resynchronisation after inserts/deletes
|
||||
|
||||
* internally, h1 is the sum of the bytes in the window and h2
|
||||
* is the sum of the bytes times the index
|
||||
|
||||
* h3 is a shift/xor based rolling hash, and is mostly needed to ensure that
|
||||
* we can cope with large blocksize values
|
||||
*/
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void roll_hash(byte c)
|
||||
{
|
||||
_self.Roll.H2 -= _self.Roll.H1;
|
||||
_self.Roll.H2 += ROLLING_WINDOW * c;
|
||||
|
||||
_self.Roll.H1 += c;
|
||||
_self.Roll.H1 -= _self.Roll.Window[_self.Roll.N % ROLLING_WINDOW];
|
||||
|
||||
_self.Roll.Window[_self.Roll.N % ROLLING_WINDOW] = c;
|
||||
_self.Roll.N++;
|
||||
|
||||
/* The original spamsum AND'ed this value with 0xFFFFFFFF which
|
||||
* in theory should have no effect. This AND has been removed
|
||||
* for performance (jk) */
|
||||
_self.Roll.H3 <<= 5;
|
||||
_self.Roll.H3 ^= c;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
uint roll_sum() => _self.Roll.H1 + _self.Roll.H2 + _self.Roll.H3;
|
||||
|
||||
/* A simple non-rolling hash, based on the FNV hash. */
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static uint sum_hash(byte c, uint h) => (h * HASH_PRIME) ^ c;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static uint SSDEEP_BS(uint index) => MIN_BLOCKSIZE << (int)index;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void fuzzy_try_fork_blockhash()
|
||||
{
|
||||
if(_self.Bhend >= NUM_BLOCKHASHES)
|
||||
return;
|
||||
|
||||
if(_self.Bhend == 0) // assert
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
uint obh = _self.Bhend - 1;
|
||||
uint nbh = _self.Bhend;
|
||||
_self.Bh[nbh].H = _self.Bh[obh].H;
|
||||
_self.Bh[nbh].Halfh = _self.Bh[obh].Halfh;
|
||||
_self.Bh[nbh].Digest[0] = 0;
|
||||
_self.Bh[nbh].Halfdigest = 0;
|
||||
_self.Bh[nbh].Dlen = 0;
|
||||
++_self.Bhend;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void fuzzy_try_reduce_blockhash()
|
||||
{
|
||||
if(_self.Bhstart >= _self.Bhend)
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
if(_self.Bhend - _self.Bhstart < 2)
|
||||
/* Need at least two working hashes. */
|
||||
return;
|
||||
|
||||
if((ulong)SSDEEP_BS(_self.Bhstart) * SPAMSUM_LENGTH >= _self.TotalSize)
|
||||
/* Initial blocksize estimate would select this or a smaller
|
||||
* blocksize. */
|
||||
return;
|
||||
|
||||
if(_self.Bh[_self.Bhstart + 1].Dlen < SPAMSUM_LENGTH / 2)
|
||||
/* Estimate adjustment would select this blocksize. */
|
||||
return;
|
||||
|
||||
/* At this point we are clearly no longer interested in the
|
||||
* start_blocksize. Get rid of it. */
|
||||
++_self.Bhstart;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void fuzzy_engine_step(byte c)
|
||||
{
|
||||
uint i;
|
||||
/* At each character we update the rolling hash and the normal hashes.
|
||||
* When the rolling hash hits a reset value then we emit a normal hash
|
||||
* as a element of the signature and reset the normal hash. */
|
||||
roll_hash(c);
|
||||
ulong h = roll_sum();
|
||||
|
||||
for(i = _self.Bhstart; i < _self.Bhend; ++i)
|
||||
{
|
||||
_self.Bh[i].H = sum_hash(c, _self.Bh[i].H);
|
||||
_self.Bh[i].Halfh = sum_hash(c, _self.Bh[i].Halfh);
|
||||
}
|
||||
|
||||
for(i = _self.Bhstart; i < _self.Bhend; ++i)
|
||||
{
|
||||
/* With growing blocksize almost no runs fail the next test. */
|
||||
if(h % SSDEEP_BS(i) != SSDEEP_BS(i) - 1)
|
||||
/* Once this condition is false for one bs, it is
|
||||
* automatically false for all further bs. I.e. if
|
||||
* h === -1 (mod 2*bs) then h === -1 (mod bs). */
|
||||
break;
|
||||
|
||||
/* We have hit a reset point. We now emit hashes which are
|
||||
* based on all characters in the piece of the message between
|
||||
* the last reset point and this one */
|
||||
if(0 == _self.Bh[i].Dlen)
|
||||
fuzzy_try_fork_blockhash();
|
||||
|
||||
_self.Bh[i].Digest[_self.Bh[i].Dlen] = _b64[_self.Bh[i].H % 64];
|
||||
_self.Bh[i].Halfdigest = _b64[_self.Bh[i].Halfh % 64];
|
||||
|
||||
if(_self.Bh[i].Dlen < SPAMSUM_LENGTH - 1)
|
||||
{
|
||||
/* We can have a problem with the tail overflowing. The
|
||||
* easiest way to cope with this is to only reset the
|
||||
* normal hash if we have room for more characters in
|
||||
* our signature. This has the effect of combining the
|
||||
* last few pieces of the message into a single piece
|
||||
* */
|
||||
_self.Bh[i].Digest[++_self.Bh[i].Dlen] = 0;
|
||||
_self.Bh[i].H = HASH_INIT;
|
||||
|
||||
if(_self.Bh[i].Dlen >= SPAMSUM_LENGTH / 2)
|
||||
continue;
|
||||
|
||||
_self.Bh[i].Halfh = HASH_INIT;
|
||||
_self.Bh[i].Halfdigest = 0;
|
||||
}
|
||||
else
|
||||
fuzzy_try_reduce_blockhash();
|
||||
}
|
||||
}
|
||||
|
||||
// CLAUNIA: Flags seems to never be used in ssdeep, so I just removed it for code simplicity
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void FuzzyDigest(out byte[] result)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
uint bi = _self.Bhstart;
|
||||
uint h = roll_sum();
|
||||
int remain = (int)(FUZZY_MAX_RESULT - 1); /* Exclude terminating '\0'. */
|
||||
result = new byte[FUZZY_MAX_RESULT];
|
||||
|
||||
/* Verify that our elimination was not overeager. */
|
||||
if(!(bi == 0 || (ulong)SSDEEP_BS(bi) / 2 * SPAMSUM_LENGTH < _self.TotalSize))
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
int resultOff;
|
||||
|
||||
/* Initial blocksize guess. */
|
||||
while((ulong)SSDEEP_BS(bi) * SPAMSUM_LENGTH < _self.TotalSize)
|
||||
{
|
||||
++bi;
|
||||
|
||||
if(bi >= NUM_BLOCKHASHES)
|
||||
throw new OverflowException("The input exceeds data types.");
|
||||
}
|
||||
|
||||
/* Adapt blocksize guess to actual digest length. */
|
||||
while(bi >= _self.Bhend)
|
||||
--bi;
|
||||
|
||||
while(bi > _self.Bhstart &&
|
||||
_self.Bh[bi].Dlen < SPAMSUM_LENGTH / 2)
|
||||
--bi;
|
||||
|
||||
if(bi > 0 &&
|
||||
_self.Bh[bi].Dlen < SPAMSUM_LENGTH / 2)
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
sb.AppendFormat("{0}:", SSDEEP_BS(bi));
|
||||
int i = Encoding.ASCII.GetBytes(sb.ToString()).Length;
|
||||
|
||||
if(i <= 0)
|
||||
/* Maybe snprintf has set errno here? */
|
||||
throw new OverflowException("The input exceeds data types.");
|
||||
|
||||
if(i >= remain)
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
remain -= i;
|
||||
|
||||
Array.Copy(Encoding.ASCII.GetBytes(sb.ToString()), 0, result, 0, i);
|
||||
|
||||
resultOff = i;
|
||||
|
||||
i = (int)_self.Bh[bi].Dlen;
|
||||
|
||||
if(i > remain)
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
Array.Copy(_self.Bh[bi].Digest, 0, result, resultOff, i);
|
||||
resultOff += i;
|
||||
remain -= i;
|
||||
|
||||
if(h != 0)
|
||||
{
|
||||
if(remain <= 0)
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
result[resultOff] = _b64[_self.Bh[bi].H % 64];
|
||||
|
||||
if(i < 3 ||
|
||||
result[resultOff] != result[resultOff - 1] ||
|
||||
result[resultOff] != result[resultOff - 2] ||
|
||||
result[resultOff] != result[resultOff - 3])
|
||||
{
|
||||
++resultOff;
|
||||
--remain;
|
||||
}
|
||||
}
|
||||
else if(_self.Bh[bi].Digest[i] != 0)
|
||||
{
|
||||
if(remain <= 0)
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
result[resultOff] = _self.Bh[bi].Digest[i];
|
||||
|
||||
if(i < 3 ||
|
||||
result[resultOff] != result[resultOff - 1] ||
|
||||
result[resultOff] != result[resultOff - 2] ||
|
||||
result[resultOff] != result[resultOff - 3])
|
||||
{
|
||||
++resultOff;
|
||||
--remain;
|
||||
}
|
||||
}
|
||||
|
||||
if(remain <= 0)
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
result[resultOff++] = 0x3A; // ':'
|
||||
--remain;
|
||||
|
||||
if(bi < _self.Bhend - 1)
|
||||
{
|
||||
++bi;
|
||||
i = (int)_self.Bh[bi].Dlen;
|
||||
|
||||
if(i > remain)
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
Array.Copy(_self.Bh[bi].Digest, 0, result, resultOff, i);
|
||||
resultOff += i;
|
||||
remain -= i;
|
||||
|
||||
if(h != 0)
|
||||
{
|
||||
if(remain <= 0)
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
h = _self.Bh[bi].Halfh;
|
||||
result[resultOff] = _b64[h % 64];
|
||||
|
||||
if(i < 3 ||
|
||||
result[resultOff] != result[resultOff - 1] ||
|
||||
result[resultOff] != result[resultOff - 2] ||
|
||||
result[resultOff] != result[resultOff - 3])
|
||||
{
|
||||
++resultOff;
|
||||
--remain;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i = _self.Bh[bi].Halfdigest;
|
||||
|
||||
if(i != 0)
|
||||
{
|
||||
if(remain <= 0)
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
result[resultOff] = (byte)i;
|
||||
|
||||
if(i < 3 ||
|
||||
result[resultOff] != result[resultOff - 1] ||
|
||||
result[resultOff] != result[resultOff - 2] ||
|
||||
result[resultOff] != result[resultOff - 3])
|
||||
{
|
||||
++resultOff;
|
||||
--remain;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(h != 0)
|
||||
{
|
||||
if(_self.Bh[bi].Dlen != 0)
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
if(remain <= 0)
|
||||
throw new Exception("Assertion failed");
|
||||
|
||||
result[resultOff++] = _b64[_self.Bh[bi].H % 64];
|
||||
/* No need to bother with FUZZY_FLAG_ELIMSEQ, because this
|
||||
* digest has length 1. */
|
||||
--remain;
|
||||
}
|
||||
|
||||
result[resultOff] = 0;
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of a file</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public static byte[] File(string filename) =>
|
||||
throw new NotImplementedException("SpamSum does not have a binary representation.");
|
||||
|
||||
/// <summary>Gets the hash of a file in hexadecimal and as a byte array.</summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string File(string filename, out byte[] hash) =>
|
||||
throw new NotImplementedException("Not yet implemented.");
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</param>
|
||||
/// <param name="hash">null</param>
|
||||
/// <returns>Base64 representation of SpamSum $blocksize:$hash:$hash</returns>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||
{
|
||||
var fuzzyContext = new SpamSumContext();
|
||||
|
||||
fuzzyContext.Update(data, len);
|
||||
|
||||
hash = null;
|
||||
|
||||
return fuzzyContext.End();
|
||||
}
|
||||
|
||||
/// <summary>Gets the hash of the specified data buffer.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="hash">null</param>
|
||||
/// <returns>Base64 representation of SpamSum $blocksize:$hash:$hash</returns>
|
||||
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
|
||||
|
||||
// Converts an ASCII null-terminated string to .NET string
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static string CToString(byte[] cString)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
// ReSharper disable once LoopCanBeConvertedToQuery
|
||||
// LINQ is six times slower
|
||||
foreach(byte c in cString)
|
||||
{
|
||||
if(c == 0)
|
||||
break;
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
return Encoding.ASCII.GetString(cString, 0, count);
|
||||
}
|
||||
|
||||
struct RollState
|
||||
{
|
||||
public byte[] Window;
|
||||
|
||||
// ROLLING_WINDOW
|
||||
public uint H1;
|
||||
public uint H2;
|
||||
public uint H3;
|
||||
public uint N;
|
||||
}
|
||||
|
||||
/* A blockhash contains a signature state for a specific (implicit) blocksize.
|
||||
* The blocksize is given by SSDEEP_BS(index). The h and halfh members are the
|
||||
* FNV hashes, where halfh stops to be reset after digest is SPAMSUM_LENGTH/2
|
||||
* long. The halfh hash is needed be able to truncate digest for the second
|
||||
* output hash to stay compatible with ssdeep output. */
|
||||
struct BlockhashContext
|
||||
{
|
||||
public uint H;
|
||||
public uint Halfh;
|
||||
public byte[] Digest;
|
||||
|
||||
// SPAMSUM_LENGTH
|
||||
public byte Halfdigest;
|
||||
public uint Dlen;
|
||||
}
|
||||
|
||||
struct FuzzyState
|
||||
{
|
||||
public uint Bhstart;
|
||||
public uint Bhend;
|
||||
public BlockhashContext[] Bh;
|
||||
|
||||
//NUM_BLOCKHASHES
|
||||
public ulong TotalSize;
|
||||
public RollState Roll;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,632 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
next_line = crlf
|
||||
insert_final_newline = false
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
# Generic non-language specific ones for Resharper and friends
|
||||
brace_style = next_line
|
||||
int_align = true
|
||||
keep_existing_arrangement = false
|
||||
place_simple_blocks_on_single_line = true
|
||||
place_simple_declaration_blocks_on_single_line = true
|
||||
place_attribute_on_same_line = false
|
||||
space_after_unary_operator = false
|
||||
space_after_comma = true
|
||||
space_around_ternary_operator = true
|
||||
space_around_binary_operator = true
|
||||
space_around_member_access_operator = false
|
||||
space_before_open_square_brackets = false
|
||||
space_after_keywords_in_control_flow_statements = true
|
||||
space_before_comma = false
|
||||
space_between_method_call_name_and_opening_parenthesis = false
|
||||
space_between_method_declaration_name_and_open_parenthesis = false
|
||||
space_between_square_brackets = false
|
||||
space_between_parentheses_of_control_flow_statements = false
|
||||
accessor_owner_declaration_braces = next_line
|
||||
accessor_declaration_braces = next_line
|
||||
case_block_braces = next_line
|
||||
initializer_braces = next_line
|
||||
other_braces = next_line
|
||||
allow_comment_after_lbrace = false
|
||||
empty_block_style = together_same_line
|
||||
braces_for_ifelse = not_required
|
||||
braces_for_for = not_required
|
||||
braces_for_foreach = not_required
|
||||
braces_for_while = not_required
|
||||
braces_for_dowhile = not_required
|
||||
braces_for_using = not_required
|
||||
braces_for_lock = not_required
|
||||
braces_for_fixed = not_required
|
||||
method_or_operator_body = expression_body
|
||||
local_function_body = expression_body
|
||||
constructor_or_destructor_body = expression_body
|
||||
accessor_owner_body = expression_body
|
||||
force_attribute_style = join
|
||||
function_braces = next_line
|
||||
force_control_statements_braces = always_remove
|
||||
space_in_singleline_accessorholder = true
|
||||
type_declaration_braces = next_line
|
||||
invocable_declaration_braces = next_line
|
||||
anonymous_method_declaration_braces = next_line
|
||||
space_between_accessors_in_singleline_property = true
|
||||
indent_nested_usings_stmt = true
|
||||
space_within_empty_braces = false
|
||||
indent_nested_fixed_stmt = true
|
||||
indent_nested_lock_stmt = true
|
||||
indent_nested_for_stmt = true
|
||||
indent_nested_foreach_stmt = true
|
||||
indent_nested_while_stmt = true
|
||||
use_continuous_indent_inside_parens = true
|
||||
indent_method_decl_pars = inside
|
||||
indent_invocation_pars = inside
|
||||
indent_statement_pars = inside
|
||||
indent_typeparam_angles = inside
|
||||
indent_typearg_angles = inside
|
||||
indent_pars = inside
|
||||
indent_preprocessor_if = outdent
|
||||
indent_preprocessor_region = usual_indent
|
||||
indent_preprocessor_other = usual_indent
|
||||
indent_switch_labels = true
|
||||
indent_type_constraints = true
|
||||
stick_comment = false
|
||||
alignment_tab_fill_style = use_spaces
|
||||
align_multiline_parameter = true
|
||||
align_multiline_extends_list = true
|
||||
align_linq_query = true
|
||||
align_multiline_binary_expressions_chain = true
|
||||
outdent_binary_ops = true
|
||||
align_multiline_calls_chain = true
|
||||
outdent_dots = true
|
||||
align_multiline_array_and_object_initializer = false
|
||||
indent_anonymous_method_block = false
|
||||
align_first_arg_by_paren = true
|
||||
align_multiline_argument = true
|
||||
align_tuple_components = true
|
||||
align_multiline_expression = true
|
||||
align_multiline_for_stmt = true
|
||||
align_multiple_declaration = true
|
||||
align_multline_type_parameter_list = true
|
||||
align_multline_type_parameter_constrains = true
|
||||
int_align_fields = true
|
||||
int_align_properties = true
|
||||
int_align_methods = true
|
||||
int_align_parameters = false
|
||||
int_align_variables = true
|
||||
int_align_assignments = true
|
||||
int_align_nested_ternary = true
|
||||
int_align_invocations = false
|
||||
int_align_binary_expressions = true
|
||||
int_align_comments = true
|
||||
int_align_switch_sections = true
|
||||
keep_user_linebreaks = false
|
||||
keep_existing_arrangement = false
|
||||
keep_existing_linebreaks = false
|
||||
max_line_length = 120
|
||||
wrap_before_comma = false
|
||||
special_else_if_treatment = true
|
||||
place_type_attribute_on_same_line = never
|
||||
place_method_attribute_on_same_line = never
|
||||
place_accessorholder_attribute_on_same_line = never
|
||||
place_attribute_on_same_line = never
|
||||
place_accessor_attribute_on_same_line = never
|
||||
place_attribute_on_same_line = never
|
||||
place_field_attribute_on_same_line = never
|
||||
place_attribute_on_same_line = never
|
||||
wrap_parameters_style = wrap_if_long
|
||||
keep_existing_declaration_parens_arrangement = false
|
||||
wrap_before_declaration_lpar = false
|
||||
wrap_after_declaration_lpar = false
|
||||
wrap_before_declaration_rpar = false
|
||||
place_constructor_initializer_on_same_line = true
|
||||
keep_existing_expr_member_arrangement = false
|
||||
place_expr_method_on_single_line = true
|
||||
place_expr_property_on_single_line = true
|
||||
place_expr_accessor_on_single_line = true
|
||||
wrap_before_arrow_with_expressions = false
|
||||
place_type_constraints_on_same_line = true
|
||||
wrap_before_first_type_parameter_constraint = true
|
||||
wrap_multiple_type_parameter_constraints_style = wrap_if_long
|
||||
wrap_before_type_parameter_langle = true
|
||||
wrap_before_extends_colon = false
|
||||
wrap_extends_list_style = wrap_if_long
|
||||
keep_existing_declaration_block_arrangement = false
|
||||
place_abstract_accessorholder_on_single_line = true
|
||||
place_simple_accessorholder_on_single_line = false
|
||||
place_accessor_with_attrs_holder_on_single_line = false
|
||||
place_simple_accessor_on_single_line = true
|
||||
place_simple_method_on_single_line = false
|
||||
keep_existing_enum_arrangement = false
|
||||
place_simple_enum_on_single_line = false
|
||||
wrap_enum_declaration = wrap_if_long
|
||||
new_line_before_else = true
|
||||
new_line_before_while = false
|
||||
wrap_for_stmt_header_style = wrap_if_long
|
||||
wrap_multiple_declaration_style = wrap_if_long
|
||||
keep_existing_embedded_arrangement = false
|
||||
place_simple_embedded_statement_on_same_line = false
|
||||
place_simple_case_statement_on_same_line = true
|
||||
keep_existing_embedded_block_arrangement = false
|
||||
place_simple_embedded_block_on_same_line = false
|
||||
place_simple_anonymousmethod_on_single_line = false
|
||||
keep_existing_initializer_arrangement = false
|
||||
place_simple_initializer_on_single_line = false
|
||||
wrap_object_and_collection_initializer_style = chop_always
|
||||
wrap_array_initializer_style = wrap_if_long
|
||||
wrap_arguments_style = wrap_if_long
|
||||
keep_existing_invocation_parens_arrangement = false
|
||||
wrap_after_invocation_lpar = false
|
||||
wrap_before_invocation_rpar = false
|
||||
wrap_after_dot_in_method_calls = true
|
||||
wrap_chained_method_calls = wrap_if_long
|
||||
wrap_before_binary_opsign = false
|
||||
wrap_chained_binary_expressions = wrap_if_long
|
||||
force_chop_compound_if_expression = true
|
||||
force_chop_compound_while_expression = true
|
||||
force_chop_compound_do_expression = true
|
||||
wrap_before_ternary_opsigns = true
|
||||
wrap_ternary_expr_style = wrap_if_long
|
||||
nested_ternary_style = expanded
|
||||
wrap_linq_expressions = wrap_if_long
|
||||
wrap_before_linq_expression = false
|
||||
place_linq_into_on_new_line = false
|
||||
wrap_verbatim_interpolated_strings = wrap_if_long
|
||||
extra_spaces = remove_all
|
||||
space_after_keywords_in_control_flow_statements = false
|
||||
space_between_method_call_name_and_opening_parenthesis = false
|
||||
space_between_method_declaration_name_and_open_parenthesis = false
|
||||
space_before_typeof_parentheses = false
|
||||
space_before_checked_parentheses = false
|
||||
space_before_sizeof_parentheses = false
|
||||
space_before_nameof_parentheses = false
|
||||
space_between_keyword_and_expression = true
|
||||
space_between_keyword_and_type = true
|
||||
space_around_assignment_op = true
|
||||
space_around_logical_op = true
|
||||
space_around_binary_operator = true
|
||||
space_around_equality_op = true
|
||||
space_around_relational_op = true
|
||||
space_around_bitwise_op = true
|
||||
space_around_additive_op = true
|
||||
space_around_multiplicative_op = true
|
||||
space_around_shift_op = true
|
||||
space_around_nullcoalescing_op = true
|
||||
space_around_arrow_op = false
|
||||
space_after_logical_not_op = false
|
||||
space_after_unary_operator = false
|
||||
space_after_cast = false
|
||||
space_around_dot = false
|
||||
space_around_lambda_arrow = true
|
||||
space_before_pointer_asterik_declaration = false
|
||||
space_before_nullable_mark = false
|
||||
blank_lines_around_class_definition = 1
|
||||
namespace_indentation = all
|
||||
space_within_template_argument = false
|
||||
align_union_type_usage = true
|
||||
space_in_singleline_method = true
|
||||
space_in_singleline_anonymous_method = true
|
||||
space_within_single_line_array_initializer_braces = true
|
||||
space_around_arrow_op = false
|
||||
|
||||
# These are for markup languages (HTML, XML, etc)
|
||||
spaces_around_eq_in_pi_attribute = false
|
||||
space_after_last_pi_attribute = true
|
||||
pi_attributes_indent = align_by_first_attribute
|
||||
blank_line_after_pi = true
|
||||
spaces_around_eq_in_attribute = false
|
||||
space_after_last_attribute = false
|
||||
space_before_self_closing = true
|
||||
attribute_style = on_single_line
|
||||
attribute_indent = align_by_first_attribute
|
||||
sort_attributes = true
|
||||
sort_class_selectors = true
|
||||
max_blank_lines_between_tags = 0
|
||||
linebreak_before_all_elements = true
|
||||
linebreak_before_multiline_elements = true
|
||||
quote_style = doublequoted
|
||||
delete_quotes_from_solid_values = false
|
||||
normalize_tag_names = true
|
||||
|
||||
|
||||
[{.babelrc,.stylelintrc,jest.config,.eslintrc,.prettierrc,*.json,*.jsb3,*.jsb2,*.bowerrc}]
|
||||
indent_size = 2
|
||||
|
||||
[*.js.map]
|
||||
indent_size = 2
|
||||
|
||||
[*.{css,scss}]
|
||||
indent_size = 2
|
||||
declarations_style = separate_lines_for_nonsingle
|
||||
media_query_style = separate_lines
|
||||
selector_style = same_line
|
||||
properties_style = separate_lines_for_nonsingle
|
||||
brace_style = next_line
|
||||
|
||||
[{.analysis_options,*.yml,*.yaml}]
|
||||
indent_size = 2
|
||||
|
||||
# Xml project files
|
||||
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
|
||||
indent_size = 2
|
||||
|
||||
# Xml files
|
||||
[*.{xml,stylecop,resx,ruleset}]
|
||||
indent_size = 2
|
||||
|
||||
# Xml config files
|
||||
[*.{props,targets,config,nuspec}]
|
||||
indent_size = 2
|
||||
|
||||
# .net files
|
||||
[*.{cs,vb}]
|
||||
# These set the this. / Me.
|
||||
dotnet_style_qualification_for_field = false:warning
|
||||
dotnet_style_qualification_for_property = false:warning
|
||||
dotnet_style_qualification_for_method = false:warning
|
||||
dotnet_style_qualification_for_event = false:warning
|
||||
|
||||
# These make it suggest Int32 instead of int, etc.
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
|
||||
dotnet_style_predefined_type_for_member_access = true:suggestion
|
||||
|
||||
# This controls implicit access modifiers
|
||||
dotnet_style_require_accessibility_modifiers = never:suggestion
|
||||
|
||||
# Prefer non modified fields to be marked readonly
|
||||
dotnet_style_readonly_field = true:warning
|
||||
|
||||
# Parenthesis settings
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_other_operators = always_for_clarity:warning
|
||||
|
||||
dotnet_style_object_initializer = true:suggestion
|
||||
dotnet_style_collection_initializer = true:suggestion
|
||||
dotnet_style_explicit_tuple_names = true:error
|
||||
dotnet_style_prefer_inferred_tuple_names = true:warning
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
|
||||
dotnet_style_prefer_conditional_expression_over_return = true:warning
|
||||
dotnet_style_coalesce_expression = true:warning
|
||||
dotnet_style_null_propagation = true:error
|
||||
|
||||
dotnet_sort_system_directives_first = true
|
||||
|
||||
# Constants in C style, all-caps
|
||||
dotnet_naming_rule.constant_fields_caps.symbols = constant_fields
|
||||
dotnet_naming_rule.constant_fields_caps.severity = warning
|
||||
dotnet_naming_rule.constant_fields_caps.style = caps_style
|
||||
dotnet_naming_symbols.constant_fields.applicable_kinds = field
|
||||
dotnet_naming_symbols.constant_fields.required_modifiers = const
|
||||
dotnet_naming_style.caps_style.capitalization = all_upper
|
||||
|
||||
# interfaces should be prefixed with I
|
||||
dotnet_naming_rule.pascal_case_for_interface.severity = error
|
||||
dotnet_naming_rule.pascal_case_for_interface.symbols = interfaces_fields
|
||||
dotnet_naming_rule.pascal_case_for_interface.style = pascal_case_interface_style
|
||||
dotnet_naming_symbols.interfaces_fields.applicable_kinds = interface
|
||||
dotnet_naming_style.pascal_case_interface_style.required_prefix = I
|
||||
dotnet_naming_style.pascal_case_interface_style.capitalization = pascal_case
|
||||
|
||||
## internal and private fields should be _camelCase
|
||||
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = warning
|
||||
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
|
||||
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
|
||||
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
|
||||
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
|
||||
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
|
||||
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
|
||||
|
||||
# 2018-12-07 NP: This is not yet working in VS2017
|
||||
# local variables should be camelCase
|
||||
#dotnet_naming_rule.camel_case_for_locals.severity = suggestion
|
||||
#dotnet_naming_rule.camel_case_for_locals.symbols = local_fields
|
||||
#dotnet_naming_rule.camel_case_for_locals.style = camel_case_style
|
||||
#dotnet_naming_symbols.local_fields.applicable_kinds = local
|
||||
#dotnet_naming_style.camel_case_style.capitalization = camel_case
|
||||
|
||||
[*.cs]
|
||||
# var var var
|
||||
csharp_style_var_for_built_in_types = false:warning
|
||||
csharp_style_var_when_type_is_apparent = true:suggestion
|
||||
csharp_style_var_elsewhere = false:warning
|
||||
|
||||
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_constructors = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_operators = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_properties = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_indexers = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_accessors = when_on_single_line:suggestion
|
||||
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
|
||||
csharp_style_pattern_matching_over_as_with_null_check = when_on_single_line:warning
|
||||
|
||||
csharp_style_inlined_variable_declaration = true:warning
|
||||
|
||||
csharp_prefer_simple_default_expression = true:warning
|
||||
csharp_style_deconstructed_variable_declaration = false:warning
|
||||
|
||||
csharp_style_throw_expression = true:warning
|
||||
csharp_style_conditional_delegate_call = true:warning
|
||||
|
||||
csharp_prefer_braces = false
|
||||
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_indent_labels = flush_left
|
||||
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = none
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
|
||||
csharp_preserve_single_line_statements = false
|
||||
csharp_preserve_single_line_blocks = true
|
||||
|
||||
csharp_blank_lines_around_region = 0
|
||||
csharp_blank_lines_inside_region = 0
|
||||
csharp_blank_lines_before_single_line_comment = 1
|
||||
csharp_keep_blank_lines_in_declarations = 1
|
||||
csharp_remove_blank_lines_near_braces_in_declarations = true
|
||||
csharp_blank_lines_after_start_comment = false
|
||||
csharp_blank_lines_between_using_groups = 0
|
||||
csharp_blank_lines_after_using_list = 1
|
||||
csharp_blank_lines_around_namespace = 1
|
||||
csharp_blank_lines_inside_namespace = 0
|
||||
csharp_blank_lines_around_type = 1
|
||||
csharp_blank_lines_inside_type = 0
|
||||
csharp_blank_lines_around_field = 0
|
||||
csharp_blank_lines_around_single_line_field = 0
|
||||
csharp_blank_lines_around_property = 1
|
||||
csharp_blank_lines_around_single_line_property = 0
|
||||
csharp_blank_lines_around_auto_property = 0
|
||||
csharp_blank_lines_around_single_line_auto_property = 0
|
||||
csharp_blank_lines_around_invocable = 1
|
||||
csharp_blank_lines_around_single_line_invocable = 1
|
||||
csharp_keep_blank_lines_in_code = 1
|
||||
csharp_remove_blank_lines_near_braces_in_code = true
|
||||
csharp_blank_lines_around_local_method = 1
|
||||
csharp_blank_lines_around_single_line_local_method = 1
|
||||
csharp_blank_lines_before_control_transfer_statements = 1
|
||||
csharp_blank_lines_after_control_transfer_statements = 1
|
||||
csharp_blank_lines_before_block_statements = 1
|
||||
csharp_blank_lines_after_block_statements = 1
|
||||
csharp_blank_lines_before_multiline_statements = 1
|
||||
csharp_blank_lines_after_multiline_statements = 1
|
||||
|
||||
csharp_type_declaration_braces = next_line
|
||||
csharp_brace_style = next_line
|
||||
csharp_indent_inside_namespace = true
|
||||
csharp_invocable_declaration_braces = next_line
|
||||
csharp_anonymous_method_declaration_braces = next_line
|
||||
csharp_accessor_owner_declaration_braces = next_line
|
||||
csharp_accessor_declaration_braces = next_line
|
||||
csharp_case_block_braces = next_line
|
||||
csharp_initializer_braces = next_line
|
||||
csharp_other_braces = next_line
|
||||
csharp_allow_comment_after_lbrace = false
|
||||
csharp_empty_block_style = together_same_line
|
||||
|
||||
csharp_for_built_in_types = use_explicit_type
|
||||
csharp_for_simple_types = use_var_when_evident
|
||||
csharp_for_other_types = use_explicit_type
|
||||
csharp_prefer_separate_deconstructed_variables_declaration = true
|
||||
csharp_prefer_explicit_discard_declaration = false
|
||||
|
||||
csharp_instance_members_qualify_members = none
|
||||
csharp_builtin_type_reference_style = use_keyword
|
||||
csharp_prefer_qualified_reference = false
|
||||
csharp_add_imports_to_deepest_scope = false
|
||||
csharp_allow_alias = true
|
||||
csharp_default_private_modifier = implicit
|
||||
csharp_default_internal_modifier = explicit
|
||||
csharp_arguments_literal = positional
|
||||
csharp_arguments_string_literal = positional
|
||||
csharp_arguments_named = positional
|
||||
csharp_arguments_anonymous_function = positional
|
||||
csharp_arguments_other = positional
|
||||
csharp_braces_for_ifelse = not_required
|
||||
csharp_braces_for_for = not_required
|
||||
csharp_braces_for_foreach = not_required
|
||||
csharp_braces_for_while = not_required
|
||||
csharp_braces_for_dowhile = not_required
|
||||
csharp_braces_for_using = not_required
|
||||
csharp_braces_for_lock = not_required
|
||||
csharp_braces_for_fixed = not_required
|
||||
csharp_method_or_operator_body = expression_body
|
||||
csharp_local_function_body = expression_body
|
||||
csharp_constructor_or_destructor_body = expression_body
|
||||
csharp_accessor_owner_body = expression_body
|
||||
csharp_force_attribute_style = join
|
||||
csharp_indent_nested_usings_stmt = true
|
||||
|
||||
csharp_builtin_type_reference_for_member_access_style = use_keyword
|
||||
csharp_indent_nested_fixed_stmt = true
|
||||
csharp_indent_nested_lock_stmt = true
|
||||
csharp_indent_nested_for_stmt = true
|
||||
csharp_indent_nested_foreach_stmt = true
|
||||
csharp_indent_nested_while_stmt = true
|
||||
csharp_use_continuous_indent_inside_parens = true
|
||||
csharp_indent_method_decl_pars = inside
|
||||
csharp_indent_invocation_pars = inside
|
||||
csharp_indent_statement_pars = inside
|
||||
csharp_indent_typeparam_angles = inside
|
||||
csharp_indent_typearg_angles = inside
|
||||
csharp_indent_pars = inside
|
||||
csharp_indent_preprocessor_if = outdent
|
||||
csharp_indent_preprocessor_region = usual_indent
|
||||
csharp_indent_preprocessor_other = usual_indent
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_indent_type_constraints = true
|
||||
csharp_stick_comment = false
|
||||
csharp_alignment_tab_fill_style = use_spaces
|
||||
csharp_align_multiline_parameter = true
|
||||
csharp_align_multiline_extends_list = true
|
||||
csharp_align_linq_query = true
|
||||
csharp_align_multiline_binary_expressions_chain = true
|
||||
csharp_outdent_binary_ops = true
|
||||
csharp_align_multiline_calls_chain = true
|
||||
csharp_outdent_dots = true
|
||||
csharp_align_multiline_array_and_object_initializer = false
|
||||
csharp_indent_anonymous_method_block = false
|
||||
csharp_align_first_arg_by_paren = true
|
||||
csharp_align_multiline_argument = true
|
||||
csharp_align_tuple_components = true
|
||||
csharp_align_multiline_expression = true
|
||||
csharp_align_multiline_for_stmt = true
|
||||
csharp_align_multiple_declaration = true
|
||||
csharp_align_multline_type_parameter_list = true
|
||||
csharp_align_multline_type_parameter_constrains = true
|
||||
csharp_int_align_fields = true
|
||||
csharp_int_align_properties = true
|
||||
csharp_int_align_methods = true
|
||||
csharp_int_align_parameters = false
|
||||
csharp_int_align_variables = true
|
||||
csharp_int_align_assignments = true
|
||||
csharp_int_align_nested_ternary = true
|
||||
csharp_int_align_invocations = false
|
||||
csharp_int_align_binary_expressions = true
|
||||
csharp_int_align_comments = true
|
||||
csharp_int_align_switch_sections = true
|
||||
csharp_int_align = true
|
||||
csharp_keep_user_linebreaks = false
|
||||
csharp_keep_existing_arrangement = false
|
||||
csharp_keep_existing_linebreaks = false
|
||||
csharp_max_line_length = 120
|
||||
csharp_wrap_before_comma = false
|
||||
csharp_special_else_if_treatment = true
|
||||
csharp_insert_final_newline = false
|
||||
csharp_place_type_attribute_on_same_line = never
|
||||
csharp_place_method_attribute_on_same_line = never
|
||||
csharp_place_accessorholder_attribute_on_same_line = never
|
||||
csharp_place_attribute_on_same_line = never
|
||||
csharp_place_accessor_attribute_on_same_line = never
|
||||
csharp_place_attribute_on_same_line = never
|
||||
csharp_place_field_attribute_on_same_line = never
|
||||
csharp_place_attribute_on_same_line = never
|
||||
csharp_wrap_parameters_style = wrap_if_long
|
||||
csharp_keep_existing_declaration_parens_arrangement = false
|
||||
csharp_wrap_before_declaration_lpar = false
|
||||
csharp_wrap_after_declaration_lpar = false
|
||||
csharp_wrap_before_declaration_rpar = false
|
||||
csharp_place_constructor_initializer_on_same_line = true
|
||||
csharp_keep_existing_expr_member_arrangement = false
|
||||
csharp_place_expr_method_on_single_line = true
|
||||
csharp_place_expr_property_on_single_line = true
|
||||
csharp_place_expr_accessor_on_single_line = true
|
||||
csharp_wrap_before_arrow_with_expressions = false
|
||||
csharp_place_type_constraints_on_same_line = true
|
||||
csharp_wrap_before_first_type_parameter_constraint = true
|
||||
csharp_wrap_multiple_type_parameter_constraints_style = wrap_if_long
|
||||
csharp_wrap_before_type_parameter_langle = true
|
||||
csharp_wrap_before_extends_colon = false
|
||||
csharp_wrap_extends_list_style = wrap_if_long
|
||||
csharp_keep_existing_declaration_block_arrangement = false
|
||||
csharp_place_abstract_accessorholder_on_single_line = true
|
||||
csharp_place_simple_accessorholder_on_single_line = false
|
||||
csharp_place_accessor_with_attrs_holder_on_single_line = false
|
||||
csharp_place_simple_accessor_on_single_line = true
|
||||
csharp_place_simple_method_on_single_line = false
|
||||
csharp_keep_existing_enum_arrangement = false
|
||||
csharp_place_simple_enum_on_single_line = false
|
||||
csharp_wrap_enum_declaration = wrap_if_long
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_while = false
|
||||
csharp_wrap_for_stmt_header_style = wrap_if_long
|
||||
csharp_wrap_multiple_declaration_style = wrap_if_long
|
||||
csharp_keep_existing_embedded_arrangement = false
|
||||
csharp_place_simple_embedded_statement_on_same_line = false
|
||||
csharp_place_simple_case_statement_on_same_line = true
|
||||
csharp_keep_existing_embedded_block_arrangement = false
|
||||
csharp_place_simple_embedded_block_on_same_line = false
|
||||
csharp_place_simple_anonymousmethod_on_single_line = false
|
||||
csharp_keep_existing_initializer_arrangement = false
|
||||
csharp_place_simple_initializer_on_single_line = false
|
||||
csharp_wrap_object_and_collection_initializer_style = chop_always
|
||||
csharp_wrap_array_initializer_style = wrap_if_long
|
||||
csharp_wrap_arguments_style = wrap_if_long
|
||||
csharp_keep_existing_invocation_parens_arrangement = false
|
||||
csharp_wrap_after_invocation_lpar = false
|
||||
csharp_wrap_before_invocation_rpar = false
|
||||
csharp_wrap_after_dot_in_method_calls = true
|
||||
csharp_wrap_chained_method_calls = wrap_if_long
|
||||
csharp_wrap_before_binary_opsign = false
|
||||
csharp_wrap_chained_binary_expressions = wrap_if_long
|
||||
csharp_force_chop_compound_if_expression = true
|
||||
csharp_force_chop_compound_while_expression = true
|
||||
csharp_force_chop_compound_do_expression = true
|
||||
csharp_wrap_before_ternary_opsigns = true
|
||||
csharp_wrap_ternary_expr_style = wrap_if_long
|
||||
csharp_nested_ternary_style = expanded
|
||||
csharp_wrap_linq_expressions = wrap_if_long
|
||||
csharp_wrap_before_linq_expression = false
|
||||
csharp_place_linq_into_on_new_line = false
|
||||
csharp_wrap_verbatim_interpolated_strings = wrap_if_long
|
||||
csharp_extra_spaces = remove_all
|
||||
csharp_space_after_keywords_in_control_flow_statements = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||
csharp_space_before_typeof_parentheses = false
|
||||
csharp_space_before_checked_parentheses = false
|
||||
csharp_space_before_sizeof_parentheses = false
|
||||
csharp_space_before_nameof_parentheses = false
|
||||
csharp_space_between_keyword_and_expression = true
|
||||
csharp_space_between_keyword_and_type = true
|
||||
csharp_space_around_assignment_op = true
|
||||
csharp_space_around_logical_op = true
|
||||
csharp_space_around_binary_operator = true
|
||||
csharp_space_around_equality_op = true
|
||||
csharp_space_around_relational_op = true
|
||||
csharp_space_around_bitwise_op = true
|
||||
csharp_space_around_additive_op = true
|
||||
csharp_space_around_multiplicative_op = true
|
||||
csharp_space_around_shift_op = true
|
||||
csharp_space_around_nullcoalescing_op = true
|
||||
csharp_space_around_arrow_op = false
|
||||
csharp_space_after_logical_not_op = false
|
||||
csharp_space_after_unary_operator = false
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_around_dot = false
|
||||
csharp_space_around_lambda_arrow = true
|
||||
csharp_space_before_pointer_asterik_declaration = false
|
||||
csharp_space_before_nullable_mark = false
|
||||
|
||||
[*.cshtml]
|
||||
linebreaks_around_razor_statements = true
|
||||
blank_lines_around_razor_functions = true
|
||||
blank_lines_around_razor_helpers = true
|
||||
blank_lines_around_razor_sections = true
|
||||
|
||||
# C++
|
||||
[*.{cc,cpp,cxx,h,hpp,hxx}]
|
||||
cpp_indent_access_specifiers_from_class = true
|
||||
cpp_indent_wrapped_function_names = false
|
||||
cpp_align_multiline_type_argument = true
|
||||
|
||||
# C, C++ and ObjectiveC
|
||||
[*.{c,h,cc,cpp,cxx,m,hpp,hxx}]
|
||||
indent_preprocessor_directives = normal
|
||||
indent_type_constraints = true
|
||||
|
||||
# Javascript and Typescript
|
||||
[*.{js,js.map,ts}]
|
||||
quote_style = doublequoted
|
||||
termination_style = ensure_semicolon
|
||||
595
Aaru.CommonTypes/.gitignore
vendored
595
Aaru.CommonTypes/.gitignore
vendored
@@ -1,595 +0,0 @@
|
||||
### VisualStudio template
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
### Linux template
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
### Xcode template
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
## User settings
|
||||
xcuserdata/
|
||||
|
||||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
|
||||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
|
||||
build/
|
||||
DerivedData/
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
### VisualStudioCode template
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
### C++ template
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
### MonoDevelop template
|
||||
#User Specific
|
||||
*.usertasks
|
||||
|
||||
#Mono Project Files
|
||||
*.resources
|
||||
test-results/
|
||||
### GPG template
|
||||
secring.*
|
||||
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
### CMake template
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
### C template
|
||||
# Object files
|
||||
*.ko
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
*.so.*
|
||||
|
||||
# Executables
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
### Windows template
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# NuGet Packages Directory
|
||||
packages/
|
||||
## TODO: If the tool you use requires repositories.config uncomment the next line
|
||||
#!packages/repositories.config
|
||||
|
||||
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
|
||||
# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
|
||||
!packages/build/
|
||||
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
|
||||
# Visual Studio 2017
|
||||
.vs
|
||||
|
||||
workspace.xml
|
||||
cmake-build-debug
|
||||
### macOS template
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
pkg/**/pkg
|
||||
pkg/**/src
|
||||
pkg/**/*.asc
|
||||
pkg/**/*.sig
|
||||
pkg/**/*.tar.xz
|
||||
pkg/**/*.zip
|
||||
pkg/**/aaru
|
||||
|
||||
.sonarqube
|
||||
@@ -1,174 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F2B84194-26EB-4227-B1C5-6602517E85AE}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Aaru.CommonTypes</RootNamespace>
|
||||
<AssemblyName>Aaru.CommonTypes</AssemblyName>
|
||||
<ReleaseVersion>$(Version)</ReleaseVersion>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>6.0.0-alpha6</Version>
|
||||
<Company>Claunia.com</Company>
|
||||
<Copyright>Copyright © 2011-2021 Natalia Portillo</Copyright>
|
||||
<Product>Aaru Data Preservation Suite</Product>
|
||||
<Title>Aaru.CommonTypes</Title>
|
||||
<ApplicationVersion>$(Version)</ApplicationVersion>
|
||||
<TargetFramework>net6</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<Description>Contains common types defined by the Aaru Data Preservation Suite.</Description>
|
||||
<PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<RepositoryUrl>https://github.com/aaru-dps/Aaru.CommonTypes</RepositoryUrl>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<Authors>Natalia Portillo <claunia@claunia.com></Authors>
|
||||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
|
||||
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
|
||||
<NrtShowRevision>true</NrtShowRevision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\CICMMetadata\dotnet\cicm.cs">
|
||||
<Link>Metadata/cicm.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Delegates.cs" />
|
||||
<Compile Include="Enums\DeviceType.cs" />
|
||||
<Compile Include="Enums\ErrorNumber.cs" />
|
||||
<Compile Include="Enums\Images.cs" />
|
||||
<Compile Include="Extents\ExtentsByte.cs" />
|
||||
<Compile Include="Extents\ExtentsConverter.cs" />
|
||||
<Compile Include="Extents\ExtentsInt.cs" />
|
||||
<Compile Include="Extents\ExtentsLong.cs" />
|
||||
<Compile Include="Extents\ExtentsSByte.cs" />
|
||||
<Compile Include="Extents\ExtentsShort.cs" />
|
||||
<Compile Include="Extents\ExtentsUInt.cs" />
|
||||
<Compile Include="Extents\ExtentsULong.cs" />
|
||||
<Compile Include="Extents\ExtentsUShort.cs" />
|
||||
<Compile Include="Filters.cs" />
|
||||
<Compile Include="Geometry.cs" />
|
||||
<Compile Include="Interfaces\IChecksum.cs" />
|
||||
<Compile Include="Interfaces\IFilesystem.cs" />
|
||||
<Compile Include="Interfaces\IArchive.cs" />
|
||||
<Compile Include="Interfaces\IFilter.cs" />
|
||||
<Compile Include="Interfaces\IFloppyImage.cs" />
|
||||
<Compile Include="Interfaces\IMediaImage.cs" />
|
||||
<Compile Include="Interfaces\IOpticalMediaImage.cs" />
|
||||
<Compile Include="Interfaces\IPartition.cs" />
|
||||
<Compile Include="Interfaces\IPartitionableMediaImage.cs" />
|
||||
<Compile Include="Interfaces\IPluginRegister.cs" />
|
||||
<Compile Include="Interfaces\IReadOnlyFilesystem.cs" />
|
||||
<Compile Include="Interfaces\ITapeImage.cs" />
|
||||
<Compile Include="Interfaces\IVerifiableImage.cs" />
|
||||
<Compile Include="Interfaces\IVerifiableSectorsImage.cs" />
|
||||
<Compile Include="Interfaces\IWritableFloppyImage.cs" />
|
||||
<Compile Include="Interfaces\IWritableImage.cs" />
|
||||
<Compile Include="Interfaces\IWritableOpticalImage.cs" />
|
||||
<Compile Include="Interfaces\IWritableTapeImage.cs" />
|
||||
<Compile Include="Interop\DetectOS.cs" />
|
||||
<Compile Include="Interop\PlatformID.cs" />
|
||||
<Compile Include="Interop\Version.cs" />
|
||||
<Compile Include="MediaTypeFromDevice\FromAta.cs" />
|
||||
<Compile Include="MediaTypeFromDevice\FromMmc.cs" />
|
||||
<Compile Include="MediaTypeFromDevice\FromOdc.cs" />
|
||||
<Compile Include="MediaTypeFromDevice\FromScsi.cs" />
|
||||
<Compile Include="MediaTypeFromDevice\FromSbc.cs" />
|
||||
<Compile Include="MediaTypeFromDevice\FromSsc.cs" />
|
||||
<Compile Include="Metadata\CdOffset.cs" />
|
||||
<Compile Include="Metadata\DeviceReport.cs" />
|
||||
<Compile Include="Metadata\DeviceReportV2.cs" />
|
||||
<Compile Include="Metadata\Dimensions.cs" />
|
||||
<Compile Include="Metadata\MediaType.cs" />
|
||||
<Compile Include="Metadata\Resume.cs" />
|
||||
<Compile Include="Metadata\Statistics.cs" />
|
||||
<Compile Include="Metadata\Version.cs" />
|
||||
<Compile Include="Partition.cs" />
|
||||
<Compile Include="MediaType.cs" />
|
||||
<Compile Include="PluginBase.cs" />
|
||||
<Compile Include="Structs\Devices\ATA\Identify.cs" />
|
||||
<Compile Include="Structs\Devices\SCSI\Enums.cs" />
|
||||
<Compile Include="Structs\Devices\SCSI\Inquiry.cs" />
|
||||
<Compile Include="Structs\Devices\SCSI\Modes\2A.cs" />
|
||||
<Compile Include="Structs\Filesystems.cs" />
|
||||
<Compile Include="Structs\Images.cs" />
|
||||
<Compile Include="Structs\TapeFile.cs" />
|
||||
<Compile Include="Structs\TapePartition.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="6.0.0-preview.4.21253.7" />
|
||||
<PackageReference Include="System.Security.Principal.Windows" Version="6.0.0-preview.5.21301.5" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.1" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\LICENSE.MIT">
|
||||
<Link>LICENSE.MIT</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj" />
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************
Aaru Data Preservation Suite
----------------------------------------------------------------------------
 
Filename : ${FileName}
Author(s) : ${AuthorName} <${AuthorEmail}>

Component : Component
 
--[ Description ] ----------------------------------------------------------
 
 Description
 
--[ 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-${Year} ${CopyrightHolder}
****************************************************************************/" />
|
||||
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp" />
|
||||
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4')) and '$(OS)' == 'Unix'">
|
||||
<!-- When compiling .NET SDK 2.0 projects targeting .NET 4.x on Mono using 'dotnet build' you -->
|
||||
<!-- have to teach MSBuild where the Mono copy of the reference asssemblies is -->
|
||||
<!-- Look in the standard install locations -->
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/Library/Frameworks/Mono.framework/Versions/Current/lib/mono')">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<!-- If we found Mono reference assemblies, then use them -->
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net40'">$(BaseFrameworkPathOverrideForMono)/4.0-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net45'">$(BaseFrameworkPathOverrideForMono)/4.5-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net451'">$(BaseFrameworkPathOverrideForMono)/4.5.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net452'">$(BaseFrameworkPathOverrideForMono)/4.5.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net46'">$(BaseFrameworkPathOverrideForMono)/4.6-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net461'">$(BaseFrameworkPathOverrideForMono)/4.6.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net462'">$(BaseFrameworkPathOverrideForMono)/4.6.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net471'">$(BaseFrameworkPathOverrideForMono)/4.7.1-api</FrameworkPathOverride>
|
||||
<EnableFrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">true</EnableFrameworkPathOverride>
|
||||
<!-- Add the Facades directory. Not sure how else to do this. Necessary at least for .NET 4.5 -->
|
||||
<AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,2 +0,0 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mediatypefromdevice/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
@@ -1,90 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Delegates.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common types.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Delegates to communicate with user interface.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.CommonTypes
|
||||
{
|
||||
/// <summary>Initializes a progress indicator (e.g. makes a progress bar visible)</summary>
|
||||
public delegate void InitProgressHandler();
|
||||
|
||||
/// <summary>Updates a progress indicator with text</summary>
|
||||
public delegate void UpdateProgressHandler(string text, long current, long maximum);
|
||||
|
||||
/// <summary>Pulses a progress indicator with indeterminate boundaries</summary>
|
||||
public delegate void PulseProgressHandler(string text);
|
||||
|
||||
/// <summary>Uninitializes a progress indicator (e.g. adds a newline to the console)</summary>
|
||||
public delegate void EndProgressHandler();
|
||||
|
||||
/// <summary>Initializes a secondary progress indicator (e.g. makes a progress bar visible)</summary>
|
||||
public delegate void InitProgressHandler2();
|
||||
|
||||
/// <summary>Updates a secondary progress indicator with text</summary>
|
||||
public delegate void UpdateProgressHandler2(string text, long current, long maximum);
|
||||
|
||||
/// <summary>Pulses a secondary progress indicator with indeterminate boundaries</summary>
|
||||
public delegate void PulseProgressHandler2(string text);
|
||||
|
||||
/// <summary>Uninitializes a secondary progress indicator (e.g. adds a newline to the console)</summary>
|
||||
public delegate void EndProgressHandler2();
|
||||
|
||||
/// <summary>Initializes two progress indicators (e.g. makes a progress bar visible)</summary>
|
||||
public delegate void InitTwoProgressHandler();
|
||||
|
||||
/// <summary>Updates two progress indicators with text</summary>
|
||||
public delegate void UpdateTwoProgressHandler(string text, long current, long maximum, string text2, long current2,
|
||||
long maximum2);
|
||||
|
||||
/// <summary>Pulses a progress indicator with indeterminate boundaries</summary>
|
||||
public delegate void PulseTwoProgressHandler(string text, string text2);
|
||||
|
||||
/// <summary>Uninitializes a progress indicator (e.g. adds a newline to the console)</summary>
|
||||
public delegate void EndTwoProgressHandler();
|
||||
|
||||
/// <summary>Updates a status indicator</summary>
|
||||
public delegate void UpdateStatusHandler(string text);
|
||||
|
||||
/// <summary>Shows an error message</summary>
|
||||
public delegate void ErrorMessageHandler(string text);
|
||||
|
||||
/// <summary>Initializes a block map that's going to be filled with a media scan</summary>
|
||||
public delegate void InitBlockMapHandler(ulong blocks, ulong blockSize, ulong blocksToRead, ushort currentProfile);
|
||||
|
||||
/// <summary>Updates lists of time taken on scanning from the specified sector</summary>
|
||||
/// <param name="duration">Time in milliseconds</param>
|
||||
public delegate void ScanTimeHandler(ulong sector, double duration);
|
||||
|
||||
/// <summary>Specified a number of blocks could not be read on scan</summary>
|
||||
public delegate void ScanUnreadableHandler(ulong sector);
|
||||
|
||||
/// <summary>Sends the speed of scanning a specific sector</summary>
|
||||
public delegate void ScanSpeedHandler(ulong sector, double currentSpeed);
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : DeviceType.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines enumerations of device types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.CommonTypes.Enums
|
||||
{
|
||||
/// <summary>Device types</summary>
|
||||
public enum DeviceType
|
||||
{
|
||||
/// <summary>Unknown device type</summary>
|
||||
Unknown = -1,
|
||||
/// <summary>ATA device</summary>
|
||||
ATA = 1,
|
||||
/// <summary>ATA Packet device (aka SCSI over ATA)</summary>
|
||||
ATAPI = 2,
|
||||
/// <summary>SCSI device (or USB-MSC, SBP2, FC, UAS, etc)</summary>
|
||||
SCSI = 3,
|
||||
/// <summary>SecureDigital memory card</summary>
|
||||
SecureDigital = 4,
|
||||
/// <summary>MultiMediaCard memory card</summary>
|
||||
MMC = 5,
|
||||
/// <summary>NVMe device</summary>
|
||||
NVMe = 6
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ErrorNumber.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common types.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines enumerations of error numbers.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.CommonTypes.Enums
|
||||
{
|
||||
/// <summary>Enumerates error codes. Negative for UNIX error number equivalents, positive for Aaru error numbers.</summary>
|
||||
public enum ErrorNumber
|
||||
{
|
||||
NotPermitted = -1,
|
||||
/// <summary>No such file or directory</summary>
|
||||
NoSuchFile = -2, NoSuchProcess = -3, InterruptedSyscall = -4,
|
||||
/// <summary>I/O error</summary>
|
||||
InOutError = -5, NoSuchDeviceOrAddress = -6, ArgumentListTooLong = -7, ExecutableFormatError = -8,
|
||||
BadFileNumber = -9, NoChildProcess = -10, TryAgain = -11,
|
||||
OutOfMemory = -12,
|
||||
/// <summary>Access denied</summary>
|
||||
AccessDenied = -13, BadAddress = -14, NotABlockDevice = -15,
|
||||
/// <summary>Busy, cannot complete</summary>
|
||||
Busy = -16, FileExists = -17, CrossDeviceLink = -18,
|
||||
/// <summary>No such device</summary>
|
||||
NoSuchDevice = -19,
|
||||
/// <summary>Is not a directory (e.g.: trying to ReadDir() a file)</summary>
|
||||
NotDirectory = -20,
|
||||
/// <summary>Is a directory (e.g.: trying to Read() a dir)</summary>
|
||||
IsDirectory = -21,
|
||||
/// <summary>Invalid argument</summary>
|
||||
InvalidArgument = -22, FileTableOverflow = -23, TooManyOpenFiles = -24, NotTypewriter = -25,
|
||||
TextFileBusy = -26,
|
||||
/// <summary>File is too large</summary>
|
||||
FileTooLarge = -27, NoSpaceLeft = -28, IllegalSeek = -29, ReadOnly = -30,
|
||||
TooManyLinks = -31, BrokenPipe = -32, OutOfDomain = -33,
|
||||
OutOfRange = -34, DeadlockWouldOccur = -35,
|
||||
/// <summary>Name is too long</summary>
|
||||
NameTooLong = -36, NoLocksAvailable = -37,
|
||||
/// <summary>Not implemented</summary>
|
||||
NotImplemented = -38,
|
||||
/// <summary>There is no data available</summary>
|
||||
NoData = -61,
|
||||
/// <summary>Link is severed</summary>
|
||||
SeveredLink = -67,
|
||||
/// <summary>There is no such attribute</summary>
|
||||
NoSuchExtendedAttribute = NoData,
|
||||
/// <summary>Not supported</summary>
|
||||
NotSupported = -252, EPERM = NotPermitted,
|
||||
/// <summary>No such file or directory</summary>
|
||||
ENOENT = NoSuchFile, ESRCH = NoSuchProcess, EINTR = InterruptedSyscall,
|
||||
/// <summary>I/O error</summary>
|
||||
EIO = InOutError, ENXIO = NoSuchDeviceOrAddress, E2BIG = ArgumentListTooLong, ENOEXEC = ExecutableFormatError,
|
||||
EBADF = BadFileNumber, ECHILD = NoChildProcess, EAGAIN = TryAgain,
|
||||
ENOMEM = OutOfMemory,
|
||||
/// <summary>Access denied</summary>
|
||||
EACCES = AccessDenied, EFAULT = BadAddress, ENOTBLK = NotABlockDevice,
|
||||
/// <summary>Busy, cannot complete</summary>
|
||||
EBUSY = Busy, EEXIST = FileExists, EXDEV = CrossDeviceLink,
|
||||
/// <summary>No such device</summary>
|
||||
ENODEV = NoSuchDevice,
|
||||
/// <summary>Is not a directory (e.g.: trying to ReadDir() a file)</summary>
|
||||
ENOTDIR = NotDirectory,
|
||||
/// <summary>Is a directory (e.g.: trying to Read() a dir)</summary>
|
||||
EISDIR = IsDirectory,
|
||||
/// <summary>Invalid argument</summary>
|
||||
EINVAL = InvalidArgument, ENFILE = FileTableOverflow, EMFILE = TooManyOpenFiles, ENOTTY = NotTypewriter,
|
||||
ETXTBSY = TextFileBusy,
|
||||
/// <summary>File is too large</summary>
|
||||
EFBIG = FileTooLarge, ENOSPC = NoSpaceLeft, ESPIPE = IllegalSeek, EROFS = ReadOnly,
|
||||
EMLINK = TooManyLinks, EPIPE = BrokenPipe, EDOM = OutOfDomain,
|
||||
ERANGE = OutOfRange, EDEADLK = DeadlockWouldOccur,
|
||||
/// <summary>Name is too long</summary>
|
||||
ENAMETOOLONG = NameTooLong, ENOLCK = NoLocksAvailable,
|
||||
/// <summary>Not implemented</summary>
|
||||
ENOSYS = NotImplemented,
|
||||
/// <summary>Link is severed</summary>
|
||||
ENOLINK = SeveredLink,
|
||||
/// <summary>Not supported</summary>
|
||||
ENOTSUP = NotSupported, DirectoryNotEmpty = -39, TooManySymbolicLinks = -40, ENOTEMPTY = DirectoryNotEmpty,
|
||||
ELOOP = TooManySymbolicLinks,
|
||||
/// <summary>There is no such attribute</summary>
|
||||
ENOATTR = NoSuchExtendedAttribute,
|
||||
/// <summary>There is no data available</summary>
|
||||
ENODATA = NoData,
|
||||
/// <summary>No error</summary>
|
||||
NoError = 0,
|
||||
/// <summary>User requested help to be shown</summary>
|
||||
HelpRequested = 1,
|
||||
/// <summary>Command found nothing</summary>
|
||||
NothingFound = 2,
|
||||
/// <summary>Media has been already dumped completely</summary>
|
||||
AlreadyDumped = 3,
|
||||
/// <summary>Image and its sectors cannot be verified</summary>
|
||||
NotVerifiable = 4,
|
||||
/// <summary>There are bad sectors and image cannot be verified</summary>
|
||||
BadSectorsImageNotVerified = 5,
|
||||
/// <summary>All sectors are good and image cannot be verified</summary>
|
||||
CorrectSectorsImageNotVerified = 6,
|
||||
/// <summary>Image is bad and sectors cannot be verified</summary>
|
||||
BadImageSectorsNotVerified = 7,
|
||||
/// <summary>Image is bad and there are bad sectors</summary>
|
||||
BadImageBadSectors = 8,
|
||||
/// <summary>All sectors are good and image is bad</summary>
|
||||
CorrectSectorsBadImage = 9,
|
||||
/// <summary>Image is good and sectors cannot be verified</summary>
|
||||
CorrectImageSectorsNotVerified = 10,
|
||||
/// <summary>Image is good and there are bad sectors</summary>
|
||||
CorrectImageBadSectors = 11,
|
||||
/// <summary>Exception has been raised</summary>
|
||||
UnexpectedException = 12,
|
||||
/// <summary>The number of arguments is not as expected</summary>
|
||||
UnexpectedArgumentCount = 13,
|
||||
/// <summary>A required argument is not present</summary>
|
||||
MissingArgument = 14,
|
||||
/// <summary>The specified file cannot be opened</summary>
|
||||
CannotOpenFile = 15,
|
||||
/// <summary>The specified encoding cannot be found</summary>
|
||||
EncodingUnknown = 16,
|
||||
/// <summary>The image format has not been recognized</summary>
|
||||
UnrecognizedFormat = 17,
|
||||
/// <summary>The image format failed to open</summary>
|
||||
CannotOpenFormat = 18,
|
||||
/// <summary>The specified metadata sidecar does not have the correct format</summary>
|
||||
InvalidSidecar = 19,
|
||||
/// <summary>The specified resume map does not have the correct format</summary>
|
||||
InvalidResume = 20,
|
||||
/// <summary>The specified image format cannot be found</summary>
|
||||
FormatNotFound = 21,
|
||||
/// <summary>More than one format found for the specified search criteria</summary>
|
||||
TooManyFormats = 22,
|
||||
/// <summary>The specified format does not support the specified media</summary>
|
||||
UnsupportedMedia = 23,
|
||||
/// <summary>Data will be lost writing the specified format</summary>
|
||||
DataWillBeLost = 24,
|
||||
/// <summary>Cannot create destination format</summary>
|
||||
CannotCreateFormat = 25,
|
||||
/// <summary>Error writing data</summary>
|
||||
WriteError = 26,
|
||||
/// <summary>Cannot open device</summary>
|
||||
CannotOpenDevice = 27,
|
||||
/// <summary>Cannot remove the existing database</summary>
|
||||
CannotRemoveDatabase = 28,
|
||||
SectorNotFound=29
|
||||
}
|
||||
}
|
||||
@@ -1,393 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Images.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines enumerations to be used by disc image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// Copyright © 2020-2021 Rebecca Wallander
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
namespace Aaru.CommonTypes.Enums
|
||||
{
|
||||
/// <summary>Track (as partitioning element) types.</summary>
|
||||
public enum TrackType : byte
|
||||
{
|
||||
/// <summary>Audio track</summary>
|
||||
Audio = 0,
|
||||
/// <summary>Data track (not any of the below defined ones)</summary>
|
||||
Data = 1,
|
||||
/// <summary>Data track, compact disc mode 1</summary>
|
||||
CdMode1 = 2,
|
||||
/// <summary>Data track, compact disc mode 2, formless</summary>
|
||||
CdMode2Formless = 3,
|
||||
/// <summary>Data track, compact disc mode 2, form 1</summary>
|
||||
CdMode2Form1 = 4,
|
||||
/// <summary>Data track, compact disc mode 2, form 2</summary>
|
||||
CdMode2Form2 = 5
|
||||
}
|
||||
|
||||
/// <summary>Type of subchannel in track</summary>
|
||||
public enum TrackSubchannelType : byte
|
||||
{
|
||||
/// <summary>Track does not has subchannel dumped, or it's not a CD</summary>
|
||||
None = 0,
|
||||
/// <summary>Subchannel is packed and error corrected</summary>
|
||||
Packed = 1,
|
||||
/// <summary>Subchannel is interleaved</summary>
|
||||
Raw = 2,
|
||||
/// <summary>Subchannel is packed and comes interleaved with main channel in same file</summary>
|
||||
PackedInterleaved = 3,
|
||||
/// <summary>Subchannel is interleaved and comes interleaved with main channel in same file</summary>
|
||||
RawInterleaved = 4,
|
||||
/// <summary>Only Q subchannel is stored as 16 bytes</summary>
|
||||
Q16 = 5,
|
||||
/// <summary>Only Q subchannel is stored as 16 bytes and comes interleaved with main channel in same file</summary>
|
||||
Q16Interleaved = 6
|
||||
}
|
||||
|
||||
/// <summary>Metadata present for each sector (aka, "tag").</summary>
|
||||
public enum SectorTagType
|
||||
{
|
||||
/// <summary>Apple's GCR sector tags, 12 bytes</summary>
|
||||
AppleSectorTag = 0,
|
||||
/// <summary>Sync frame from CD sector, 12 bytes</summary>
|
||||
CdSectorSync = 1,
|
||||
/// <summary>CD sector header, 4 bytes</summary>
|
||||
CdSectorHeader = 2,
|
||||
/// <summary>CD mode 2 sector subheader</summary>
|
||||
CdSectorSubHeader = 3,
|
||||
/// <summary>CD sector EDC, 4 bytes</summary>
|
||||
CdSectorEdc = 4,
|
||||
/// <summary>CD sector ECC P, 172 bytes</summary>
|
||||
CdSectorEccP = 5,
|
||||
/// <summary>CD sector ECC Q, 104 bytes</summary>
|
||||
CdSectorEccQ = 6,
|
||||
/// <summary>CD sector ECC (P and Q), 276 bytes</summary>
|
||||
CdSectorEcc = 7,
|
||||
/// <summary>CD sector subchannel, 96 bytes</summary>
|
||||
CdSectorSubchannel = 8,
|
||||
/// <summary>CD track ISRC, string, 12 bytes</summary>
|
||||
CdTrackIsrc = 9,
|
||||
/// <summary>CD track text, string, 13 bytes</summary>
|
||||
CdTrackText = 10,
|
||||
/// <summary>CD track flags, 1 byte</summary>
|
||||
CdTrackFlags = 11,
|
||||
/// <summary>DVD sector copyright information</summary>
|
||||
DvdCmi = 12,
|
||||
/// <summary>Floppy address mark (contents depend on underlying floppy format)</summary>
|
||||
FloppyAddressMark = 13,
|
||||
/// <summary>DVD sector title key, 5 bytes</summary>
|
||||
DvdTitleKey = 14,
|
||||
/// <summary>Decrypted DVD sector title key, 5 bytes</summary>
|
||||
DvdTitleKeyDecrypted = 15
|
||||
}
|
||||
|
||||
/// <summary>Metadata present for each media.</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum MediaTagType
|
||||
{
|
||||
/// <summary>CD table of contents</summary>
|
||||
CD_TOC = 0,
|
||||
/// <summary>CD session information</summary>
|
||||
CD_SessionInfo = 1,
|
||||
/// <summary>CD full table of contents</summary>
|
||||
CD_FullTOC = 2,
|
||||
/// <summary>CD PMA</summary>
|
||||
CD_PMA = 3,
|
||||
/// <summary>CD Address-Time-In-Pregroove</summary>
|
||||
CD_ATIP = 4,
|
||||
/// <summary>CD-Text</summary>
|
||||
CD_TEXT = 5,
|
||||
/// <summary>CD Media Catalogue Number</summary>
|
||||
CD_MCN = 6,
|
||||
/// <summary>DVD/HD DVD Physical Format Information</summary>
|
||||
DVD_PFI = 7,
|
||||
/// <summary>DVD Lead-in Copyright Management Information</summary>
|
||||
DVD_CMI = 8,
|
||||
/// <summary>DVD disc key</summary>
|
||||
DVD_DiscKey = 9,
|
||||
/// <summary>DVD/HD DVD Burst Cutting Area</summary>
|
||||
DVD_BCA = 10,
|
||||
/// <summary>DVD/HD DVD Lead-in Disc Manufacturer Information</summary>
|
||||
DVD_DMI = 11,
|
||||
/// <summary>Media identifier</summary>
|
||||
DVD_MediaIdentifier = 12,
|
||||
/// <summary>Media key block</summary>
|
||||
DVD_MKB = 13,
|
||||
/// <summary>DVD-RAM/HD DVD-RAM DDS information</summary>
|
||||
DVDRAM_DDS = 14,
|
||||
/// <summary>DVD-RAM/HD DVD-RAM Medium status</summary>
|
||||
DVDRAM_MediumStatus = 15,
|
||||
/// <summary>DVD-RAM/HD DVD-RAM Spare area information</summary>
|
||||
DVDRAM_SpareArea = 16,
|
||||
/// <summary>DVD-R/-RW/HD DVD-R RMD in last border-out</summary>
|
||||
DVDR_RMD = 17,
|
||||
/// <summary>Pre-recorded information from DVD-R/-RW lead-in</summary>
|
||||
DVDR_PreRecordedInfo = 18,
|
||||
/// <summary>DVD-R/-RW/HD DVD-R media identifier</summary>
|
||||
DVDR_MediaIdentifier = 19,
|
||||
/// <summary>DVD-R/-RW/HD DVD-R physical format information</summary>
|
||||
DVDR_PFI = 20,
|
||||
/// <summary>ADIP information</summary>
|
||||
DVD_ADIP = 21,
|
||||
/// <summary>HD DVD Lead-in copyright protection information</summary>
|
||||
HDDVD_CPI = 22,
|
||||
/// <summary>HD DVD-R Medium Status</summary>
|
||||
HDDVD_MediumStatus = 23,
|
||||
/// <summary>DVD+/-R DL Layer capacity</summary>
|
||||
DVDDL_LayerCapacity = 24,
|
||||
/// <summary>DVD-R DL Middle Zone start address</summary>
|
||||
DVDDL_MiddleZoneAddress = 25,
|
||||
/// <summary>DVD-R DL Jump Interval Size</summary>
|
||||
DVDDL_JumpIntervalSize = 26,
|
||||
/// <summary>DVD-R DL Start LBA of the manual layer jump</summary>
|
||||
DVDDL_ManualLayerJumpLBA = 27,
|
||||
/// <summary>Blu-ray Disc Information</summary>
|
||||
BD_DI = 28,
|
||||
/// <summary>Blu-ray Burst Cutting Area</summary>
|
||||
BD_BCA = 29,
|
||||
/// <summary>Blu-ray Disc Definition Structure</summary>
|
||||
BD_DDS = 30,
|
||||
/// <summary>Blu-ray Cartridge Status</summary>
|
||||
BD_CartridgeStatus = 31,
|
||||
/// <summary>Blu-ray Status of Spare Area</summary>
|
||||
BD_SpareArea = 32,
|
||||
/// <summary>AACS volume identifier</summary>
|
||||
AACS_VolumeIdentifier = 33,
|
||||
/// <summary>AACS pre-recorded media serial number</summary>
|
||||
AACS_SerialNumber = 34,
|
||||
/// <summary>AACS media identifier</summary>
|
||||
AACS_MediaIdentifier = 35,
|
||||
/// <summary>Lead-in AACS media key block</summary>
|
||||
AACS_MKB = 36,
|
||||
/// <summary>AACS data keys</summary>
|
||||
AACS_DataKeys = 37,
|
||||
/// <summary>LBA extents flagged for bus encryption by AACS</summary>
|
||||
AACS_LBAExtents = 38,
|
||||
/// <summary>CPRM media key block in Lead-in</summary>
|
||||
AACS_CPRM_MKB = 39,
|
||||
/// <summary>Recognized layer formats in hybrid discs</summary>
|
||||
Hybrid_RecognizedLayers = 40,
|
||||
/// <summary>Disc write protection status</summary>
|
||||
MMC_WriteProtection = 41,
|
||||
/// <summary>Disc standard information</summary>
|
||||
MMC_DiscInformation = 42,
|
||||
/// <summary>Disc track resources information</summary>
|
||||
MMC_TrackResourcesInformation = 43,
|
||||
/// <summary>BD-R Pseudo-overwrite information</summary>
|
||||
MMC_POWResourcesInformation = 44,
|
||||
/// <summary>SCSI INQUIRY response</summary>
|
||||
SCSI_INQUIRY = 45,
|
||||
/// <summary>SCSI MODE PAGE 2Ah</summary>
|
||||
SCSI_MODEPAGE_2A = 46,
|
||||
/// <summary>ATA IDENTIFY DEVICE response</summary>
|
||||
ATA_IDENTIFY = 47,
|
||||
/// <summary>ATA IDENTIFY PACKET DEVICE response</summary>
|
||||
ATAPI_IDENTIFY = 48,
|
||||
/// <summary>PCMCIA/CardBus Card Information Structure</summary>
|
||||
PCMCIA_CIS = 49,
|
||||
/// <summary>SecureDigital CID</summary>
|
||||
SD_CID = 50,
|
||||
/// <summary>SecureDigital CSD</summary>
|
||||
SD_CSD = 51,
|
||||
/// <summary>SecureDigital SCR</summary>
|
||||
SD_SCR = 52,
|
||||
/// <summary>SecureDigital OCR</summary>
|
||||
SD_OCR = 53,
|
||||
/// <summary>MultiMediaCard CID</summary>
|
||||
MMC_CID = 54,
|
||||
/// <summary>MultiMediaCard CSD</summary>
|
||||
MMC_CSD = 55,
|
||||
/// <summary>MultiMediaCard OCR</summary>
|
||||
MMC_OCR = 56,
|
||||
/// <summary>MultiMediaCard Extended CSD</summary>
|
||||
MMC_ExtendedCSD = 57,
|
||||
/// <summary>Xbox Security Sector</summary>
|
||||
Xbox_SecuritySector = 58,
|
||||
/// <summary>
|
||||
/// On floppy disks, data in last cylinder usually in a different format that contains duplication or
|
||||
/// manufacturing information
|
||||
/// </summary>
|
||||
Floppy_LeadOut = 59,
|
||||
/// <summary>DVD Disc Control Blocks</summary>
|
||||
DCB = 60,
|
||||
/// <summary>Compact Disc First Track Pregap</summary>
|
||||
CD_FirstTrackPregap = 61,
|
||||
/// <summary>Compact Disc Lead-out</summary>
|
||||
CD_LeadOut = 62,
|
||||
/// <summary>SCSI MODE SENSE (6)</summary>
|
||||
SCSI_MODESENSE_6 = 63,
|
||||
/// <summary>SCSI MODE SENSE (10)</summary>
|
||||
SCSI_MODESENSE_10 = 64,
|
||||
/// <summary>USB descriptors</summary>
|
||||
USB_Descriptors = 65,
|
||||
/// <summary>XGD unlocked DMI</summary>
|
||||
Xbox_DMI = 66,
|
||||
/// <summary>XDG unlocked PFI</summary>
|
||||
Xbox_PFI = 67,
|
||||
/// <summary>Compact Disc Lead-in</summary>
|
||||
CD_LeadIn = 68,
|
||||
/// <summary>8 bytes response that seems to define type of MiniDisc</summary>
|
||||
MiniDiscType = 69,
|
||||
/// <summary>4 bytes response to vendor command D5h</summary>
|
||||
MiniDiscD5 = 70,
|
||||
/// <summary>User TOC, contains fragments, track names, and can be from 1 to 3 sectors of 2336 bytes</summary>
|
||||
MiniDiscUTOC = 71,
|
||||
/// <summary>Not entirely clear kind of TOC that only appears on MD-DATA discs</summary>
|
||||
MiniDiscDTOC = 72,
|
||||
/// <summary>Decrypted DVD disc key</summary>
|
||||
DVD_DiscKey_Decrypted = 73
|
||||
}
|
||||
|
||||
/// <summary>Enumeration of media types defined in CICM metadata</summary>
|
||||
public enum XmlMediaType : byte
|
||||
{
|
||||
/// <summary>Purely optical discs</summary>
|
||||
OpticalDisc = 0,
|
||||
/// <summary>Media that is physically block-based or abstracted like that</summary>
|
||||
BlockMedia = 1,
|
||||
/// <summary>Media that can be accessed by-byte or by-bit, like chips</summary>
|
||||
LinearMedia = 2,
|
||||
/// <summary>Media that can only store data when it is modulated to audio</summary>
|
||||
AudioMedia = 3
|
||||
}
|
||||
|
||||
/// <summary> CD flags bitmask</summary>
|
||||
[Flags]
|
||||
public enum CdFlags : byte
|
||||
{
|
||||
/// <summary>Track is quadraphonic.</summary>
|
||||
FourChannel = 0x08,
|
||||
/// <summary>Track is non-audio (data).</summary>
|
||||
DataTrack = 0x04,
|
||||
/// <summary>Track is copy protected.</summary>
|
||||
CopyPermitted = 0x02,
|
||||
/// <summary>Track has pre-emphasis.</summary>
|
||||
PreEmphasis = 0x01
|
||||
}
|
||||
|
||||
/// <summary>Status of a requested floppy sector</summary>
|
||||
[Flags]
|
||||
public enum FloppySectorStatus : byte
|
||||
{
|
||||
/// <summary>Both address mark and data checksums are correct.</summary>
|
||||
Correct = 0x01,
|
||||
/// <summary>Data checksum is incorrect.</summary>
|
||||
DataError = 0x02,
|
||||
/// <summary>Address mark checksum is incorrect.</summary>
|
||||
AddressMarkError = 0x04,
|
||||
/// <summary>There is another sector in the same track/head with same sector id.</summary>
|
||||
Duplicated = 0x08,
|
||||
/// <summary>Sector data section is not magnetized.</summary>
|
||||
Demagnetized = 0x10,
|
||||
/// <summary>Sector data section has a physically visible hole.</summary>
|
||||
Hole = 0x20,
|
||||
/// <summary>There is no address mark containing the requested sector id in the track/head.</summary>
|
||||
NotFound = 0x40
|
||||
}
|
||||
|
||||
/// <summary>Types of floppy disks</summary>
|
||||
public enum FloppyTypes : byte
|
||||
{
|
||||
/// <summary>8" floppy</summary>
|
||||
Floppy,
|
||||
/// <summary>5.25" floppy</summary>
|
||||
MiniFloppy,
|
||||
/// <summary>3.5" floppy</summary>
|
||||
MicroFloppy,
|
||||
/// <summary>3" floppy</summary>
|
||||
CompactFloppy,
|
||||
/// <summary>5.25" twiggy</summary>
|
||||
FileWare,
|
||||
/// <summary>2.5" quickdisk</summary>
|
||||
QuickDisk
|
||||
}
|
||||
|
||||
/// <summary>Enumeration of floppy densities</summary>
|
||||
public enum FloppyDensities : byte
|
||||
{
|
||||
/// <summary>Standard coercivity (about 300Oe as found in 8" and 5.25"-double-density disks).</summary>
|
||||
Standard,
|
||||
/// <summary>Double density coercivity (about 600Oe as found in 5.25" HD and 3.5" DD disks).</summary>
|
||||
Double,
|
||||
/// <summary>High density coercivity (about 700Oe as found in 3.5" HD disks).</summary>
|
||||
High,
|
||||
/// <summary>Extended density coercivity (about 750Oe as found in 3.5" ED disks).</summary>
|
||||
Extended
|
||||
}
|
||||
|
||||
/// <summary>Capabilities for optical media image formats</summary>
|
||||
[Flags]
|
||||
public enum OpticalImageCapabilities : ulong
|
||||
{
|
||||
/// <summary>Can store Red Book audio tracks?</summary>
|
||||
CanStoreAudioTracks = 0x01,
|
||||
/// <summary>Can store CD-V analogue video tracks?</summary>
|
||||
CanStoreVideoTracks = 0x02,
|
||||
/// <summary>Can store Yellow Book data tracks?</summary>
|
||||
CanStoreDataTracks = 0x03,
|
||||
/// <summary>Can store pregaps without needing to interpret the subchannel?</summary>
|
||||
CanStorePregaps = 0x04,
|
||||
/// <summary>Can store indexes without needing to interpret the subchannel?</summary>
|
||||
CanStoreIndexes = 0x08,
|
||||
/// <summary>Can store raw P to W subchannel data?</summary>
|
||||
CanStoreSubchannelRw = 0x10,
|
||||
/// <summary>Can store more than one session?</summary>
|
||||
CanStoreSessions = 0x20,
|
||||
/// <summary>Can store track ISRCs without needing to interpret the subchannel?</summary>
|
||||
CanStoreIsrc = 0x40,
|
||||
/// <summary>Can store Lead-In's CD-TEXT?</summary>
|
||||
CanStoreCdText = 0x80,
|
||||
/// <summary>Can store the MCN without needing to interpret the subchannel?</summary>
|
||||
CanStoreMcn = 0x100,
|
||||
/// <summary>Can store the whole 2352 bytes of a sector?</summary>
|
||||
CanStoreRawData = 0x200,
|
||||
/// <summary>Can store more than 1 session in media that is not CD based (DVD et al)?</summary>
|
||||
CanStoreNotCdSessions = 0x2000,
|
||||
/// <summary>Can store more than 1 track in media that is not CD based (DVD et al)?</summary>
|
||||
CanStoreNotCdTracks = 0x4000,
|
||||
|
||||
// TODO: Implement
|
||||
/// <summary>Can store scrambled data?</summary>
|
||||
CanStoreScrambledData = 0x400,
|
||||
/// <summary>Can store only the user area of a sector (2048, 2324, etc)?</summary>
|
||||
CanStoreCookedData = 0x800,
|
||||
/// <summary>Can store more than 1 track?</summary>
|
||||
CanStoreMultipleTracks = 0x1000
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ExtentsByte.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Extent helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides extents for byte types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Aaru.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>Implements extents for <see cref="byte" /></summary>
|
||||
public class ExtentsByte
|
||||
{
|
||||
List<Tuple<byte, byte>> _backend;
|
||||
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsByte() => _backend = new List<Tuple<byte, byte>>();
|
||||
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsByte(IEnumerable<Tuple<byte, byte>> list)
|
||||
{
|
||||
_backend = new List<Tuple<byte, byte>>();
|
||||
|
||||
// This ensure no overlapping extents are added on creation
|
||||
foreach(Tuple<byte, byte> t in list)
|
||||
Add(t.Item1, t.Item2);
|
||||
}
|
||||
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => _backend.Count;
|
||||
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(byte item)
|
||||
{
|
||||
Tuple<byte, byte> removeOne = null;
|
||||
Tuple<byte, byte> removeTwo = null;
|
||||
Tuple<byte, byte> itemToAdd = null;
|
||||
|
||||
for(int i = 0; i < _backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= _backend[i].Item1 &&
|
||||
item <= _backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == _backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i > 0 &&
|
||||
item == _backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = _backend[i - 1];
|
||||
itemToAdd = new Tuple<byte, byte>(_backend[i - 1].Item1, _backend[i].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<byte, byte>(item, _backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != _backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i < _backend.Count - 1 &&
|
||||
item == _backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = _backend[i + 1];
|
||||
itemToAdd = new Tuple<byte, byte>(_backend[i].Item1, _backend[i + 1].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<byte, byte>(_backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(itemToAdd != null)
|
||||
{
|
||||
_backend.Remove(removeOne);
|
||||
_backend.Remove(removeTwo);
|
||||
_backend.Add(itemToAdd);
|
||||
}
|
||||
else
|
||||
_backend.Add(new Tuple<byte, byte>(item, item));
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(byte start, byte end, bool run = false)
|
||||
{
|
||||
byte realEnd;
|
||||
|
||||
if(run)
|
||||
realEnd = (byte)(start + end - 1);
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(byte t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to search for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(byte item) => _backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => _backend.Clear();
|
||||
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(byte item)
|
||||
{
|
||||
Tuple<byte, byte> toRemove = null;
|
||||
Tuple<byte, byte> toAddOne = null;
|
||||
Tuple<byte, byte> toAddTwo = null;
|
||||
|
||||
foreach(Tuple<byte, byte> extent in _backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<byte, byte>(extent.Item1, (byte)(item - 1));
|
||||
toAddTwo = new Tuple<byte, byte>((byte)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<byte, byte>((byte)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<byte, byte>(extent.Item1, (byte)(item - 1));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
_backend.Remove(toRemove);
|
||||
|
||||
if(toAddOne != null)
|
||||
_backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
_backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<byte, byte>[] ToArray() => _backend.ToArray();
|
||||
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(byte item, out byte start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<byte, byte> extent in _backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ExtentsConverter.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : XML metadata.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Converts extents to/from XML.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>Converts extents</summary>
|
||||
public static class ExtentsConverter
|
||||
{
|
||||
/// <summary>Converts unsigned long integer extents into XML based extents</summary>
|
||||
/// <param name="extents">Extents</param>
|
||||
/// <returns>XML based extents</returns>
|
||||
public static ExtentType[] ToMetadata(ExtentsULong extents)
|
||||
{
|
||||
if(extents == null)
|
||||
return null;
|
||||
|
||||
Tuple<ulong, ulong>[] tuples = extents.ToArray();
|
||||
ExtentType[] array = new ExtentType[tuples.Length];
|
||||
|
||||
for(ulong i = 0; i < (ulong)array.LongLength; i++)
|
||||
array[i] = new ExtentType
|
||||
{
|
||||
Start = tuples[i].Item1,
|
||||
End = tuples[i].Item2
|
||||
};
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
/// <summary>Converts XML based extents into unsigned long integer extents</summary>
|
||||
/// <param name="extents">XML based extents</param>
|
||||
/// <returns>Extents</returns>
|
||||
public static ExtentsULong FromMetadata(ExtentType[] extents)
|
||||
{
|
||||
if(extents == null)
|
||||
return null;
|
||||
|
||||
List<Tuple<ulong, ulong>> tuples =
|
||||
extents.Select(extent => new Tuple<ulong, ulong>(extent.Start, extent.End)).ToList();
|
||||
|
||||
return new ExtentsULong(tuples);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ExtentsInt.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Extent helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides extents for int types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Aaru.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>Implements extents for <see cref="int" /></summary>
|
||||
public class ExtentsInt
|
||||
{
|
||||
List<Tuple<int, int>> _backend;
|
||||
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsInt() => _backend = new List<Tuple<int, int>>();
|
||||
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsInt(IEnumerable<Tuple<int, int>> list)
|
||||
{
|
||||
_backend = new List<Tuple<int, int>>();
|
||||
|
||||
// This ensure no overlapping extents are added on creation
|
||||
foreach(Tuple<int, int> t in list)
|
||||
Add(t.Item1, t.Item2);
|
||||
}
|
||||
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => _backend.Count;
|
||||
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(int item)
|
||||
{
|
||||
Tuple<int, int> removeOne = null;
|
||||
Tuple<int, int> removeTwo = null;
|
||||
Tuple<int, int> itemToAdd = null;
|
||||
|
||||
for(int i = 0; i < _backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= _backend[i].Item1 &&
|
||||
item <= _backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == _backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i > 0 &&
|
||||
item == _backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = _backend[i - 1];
|
||||
itemToAdd = new Tuple<int, int>(_backend[i - 1].Item1, _backend[i].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<int, int>(item, _backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != _backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i < _backend.Count - 1 &&
|
||||
item == _backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = _backend[i + 1];
|
||||
itemToAdd = new Tuple<int, int>(_backend[i].Item1, _backend[i + 1].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<int, int>(_backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(itemToAdd != null)
|
||||
{
|
||||
_backend.Remove(removeOne);
|
||||
_backend.Remove(removeTwo);
|
||||
_backend.Add(itemToAdd);
|
||||
}
|
||||
else
|
||||
_backend.Add(new Tuple<int, int>(item, item));
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(int start, int end, bool run = false)
|
||||
{
|
||||
int realEnd;
|
||||
|
||||
if(run)
|
||||
realEnd = start + end - 1;
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(int t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to search for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(int item) => _backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => _backend.Clear();
|
||||
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(int item)
|
||||
{
|
||||
Tuple<int, int> toRemove = null;
|
||||
Tuple<int, int> toAddOne = null;
|
||||
Tuple<int, int> toAddTwo = null;
|
||||
|
||||
foreach(Tuple<int, int> extent in _backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<int, int>(extent.Item1, item - 1);
|
||||
toAddTwo = new Tuple<int, int>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<int, int>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<int, int>(extent.Item1, item - 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
_backend.Remove(toRemove);
|
||||
|
||||
if(toAddOne != null)
|
||||
_backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
_backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<int, int>[] ToArray() => _backend.ToArray();
|
||||
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(int item, out int start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<int, int> extent in _backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ExtentsLong.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Extent helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides extents for long types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Aaru.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>Implements extents for <see cref="long" /></summary>
|
||||
public class ExtentsLong
|
||||
{
|
||||
List<Tuple<long, long>> _backend;
|
||||
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsLong() => _backend = new List<Tuple<long, long>>();
|
||||
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsLong(IEnumerable<Tuple<long, long>> list)
|
||||
{
|
||||
_backend = new List<Tuple<long, long>>();
|
||||
|
||||
// This ensure no overlapping extents are added on creation
|
||||
foreach(Tuple<long, long> t in list)
|
||||
Add(t.Item1, t.Item2);
|
||||
}
|
||||
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => _backend.Count;
|
||||
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(long item)
|
||||
{
|
||||
Tuple<long, long> removeOne = null;
|
||||
Tuple<long, long> removeTwo = null;
|
||||
Tuple<long, long> itemToAdd = null;
|
||||
|
||||
for(int i = 0; i < _backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= _backend[i].Item1 &&
|
||||
item <= _backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == _backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i > 0 &&
|
||||
item == _backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = _backend[i - 1];
|
||||
itemToAdd = new Tuple<long, long>(_backend[i - 1].Item1, _backend[i].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<long, long>(item, _backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != _backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i < _backend.Count - 1 &&
|
||||
item == _backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = _backend[i + 1];
|
||||
itemToAdd = new Tuple<long, long>(_backend[i].Item1, _backend[i + 1].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<long, long>(_backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(itemToAdd != null)
|
||||
{
|
||||
_backend.Remove(removeOne);
|
||||
_backend.Remove(removeTwo);
|
||||
_backend.Add(itemToAdd);
|
||||
}
|
||||
else
|
||||
_backend.Add(new Tuple<long, long>(item, item));
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(long start, long end, bool run = false)
|
||||
{
|
||||
long realEnd;
|
||||
|
||||
if(run)
|
||||
realEnd = start + end - 1;
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(long t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to search for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(long item) => _backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => _backend.Clear();
|
||||
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(long item)
|
||||
{
|
||||
Tuple<long, long> toRemove = null;
|
||||
Tuple<long, long> toAddOne = null;
|
||||
Tuple<long, long> toAddTwo = null;
|
||||
|
||||
foreach(Tuple<long, long> extent in _backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<long, long>(extent.Item1, item - 1);
|
||||
toAddTwo = new Tuple<long, long>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<long, long>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<long, long>(extent.Item1, item - 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
_backend.Remove(toRemove);
|
||||
|
||||
if(toAddOne != null)
|
||||
_backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
_backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<long, long>[] ToArray() => _backend.ToArray();
|
||||
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(long item, out long start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<long, long> extent in _backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,255 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ExtentsSByte.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Extent helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides extents for sbyte types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Aaru.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>Implements extents for <see cref="sbyte" /></summary>
|
||||
public class ExtentsSByte
|
||||
{
|
||||
List<Tuple<sbyte, sbyte>> _backend;
|
||||
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsSByte() => _backend = new List<Tuple<sbyte, sbyte>>();
|
||||
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsSByte(IEnumerable<Tuple<sbyte, sbyte>> list)
|
||||
{
|
||||
_backend = new List<Tuple<sbyte, sbyte>>();
|
||||
|
||||
// This ensure no overlapping extents are added on creation
|
||||
foreach(Tuple<sbyte, sbyte> t in list)
|
||||
Add(t.Item1, t.Item2);
|
||||
}
|
||||
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => _backend.Count;
|
||||
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(sbyte item)
|
||||
{
|
||||
Tuple<sbyte, sbyte> removeOne = null;
|
||||
Tuple<sbyte, sbyte> removeTwo = null;
|
||||
Tuple<sbyte, sbyte> itemToAdd = null;
|
||||
|
||||
for(int i = 0; i < _backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= _backend[i].Item1 &&
|
||||
item <= _backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == _backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i > 0 &&
|
||||
item == _backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = _backend[i - 1];
|
||||
itemToAdd = new Tuple<sbyte, sbyte>(_backend[i - 1].Item1, _backend[i].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<sbyte, sbyte>(item, _backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != _backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i < _backend.Count - 1 &&
|
||||
item == _backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = _backend[i + 1];
|
||||
itemToAdd = new Tuple<sbyte, sbyte>(_backend[i].Item1, _backend[i + 1].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<sbyte, sbyte>(_backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(itemToAdd != null)
|
||||
{
|
||||
_backend.Remove(removeOne);
|
||||
_backend.Remove(removeTwo);
|
||||
_backend.Add(itemToAdd);
|
||||
}
|
||||
else
|
||||
_backend.Add(new Tuple<sbyte, sbyte>(item, item));
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(sbyte start, sbyte end, bool run = false)
|
||||
{
|
||||
sbyte realEnd;
|
||||
|
||||
if(run)
|
||||
realEnd = (sbyte)(start + end - 1);
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(sbyte t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to search for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(sbyte item) => _backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => _backend.Clear();
|
||||
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(sbyte item)
|
||||
{
|
||||
Tuple<sbyte, sbyte> toRemove = null;
|
||||
Tuple<sbyte, sbyte> toAddOne = null;
|
||||
Tuple<sbyte, sbyte> toAddTwo = null;
|
||||
|
||||
foreach(Tuple<sbyte, sbyte> extent in _backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<sbyte, sbyte>(extent.Item1, (sbyte)(item - 1));
|
||||
toAddTwo = new Tuple<sbyte, sbyte>((sbyte)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<sbyte, sbyte>((sbyte)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<sbyte, sbyte>(extent.Item1, (sbyte)(item - 1));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
_backend.Remove(toRemove);
|
||||
|
||||
if(toAddOne != null)
|
||||
_backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
_backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<sbyte, sbyte>[] ToArray() => _backend.ToArray();
|
||||
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(sbyte item, out sbyte start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<sbyte, sbyte> extent in
|
||||
_backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,255 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ExtentsShort.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Extent helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides extents for short types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Aaru.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>Implements extents for <see cref="short" /></summary>
|
||||
public class ExtentsShort
|
||||
{
|
||||
List<Tuple<short, short>> _backend;
|
||||
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsShort() => _backend = new List<Tuple<short, short>>();
|
||||
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsShort(IEnumerable<Tuple<short, short>> list)
|
||||
{
|
||||
_backend = new List<Tuple<short, short>>();
|
||||
|
||||
// This ensure no overlapping extents are added on creation
|
||||
foreach(Tuple<short, short> t in list)
|
||||
Add(t.Item1, t.Item2);
|
||||
}
|
||||
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => _backend.Count;
|
||||
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(short item)
|
||||
{
|
||||
Tuple<short, short> removeOne = null;
|
||||
Tuple<short, short> removeTwo = null;
|
||||
Tuple<short, short> itemToAdd = null;
|
||||
|
||||
for(int i = 0; i < _backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= _backend[i].Item1 &&
|
||||
item <= _backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == _backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i > 0 &&
|
||||
item == _backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = _backend[i - 1];
|
||||
itemToAdd = new Tuple<short, short>(_backend[i - 1].Item1, _backend[i].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<short, short>(item, _backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != _backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i < _backend.Count - 1 &&
|
||||
item == _backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = _backend[i + 1];
|
||||
itemToAdd = new Tuple<short, short>(_backend[i].Item1, _backend[i + 1].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<short, short>(_backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(itemToAdd != null)
|
||||
{
|
||||
_backend.Remove(removeOne);
|
||||
_backend.Remove(removeTwo);
|
||||
_backend.Add(itemToAdd);
|
||||
}
|
||||
else
|
||||
_backend.Add(new Tuple<short, short>(item, item));
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(short start, short end, bool run = false)
|
||||
{
|
||||
short realEnd;
|
||||
|
||||
if(run)
|
||||
realEnd = (short)(start + end - 1);
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(short t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to search for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(short item) => _backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => _backend.Clear();
|
||||
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(short item)
|
||||
{
|
||||
Tuple<short, short> toRemove = null;
|
||||
Tuple<short, short> toAddOne = null;
|
||||
Tuple<short, short> toAddTwo = null;
|
||||
|
||||
foreach(Tuple<short, short> extent in _backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<short, short>(extent.Item1, (short)(item - 1));
|
||||
toAddTwo = new Tuple<short, short>((short)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<short, short>((short)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<short, short>(extent.Item1, (short)(item - 1));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
_backend.Remove(toRemove);
|
||||
|
||||
if(toAddOne != null)
|
||||
_backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
_backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<short, short>[] ToArray() => _backend.ToArray();
|
||||
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(short item, out short start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<short, short> extent in
|
||||
_backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ExtentsUInt.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Extent helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides extents for uint types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Aaru.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>Implements extents for <see cref="uint" /></summary>
|
||||
public class ExtentsUInt
|
||||
{
|
||||
List<Tuple<uint, uint>> _backend;
|
||||
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsUInt() => _backend = new List<Tuple<uint, uint>>();
|
||||
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsUInt(IEnumerable<Tuple<uint, uint>> list)
|
||||
{
|
||||
_backend = new List<Tuple<uint, uint>>();
|
||||
|
||||
// This ensure no overlapping extents are added on creation
|
||||
foreach(Tuple<uint, uint> t in list)
|
||||
Add(t.Item1, t.Item2);
|
||||
}
|
||||
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => _backend.Count;
|
||||
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(uint item)
|
||||
{
|
||||
Tuple<uint, uint> removeOne = null;
|
||||
Tuple<uint, uint> removeTwo = null;
|
||||
Tuple<uint, uint> itemToAdd = null;
|
||||
|
||||
for(int i = 0; i < _backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= _backend[i].Item1 &&
|
||||
item <= _backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == _backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i > 0 &&
|
||||
item == _backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = _backend[i - 1];
|
||||
itemToAdd = new Tuple<uint, uint>(_backend[i - 1].Item1, _backend[i].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<uint, uint>(item, _backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != _backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i < _backend.Count - 1 &&
|
||||
item == _backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = _backend[i + 1];
|
||||
itemToAdd = new Tuple<uint, uint>(_backend[i].Item1, _backend[i + 1].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<uint, uint>(_backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(itemToAdd != null)
|
||||
{
|
||||
_backend.Remove(removeOne);
|
||||
_backend.Remove(removeTwo);
|
||||
_backend.Add(itemToAdd);
|
||||
}
|
||||
else
|
||||
_backend.Add(new Tuple<uint, uint>(item, item));
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(uint start, uint end, bool run = false)
|
||||
{
|
||||
uint realEnd;
|
||||
|
||||
if(run)
|
||||
realEnd = start + end - 1;
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(uint t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to search for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(uint item) => _backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => _backend.Clear();
|
||||
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(uint item)
|
||||
{
|
||||
Tuple<uint, uint> toRemove = null;
|
||||
Tuple<uint, uint> toAddOne = null;
|
||||
Tuple<uint, uint> toAddTwo = null;
|
||||
|
||||
foreach(Tuple<uint, uint> extent in _backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<uint, uint>(extent.Item1, item - 1);
|
||||
toAddTwo = new Tuple<uint, uint>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<uint, uint>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<uint, uint>(extent.Item1, item - 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
_backend.Remove(toRemove);
|
||||
|
||||
if(toAddOne != null)
|
||||
_backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
_backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<uint, uint>[] ToArray() => _backend.ToArray();
|
||||
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(uint item, out uint start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<uint, uint> extent in _backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,255 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ExtentsULong.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Extent helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides extents for ulong types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Aaru.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>Implements extents for <see cref="ulong" /></summary>
|
||||
public class ExtentsULong
|
||||
{
|
||||
List<Tuple<ulong, ulong>> _backend;
|
||||
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsULong() => _backend = new List<Tuple<ulong, ulong>>();
|
||||
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsULong(IEnumerable<Tuple<ulong, ulong>> list)
|
||||
{
|
||||
_backend = new List<Tuple<ulong, ulong>>();
|
||||
|
||||
// This ensure no overlapping extents are added on creation
|
||||
foreach(Tuple<ulong, ulong> t in list)
|
||||
Add(t.Item1, t.Item2);
|
||||
}
|
||||
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => _backend.Count;
|
||||
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(ulong item)
|
||||
{
|
||||
Tuple<ulong, ulong> removeOne = null;
|
||||
Tuple<ulong, ulong> removeTwo = null;
|
||||
Tuple<ulong, ulong> itemToAdd = null;
|
||||
|
||||
for(int i = 0; i < _backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= _backend[i].Item1 &&
|
||||
item <= _backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == _backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i > 0 &&
|
||||
item == _backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = _backend[i - 1];
|
||||
itemToAdd = new Tuple<ulong, ulong>(_backend[i - 1].Item1, _backend[i].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<ulong, ulong>(item, _backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != _backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i < _backend.Count - 1 &&
|
||||
item == _backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = _backend[i + 1];
|
||||
itemToAdd = new Tuple<ulong, ulong>(_backend[i].Item1, _backend[i + 1].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<ulong, ulong>(_backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(itemToAdd != null)
|
||||
{
|
||||
_backend.Remove(removeOne);
|
||||
_backend.Remove(removeTwo);
|
||||
_backend.Add(itemToAdd);
|
||||
}
|
||||
else
|
||||
_backend.Add(new Tuple<ulong, ulong>(item, item));
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(ulong start, ulong end, bool run = false)
|
||||
{
|
||||
ulong realEnd;
|
||||
|
||||
if(run)
|
||||
realEnd = start + end - 1;
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(ulong t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to search for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(ulong item) => _backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => _backend.Clear();
|
||||
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(ulong item)
|
||||
{
|
||||
Tuple<ulong, ulong> toRemove = null;
|
||||
Tuple<ulong, ulong> toAddOne = null;
|
||||
Tuple<ulong, ulong> toAddTwo = null;
|
||||
|
||||
foreach(Tuple<ulong, ulong> extent in _backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<ulong, ulong>(extent.Item1, item - 1);
|
||||
toAddTwo = new Tuple<ulong, ulong>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<ulong, ulong>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<ulong, ulong>(extent.Item1, item - 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
_backend.Remove(toRemove);
|
||||
|
||||
if(toAddOne != null)
|
||||
_backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
_backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<ulong, ulong>[] ToArray() => _backend.ToArray();
|
||||
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(ulong item, out ulong start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<ulong, ulong> extent in
|
||||
_backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,255 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ExtentsUShort.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Extent helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides extents for ushort types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Aaru.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>Implements extents for <see cref="ushort" /></summary>
|
||||
public class ExtentsUShort
|
||||
{
|
||||
List<Tuple<ushort, ushort>> _backend;
|
||||
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsUShort() => _backend = new List<Tuple<ushort, ushort>>();
|
||||
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsUShort(IEnumerable<Tuple<ushort, ushort>> list)
|
||||
{
|
||||
_backend = new List<Tuple<ushort, ushort>>();
|
||||
|
||||
// This ensure no overlapping extents are added on creation
|
||||
foreach(Tuple<ushort, ushort> t in list)
|
||||
Add(t.Item1, t.Item2);
|
||||
}
|
||||
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => _backend.Count;
|
||||
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(ushort item)
|
||||
{
|
||||
Tuple<ushort, ushort> removeOne = null;
|
||||
Tuple<ushort, ushort> removeTwo = null;
|
||||
Tuple<ushort, ushort> itemToAdd = null;
|
||||
|
||||
for(int i = 0; i < _backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= _backend[i].Item1 &&
|
||||
item <= _backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == _backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i > 0 &&
|
||||
item == _backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = _backend[i - 1];
|
||||
itemToAdd = new Tuple<ushort, ushort>(_backend[i - 1].Item1, _backend[i].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<ushort, ushort>(item, _backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != _backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = _backend[i];
|
||||
|
||||
if(i < _backend.Count - 1 &&
|
||||
item == _backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = _backend[i + 1];
|
||||
itemToAdd = new Tuple<ushort, ushort>(_backend[i].Item1, _backend[i + 1].Item2);
|
||||
}
|
||||
else
|
||||
itemToAdd = new Tuple<ushort, ushort>(_backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(itemToAdd != null)
|
||||
{
|
||||
_backend.Remove(removeOne);
|
||||
_backend.Remove(removeTwo);
|
||||
_backend.Add(itemToAdd);
|
||||
}
|
||||
else
|
||||
_backend.Add(new Tuple<ushort, ushort>(item, item));
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(ushort start, ushort end, bool run = false)
|
||||
{
|
||||
ushort realEnd;
|
||||
|
||||
if(run)
|
||||
realEnd = (ushort)(start + end - 1);
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(ushort t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to search for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(ushort item) => _backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => _backend.Clear();
|
||||
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(ushort item)
|
||||
{
|
||||
Tuple<ushort, ushort> toRemove = null;
|
||||
Tuple<ushort, ushort> toAddOne = null;
|
||||
Tuple<ushort, ushort> toAddTwo = null;
|
||||
|
||||
foreach(Tuple<ushort, ushort> extent in _backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<ushort, ushort>(extent.Item1, (ushort)(item - 1));
|
||||
toAddTwo = new Tuple<ushort, ushort>((ushort)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<ushort, ushort>((ushort)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<ushort, ushort>(extent.Item1, (ushort)(item - 1));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
_backend.Remove(toRemove);
|
||||
|
||||
if(toAddOne != null)
|
||||
_backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
_backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
_backend = _backend.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<ushort, ushort>[] ToArray() => _backend.ToArray();
|
||||
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(ushort item, out ushort start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<ushort, ushort> extent in _backend.Where(extent => item >= extent.Item1 &&
|
||||
item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Filters.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Filters.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Enumerates all filters and instantiates the correct one.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.CommonTypes
|
||||
{
|
||||
/// <summary>Manages the known filters</summary>
|
||||
public sealed class FiltersList
|
||||
{
|
||||
/// <summary>List of known filters</summary>
|
||||
public readonly SortedDictionary<string, IFilter> Filters;
|
||||
|
||||
/// <summary>Fills the list of all known filters</summary>
|
||||
public FiltersList()
|
||||
{
|
||||
var assembly = Assembly.Load("Aaru.Filters");
|
||||
Filters = new SortedDictionary<string, IFilter>();
|
||||
|
||||
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IFilter))))
|
||||
try
|
||||
{
|
||||
var filter = (IFilter)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{});
|
||||
|
||||
if(filter != null &&
|
||||
!Filters.ContainsKey(filter.Name.ToLower()))
|
||||
Filters.Add(filter.Name.ToLower(), filter);
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine("Exception {0}", exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets the filter that allows to read the specified path</summary>
|
||||
/// <param name="path">Path</param>
|
||||
/// <returns>The filter that allows reading the specified path</returns>
|
||||
public IFilter GetFilter(string path)
|
||||
{
|
||||
IFilter noFilter = null;
|
||||
|
||||
foreach(IFilter filter in Filters.Values)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(filter.Id != new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
|
||||
{
|
||||
if(!filter.Identify(path))
|
||||
continue;
|
||||
|
||||
var foundFilter = (IFilter)filter.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{});
|
||||
|
||||
if(foundFilter?.Open(path) == ErrorNumber.NoError)
|
||||
return foundFilter;
|
||||
}
|
||||
else
|
||||
noFilter = filter;
|
||||
}
|
||||
catch(IOException)
|
||||
{
|
||||
// Ignore and continue
|
||||
}
|
||||
}
|
||||
|
||||
if(!noFilter?.Identify(path) == true)
|
||||
return null;
|
||||
|
||||
noFilter?.Open(path);
|
||||
|
||||
return noFilter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Geometry.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : CommonTypes.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Includes geometry for several medias.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace Aaru.CommonTypes
|
||||
{
|
||||
/// <summary>Handles CHS geometries</summary>
|
||||
public static class Geometry
|
||||
{
|
||||
/// <summary>List of known disk geometries</summary>
|
||||
public static readonly (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding
|
||||
encoding, bool variableSectorsPerTrack, MediaType type)[] KnownGeometries =
|
||||
{
|
||||
(32, 1, 8, 319, MediaEncoding.FM, false, MediaType.IBM23FD),
|
||||
(35, 1, 9, 256, MediaEncoding.FM, false, MediaType.ECMA_66),
|
||||
(35, 1, 13, 256, MediaEncoding.AppleGCR, false, MediaType.Apple32SS),
|
||||
(35, 1, 16, 256, MediaEncoding.AppleGCR, false, MediaType.Apple33SS),
|
||||
(35, 1, 19, 256, MediaEncoding.CommodoreGCR, false, MediaType.CBM_1540),
|
||||
(35, 2, 13, 256, MediaEncoding.AppleGCR, false, MediaType.Apple32DS),
|
||||
(35, 2, 16, 256, MediaEncoding.AppleGCR, false, MediaType.Apple33DS),
|
||||
(35, 2, 19, 256, MediaEncoding.CommodoreGCR, false, MediaType.CBM_1571),
|
||||
(40, 1, 8, 512, MediaEncoding.MFM, false, MediaType.DOS_525_SS_DD_8),
|
||||
(40, 1, 9, 512, MediaEncoding.MFM, false, MediaType.DOS_525_SS_DD_9),
|
||||
(40, 1, 10, 256, MediaEncoding.FM, false, MediaType.ACORN_525_SS_SD_40),
|
||||
(40, 1, 16, 256, MediaEncoding.MFM, false, MediaType.ACORN_525_SS_DD_40),
|
||||
(40, 1, 18, 128, MediaEncoding.FM, false, MediaType.ATARI_525_SD),
|
||||
(40, 1, 18, 256, MediaEncoding.MFM, false, MediaType.ATARI_525_DD),
|
||||
(40, 1, 19, 256, MediaEncoding.CommodoreGCR, false, MediaType.CBM_1540_Ext),
|
||||
(40, 1, 26, 128, MediaEncoding.MFM, false, MediaType.ATARI_525_ED),
|
||||
(40, 2, 8, 512, MediaEncoding.MFM, false, MediaType.DOS_525_DS_DD_8),
|
||||
(40, 2, 9, 512, MediaEncoding.MFM, false, MediaType.DOS_525_DS_DD_9),
|
||||
(40, 2, 16, 256, MediaEncoding.FM, false, MediaType.ECMA_70),
|
||||
(70, 2, 9, 512, MediaEncoding.MFM, false, MediaType.Apricot_35),
|
||||
(74, 1, 8, 512, MediaEncoding.FM, false, MediaType.IBM33FD_512),
|
||||
(74, 1, 15, 256, MediaEncoding.FM, false, MediaType.IBM33FD_256),
|
||||
(74, 1, 26, 128, MediaEncoding.FM, false, MediaType.IBM33FD_128),
|
||||
(74, 2, 8, 1024, MediaEncoding.MFM, false, MediaType.IBM53FD_1024),
|
||||
(74, 2, 15, 256, MediaEncoding.FM, false, MediaType.IBM43FD_256),
|
||||
(74, 2, 15, 512, MediaEncoding.MFM, false, MediaType.IBM53FD_512),
|
||||
(74, 2, 26, 128, MediaEncoding.FM, false, MediaType.IBM43FD_128),
|
||||
(74, 2, 26, 256, MediaEncoding.MFM, false, MediaType.IBM53FD_256),
|
||||
(77, 1, 26, 128, MediaEncoding.FM, false, MediaType.RX01),
|
||||
(77, 1, 26, 256, MediaEncoding.MFM, false, MediaType.RX02),
|
||||
(77, 2, 8, 1024, MediaEncoding.MFM, false, MediaType.NEC_525_HD),
|
||||
(77, 2, 15, 512, MediaEncoding.MFM, false, MediaType.ECMA_99_15),
|
||||
(77, 2, 26, 128, MediaEncoding.FM, false, MediaType.NEC_8_SD),
|
||||
(77, 2, 26, 256, MediaEncoding.MFM, false, MediaType.RX03),
|
||||
(80, 1, 8, 512, MediaEncoding.MFM, false, MediaType.DOS_35_SS_DD_8),
|
||||
(80, 1, 9, 512, MediaEncoding.MFM, false, MediaType.DOS_35_SS_DD_9),
|
||||
(80, 1, 10, 256, MediaEncoding.FM, false, MediaType.ACORN_525_SS_SD_80),
|
||||
(80, 1, 10, 512, MediaEncoding.AppleGCR, true, MediaType.AppleSonySS),
|
||||
(80, 1, 10, 512, MediaEncoding.MFM, false, MediaType.RX50),
|
||||
(80, 1, 11, 512, MediaEncoding.MFM, false, MediaType.ATARI_35_SS_DD_11),
|
||||
(80, 1, 16, 256, MediaEncoding.MFM, false, MediaType.ACORN_525_SS_DD_80),
|
||||
(80, 2, 5, 1024, MediaEncoding.MFM, false, MediaType.ACORN_35_DS_DD),
|
||||
(80, 2, 8, 512, MediaEncoding.MFM, false, MediaType.DOS_35_DS_DD_8),
|
||||
(80, 2, 9, 512, MediaEncoding.MFM, false, MediaType.DOS_35_DS_DD_9),
|
||||
(80, 2, 10, 512, MediaEncoding.AppleGCR, true, MediaType.AppleSonyDS),
|
||||
(80, 2, 10, 512, MediaEncoding.MFM, false, MediaType.CBM_35_DD),
|
||||
(80, 2, 10, 1024, MediaEncoding.MFM, false, MediaType.ACORN_35_DS_HD),
|
||||
(80, 2, 11, 512, MediaEncoding.MFM, false, MediaType.CBM_AMIGA_35_DD),
|
||||
(80, 2, 15, 512, MediaEncoding.MFM, false, MediaType.DOS_525_HD),
|
||||
(80, 2, 16, 256, MediaEncoding.FM, false, MediaType.ECMA_78),
|
||||
(80, 2, 16, 256, MediaEncoding.MFM, false, MediaType.ACORN_525_DS_DD),
|
||||
(80, 2, 18, 512, MediaEncoding.MFM, false, MediaType.DOS_35_HD),
|
||||
(80, 2, 19, 512, MediaEncoding.MFM, false, MediaType.XDF_525),
|
||||
(80, 2, 21, 512, MediaEncoding.MFM, false, MediaType.DMF),
|
||||
(80, 2, 22, 512, MediaEncoding.MFM, false, MediaType.CBM_AMIGA_35_HD),
|
||||
(80, 2, 23, 512, MediaEncoding.MFM, false, MediaType.XDF_35),
|
||||
(80, 2, 36, 512, MediaEncoding.MFM, false, MediaType.DOS_35_ED),
|
||||
(82, 2, 10, 512, MediaEncoding.MFM, false, MediaType.FDFORMAT_35_DD),
|
||||
(82, 2, 17, 512, MediaEncoding.MFM, false, MediaType.FDFORMAT_525_HD),
|
||||
(82, 2, 21, 512, MediaEncoding.MFM, false, MediaType.FDFORMAT_35_HD),
|
||||
(240, 2, 38, 512, MediaEncoding.MFM, false, MediaType.NEC_35_TD),
|
||||
(753, 2, 27, 512, MediaEncoding.MFM, false, MediaType.Floptical),
|
||||
|
||||
// Following ones are what the device itself report, not the physical geometry
|
||||
(154, 16, 32, 512, MediaEncoding.MFM, false, MediaType.PocketZip),
|
||||
(262, 32, 56, 512, MediaEncoding.MFM, false, MediaType.LS240),
|
||||
(963, 8, 32, 512, MediaEncoding.MFM, false, MediaType.LS120),
|
||||
(1021, 64, 32, 512, MediaEncoding.MFM, false, MediaType.Jaz),
|
||||
(1024, 2, 32, 512, MediaEncoding.MFM, false, MediaType.FD32MB)
|
||||
};
|
||||
|
||||
/// <summary>Gets the media type for a given geometry</summary>
|
||||
/// <param name="geometry">Geometry</param>
|
||||
/// <returns>Media type</returns>
|
||||
public static MediaType GetMediaType(
|
||||
(ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding, bool
|
||||
variableSectorsPerTrack) geometry) => (from geom in KnownGeometries
|
||||
where geom.cylinders == geometry.cylinders &&
|
||||
geom.heads == geometry.heads &&
|
||||
geom.sectorsPerTrack == geometry.sectorsPerTrack &&
|
||||
geom.bytesPerSector == geometry.bytesPerSector &&
|
||||
geom.encoding == geometry.encoding &&
|
||||
geom.variableSectorsPerTrack ==
|
||||
geometry.variableSectorsPerTrack select geom.type).
|
||||
FirstOrDefault();
|
||||
|
||||
/// <summary>Gets the geometry for a given media type</summary>
|
||||
/// <param name="mediaType">Media type</param>
|
||||
/// <returns>Geometry</returns>
|
||||
public static (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding
|
||||
, bool variableSectorsPerTrack, MediaType type) GetGeometry(MediaType mediaType) =>
|
||||
(from geom in KnownGeometries where geom.type == mediaType select geom).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IArchive.cs
|
||||
// Author(s) : Michael Drüing <michael@drueing.de>
|
||||
//
|
||||
// Component : Archives.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines the interface for implementing archive plugins.
|
||||
//
|
||||
// --[ 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 © 2018-2019 Michael Drüing
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>Supported archive features</summary>
|
||||
[Flags]
|
||||
public enum ArchiveSupportedFeature : uint
|
||||
{
|
||||
/// <summary>The archive supports filenames for its entries. If this flag is not set, files can only be accessed by number.</summary>
|
||||
SupportsFilenames = 1 << 0,
|
||||
/// <summary>
|
||||
/// The archive supports compression. If this flag is not set, compressed and uncompressed lengths are always the
|
||||
/// same.
|
||||
/// </summary>
|
||||
SupportsCompression = 1 << 1,
|
||||
/// <summary>
|
||||
/// The archive supports subdirectories. If this flag is not set, all filenames are guaranteed to not contain any
|
||||
/// "/" character.
|
||||
/// </summary>
|
||||
SupportsSubdirectories = 1 << 2,
|
||||
/// <summary>
|
||||
/// The archive supports explicit entries for directories (like Zip, for example). If this flag is not set,
|
||||
/// directories are implicit by the relative name of the files.
|
||||
/// </summary>
|
||||
HasExplicitDirectories = 1 << 3,
|
||||
/// <summary>The archive stores a timestamp with each entry if this flag is set.</summary>
|
||||
HasEntryTimestamp = 1 << 4,
|
||||
/// <summary>If this flag is set, individual files or the whole archive might be encrypted or password-protected.</summary>
|
||||
SupportsProtection = 1 << 5, // TODO: not implemented yet
|
||||
|
||||
/// <summary>If this flag is set, the archive supports returning extended attributes (Xattrs) for each entry.</summary>
|
||||
SupportsXAttrs = 1 << 6
|
||||
}
|
||||
|
||||
/// <summary>Defines the interface to handle an archive (e.g. ZIP, WAD, etc)</summary>
|
||||
public interface IArchive
|
||||
{
|
||||
/// <summary>Descriptive name of the plugin</summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>Unique UUID of the plugin</summary>
|
||||
Guid Id { get; }
|
||||
|
||||
/// <summary>Identifies if the specified path contains data recognizable by this archive instance</summary>
|
||||
/// <param name="path">Path.</param>
|
||||
bool Identify(string path);
|
||||
|
||||
/// <summary>Identifies if the specified stream contains data recognizable by this archive instance</summary>
|
||||
/// <param name="stream">Stream.</param>
|
||||
bool Identify(Stream stream);
|
||||
|
||||
/// <summary>Identifies if the specified buffer contains data recognizable by this archive instance</summary>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
bool Identify(byte[] buffer);
|
||||
|
||||
/// <summary>Opens the specified path with this archive instance</summary>
|
||||
/// <param name="path">Path.</param>
|
||||
ErrorNumber Open(string path);
|
||||
|
||||
/// <summary>Opens the specified stream with this archive instance</summary>
|
||||
/// <param name="stream">Stream.</param>
|
||||
ErrorNumber Open(Stream stream);
|
||||
|
||||
/// <summary>Opens the specified buffer with this archive instance</summary>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
ErrorNumber Open(byte[] buffer);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the archive has a file/stream/buffer currently opened and no
|
||||
/// <see cref="M:Aaru.Filters.Filter.Close" /> has been issued.
|
||||
/// </summary>
|
||||
bool IsOpened();
|
||||
|
||||
/// <summary>Closes all opened streams.</summary>
|
||||
void Close();
|
||||
|
||||
/// <summary>Return a bitfield indicating the features supported by this archive type.</summary>
|
||||
/// <returns>The <c>ArchiveSupportedFeature</c> bitfield.</returns>
|
||||
/// <remarks>
|
||||
/// This should be a constant, tied to the archive type, not to the particular features used by the
|
||||
/// currently-opened archive file.
|
||||
/// </remarks>
|
||||
ArchiveSupportedFeature GetArchiveFeatures();
|
||||
|
||||
/// <summary>Gets the number of entries (i.e. files) that are contained in this archive.</summary>
|
||||
/// <remarks>
|
||||
/// Entries in this context can also mean directories or volume labels, for some types of archives that store
|
||||
/// these explicitly. Do not rely on all entries being regular files!
|
||||
/// </remarks>
|
||||
/// <returns>The number of files.</returns>
|
||||
int GetNumberOfEntries();
|
||||
|
||||
/// <summary>Gets the file name (and path) of the given entry in the archive.</summary>
|
||||
/// <remarks>
|
||||
/// The path components are separated by a forward slash "/". <br /> The path should not start with a leading
|
||||
/// slash (i.e. it should be relative, not absolute).
|
||||
/// </remarks>
|
||||
/// <seealso cref="Stat(int)" />
|
||||
/// <param name="entryNumber">The entry in the archive for which to return the file name.</param>
|
||||
/// <returns>The file name, with (relative) path</returns>
|
||||
string GetFilename(int entryNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the entry number for a particular file path in the archive. <c>fileName</c> is the relative path of the
|
||||
/// file in the archive. If the file cannot be found, -1 is returned.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The path should be relative (no leading slash), using regular slashes as path separator, and be normalized,
|
||||
/// i.e. no "foo//bar" or "foo/../bar" path components.
|
||||
/// </remarks>
|
||||
/// <param name="fileName">The relative path for which to get the entry number.</param>
|
||||
/// <param name="caseInsensitiveMatch">If set, do a case insensitive matching and return the first file that matches.</param>
|
||||
/// <returns>The number of the entry corresponding to the given path, or -1 if the path does not exist.</returns>
|
||||
int GetEntryNumber(string fileName, bool caseInsensitiveMatch);
|
||||
|
||||
/// <summary>Gets the (compressed) size of the given entry.</summary>
|
||||
/// <param name="entryNumber">The entry for which to get the compressed size.</param>
|
||||
/// <returns>The compressed size of the entry, or 0 if the entry is not a regular file.</returns>
|
||||
/// <remarks>The return value is equal to the return value of <c>GetUncompressedSize()</c> if the file is not compressed.</remarks>
|
||||
/// <seealso cref="GetUncompressedSize(int)" />
|
||||
long GetCompressedSize(int entryNumber);
|
||||
|
||||
/// <summary>Gets the uncompressed size of the given entry.</summary>
|
||||
/// <param name="entryNumber">The entry for which to get the uncompressed size.</param>
|
||||
/// <returns>The uncompressed size of the entry, or 0 if the entry is not a regular file.</returns>
|
||||
/// <remarks>The return value is equal to the return value of <c>GetCompressedSize()</c> if the file is not compressed.</remarks>
|
||||
/// <seealso cref="GetCompressedSize(int)" />
|
||||
long GetUncompressedSize(int entryNumber);
|
||||
|
||||
/// <summary>Gets the attributes of a file or directory.</summary>
|
||||
/// <seealso cref="Stat(int)" />
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="entryNumber">The entry in the archive for which to retrieve the attributes.</param>
|
||||
/// <returns>File attributes, or zero if the archive does not support attributes.</returns>
|
||||
FileAttributes GetAttributes(int entryNumber);
|
||||
|
||||
/// <summary>Lists all extended attributes, alternate data streams and forks of the given file.</summary>
|
||||
/// <param name="entryNumber">The entry in the archive for which to retrieve the list of attributes.</param>
|
||||
/// <returns>List of extended attributes, alternate data streams and forks.</returns>
|
||||
List<string> GetXAttrs(int entryNumber);
|
||||
|
||||
/// <summary>Reads an extended attribute, alternate data stream or fork from the given file.</summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="entryNumber">The entry in the archive for which to retrieve the XAttr.</param>
|
||||
/// <param name="xattr">Extended attribute, alternate data stream or fork name.</param>
|
||||
/// <returns>Buffer with the XAttr data.</returns>
|
||||
ErrorNumber GetXattr(int entryNumber, string xattr, out byte[] buffer);
|
||||
|
||||
/// <summary>Gets information about an entry in the archive.</summary>
|
||||
/// <remarks>Note that some of the data might be incomplete or not available at all, depending on the type of archive.</remarks>
|
||||
/// <seealso cref="GetAttributes(int)" />
|
||||
/// <seealso cref="GetFilename(int)" />
|
||||
/// <param name="entryNumber">The entry int he archive for which to get the information</param>
|
||||
/// <returns>The available information about the entry in the archive</returns>
|
||||
FileSystemInfo Stat(int entryNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Filter for the given entry. It will return <c>null</c> if the entry in question is not a regular
|
||||
/// file (i.e. directory, volume label, etc.)
|
||||
/// </summary>
|
||||
/// <param name="entryNumber">The entry for which the Filter should be returned.</param>
|
||||
/// <returns>The Filter for the given entry.</returns>
|
||||
IFilter GetEntry(int entryNumber);
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IChecksum.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides an interface for implementing checksums and hashes.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>Defines the interface to implement a checksum or hashing algorithm</summary>
|
||||
public interface IChecksum
|
||||
{
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of buffer to hash.</param>
|
||||
void Update(byte[] data, uint len);
|
||||
|
||||
/// <summary>Updates the hash with data.</summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
void Update(byte[] data);
|
||||
|
||||
/// <summary>Returns a byte array of the hash value.</summary>
|
||||
byte[] Final();
|
||||
|
||||
/// <summary>Returns a hexadecimal representation of the hash value.</summary>
|
||||
string End();
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IFilesystem.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Filesystem plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Interface for filesystem plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>Interface to implement filesystem plugins.</summary>
|
||||
public interface IFilesystem
|
||||
{
|
||||
/// <summary>Defines the encoding used to interpret strings in the filesystem</summary>
|
||||
Encoding Encoding { get; }
|
||||
/// <summary>Plugin name.</summary>
|
||||
string Name { get; }
|
||||
/// <summary>Plugin UUID.</summary>
|
||||
Guid Id { get; }
|
||||
/// <summary>Information about the filesystem as expected by CICM Metadata XML</summary>
|
||||
/// <value>Information about the filesystem as expected by CICM Metadata XML</value>
|
||||
FileSystemType XmlFsType { get; }
|
||||
/// <summary>Plugin author</summary>
|
||||
string Author { get; }
|
||||
|
||||
/// <summary>Identifies the filesystem in the specified LBA</summary>
|
||||
/// <param name="imagePlugin">Disk image.</param>
|
||||
/// <param name="partition">Partition.</param>
|
||||
/// <returns><c>true</c>, if the filesystem is recognized, <c>false</c> otherwise.</returns>
|
||||
bool Identify(IMediaImage imagePlugin, Partition partition);
|
||||
|
||||
/// <summary>Gets information about the identified filesystem.</summary>
|
||||
/// <param name="imagePlugin">Disk image.</param>
|
||||
/// <param name="partition">Partition.</param>
|
||||
/// <param name="information">Filesystem information.</param>
|
||||
/// <param name="encoding">Which encoding to use for this filesystem.</param>
|
||||
void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding);
|
||||
}
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IFilter.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Filters.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines the interface for a Filter.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a filter, that is, a transformation of the data from a file, like, for example, a compressor (e.g.
|
||||
/// GZIP), or a container (e.g. AppleDouble)
|
||||
/// </summary>
|
||||
public interface IFilter
|
||||
{
|
||||
/// <summary>Descriptive name of the plugin</summary>
|
||||
string Name { get; }
|
||||
/// <summary>Unique UUID of the plugin</summary>
|
||||
Guid Id { get; }
|
||||
/// <summary>Plugin author</summary>
|
||||
string Author { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path used to open this filter.<br /> UNIX: /path/to/archive.zip/path/to/file.bin =>
|
||||
/// /path/to/archive.zip/path/to/file.bin <br /> Windows: C:\path\to\archive.zip\path\to\file.bin =>
|
||||
/// C:\path\to\archive.zip\path\to\file.bin
|
||||
/// </summary>
|
||||
/// <returns>Path used to open this filter.</returns>
|
||||
string BasePath { get; }
|
||||
|
||||
/// <summary>Gets creation time of file referenced by this filter.</summary>
|
||||
/// <returns>The creation time.</returns>
|
||||
DateTime CreationTime { get; }
|
||||
|
||||
/// <summary>Gets length of this filter's data fork.</summary>
|
||||
/// <returns>The data fork length.</returns>
|
||||
long DataForkLength { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the filename for the file referenced by this filter.<br /> UNIX: /path/to/archive.zip/path/to/file.bin =
|
||||
/// > file.bin <br /> Windows: C:\path\to\archive.zip\path\to\file.bin => file.bin
|
||||
/// </summary>
|
||||
/// <returns>The filename.</returns>
|
||||
string Filename { get; }
|
||||
|
||||
/// <summary>Gets last write time of file referenced by this filter.</summary>
|
||||
/// <returns>The last write time.</returns>
|
||||
DateTime LastWriteTime { get; }
|
||||
|
||||
/// <summary>Gets length of file referenced by ths filter.</summary>
|
||||
/// <returns>The length.</returns>
|
||||
long Length { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets full path to file referenced by this filter. If it's an archive, it's the path inside the archive.<br />
|
||||
/// UNIX: /path/to/archive.zip/path/to/file.bin => /path/to/file.bin <br /> Windows:
|
||||
/// C:\path\to\archive.zip\path\to\file.bin => \path\to\file.bin
|
||||
/// </summary>
|
||||
/// <returns>The path.</returns>
|
||||
string Path { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets path to parent folder to the file referenced by this filter. If it's an archive, it's the full path to
|
||||
/// the archive itself.<br /> UNIX: /path/to/archive.zip/path/to/file.bin => /path/to/archive.zip <br /> Windows:
|
||||
/// C:\path\to\archive.zip\path\to\file.bin => C:\path\to\archive.zip
|
||||
/// </summary>
|
||||
/// <returns>The parent folder.</returns>
|
||||
string ParentFolder { get; }
|
||||
|
||||
/// <summary>Gets length of this filter's resource fork.</summary>
|
||||
/// <returns>The resource fork length.</returns>
|
||||
long ResourceForkLength { get; }
|
||||
|
||||
/// <summary>Returns true if the file referenced by this filter has a resource fork</summary>
|
||||
bool HasResourceFork { get; }
|
||||
|
||||
/// <summary>Closes all opened streams.</summary>
|
||||
void Close();
|
||||
|
||||
/// <summary>Gets a stream to access the data fork contents.</summary>
|
||||
/// <returns>The data fork stream.</returns>
|
||||
Stream GetDataForkStream();
|
||||
|
||||
/// <summary>Gets a stream to access the resource fork contents.</summary>
|
||||
/// <returns>The resource fork stream.</returns>
|
||||
Stream GetResourceForkStream();
|
||||
|
||||
/// <summary>Identifies if the specified path contains data recognizable by this filter instance</summary>
|
||||
/// <param name="path">Path.</param>
|
||||
bool Identify(string path);
|
||||
|
||||
/// <summary>Identifies if the specified stream contains data recognizable by this filter instance</summary>
|
||||
/// <param name="stream">Stream.</param>
|
||||
bool Identify(Stream stream);
|
||||
|
||||
/// <summary>Identifies if the specified buffer contains data recognizable by this filter instance</summary>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
bool Identify(byte[] buffer);
|
||||
|
||||
/// <summary>Opens the specified path with this filter instance</summary>
|
||||
/// <param name="path">Path.</param>
|
||||
ErrorNumber Open(string path);
|
||||
|
||||
/// <summary>Opens the specified stream with this filter instance</summary>
|
||||
/// <param name="stream">Stream.</param>
|
||||
ErrorNumber Open(Stream stream);
|
||||
|
||||
/// <summary>Opens the specified buffer with this filter instance</summary>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
ErrorNumber Open(byte[] buffer);
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IFloppyImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines the interface to be implemented by floppy image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Abstract class to implement disk image reading plugins that can contain floppy images. This interface is
|
||||
/// needed because floppy formatting characteristics are not necesarily compatible with the whole. LBA-oriented
|
||||
/// interface is defined by <see cref="T:Aaru.CommonTypes.Interfaces.IMediaImage" />. All data returned by these
|
||||
/// methods is already decoded from its corresponding bitstream.
|
||||
/// </summary>
|
||||
public interface IFloppyImage : IMediaImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Floppy info, contains information about physical characteristics of floppy, like size, bitrate, track density,
|
||||
/// etc...
|
||||
/// </summary>
|
||||
FloppyInfo FloppyInfo { get; }
|
||||
|
||||
/// <summary>Reads a sector's user data.</summary>
|
||||
/// <returns>
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Duplicated" /> one of the duplicates is returned
|
||||
/// randomly. If <see cref="status" /> is <see cref="FloppySectorStatus.Demagnetized" /> or
|
||||
/// <see cref="FloppySectorStatus.Hole" /> random data is returned. If <see cref="status" /> is
|
||||
/// <see cref="FloppySectorStatus.NotFound" /> <c>null</c> is returned. Otherwise, whatever is in the sector is
|
||||
/// returned.
|
||||
/// </returns>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <param name="sector">Logical sector ID.</param>
|
||||
/// <param name="status">Status of request.</param>
|
||||
ErrorNumber ReadSector(ushort track, byte head, ushort sector, out FloppySectorStatus status,
|
||||
out byte[] buffer);
|
||||
|
||||
/// <summary>Reads a sector's tag.</summary>
|
||||
/// <returns>
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Duplicated" /> one of the duplicates is returned
|
||||
/// randomly. If <see cref="status" /> is <see cref="FloppySectorStatus.Demagnetized" /> or
|
||||
/// <see cref="FloppySectorStatus.Hole" /> random data is returned. If <see cref="status" /> is
|
||||
/// <see cref="FloppySectorStatus.NotFound" /> <c>null</c> is returned. Otherwise, whatever tag is in the sector is
|
||||
/// returned.
|
||||
/// </returns>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <param name="sector">Logical sector ID.</param>
|
||||
/// <param name="status">Status of request.</param>
|
||||
/// <param name="tag">Sector tag</param>
|
||||
ErrorNumber ReadSectorTag(ushort track, byte head, ushort sector, out FloppySectorStatus status,
|
||||
SectorTagType tag, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads a whole track. It includes all gaps, address marks, sectors data, etc.</summary>
|
||||
/// <returns>The track data.</returns>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
ErrorNumber ReadTrack(ushort track, byte head, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads a sector's data including all tags, address mark, and so, in a format dependent of represented media.</summary>
|
||||
/// <returns>
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Duplicated" /> one of the duplicates is returned
|
||||
/// randomly. If <see cref="status" /> is <see cref="FloppySectorStatus.Demagnetized" /> or
|
||||
/// <see cref="FloppySectorStatus.Hole" /> random data is returned. If <see cref="status" /> is
|
||||
/// <see cref="FloppySectorStatus.NotFound" /> <c>null</c> is returned. Otherwise, whatever is in the sector is
|
||||
/// returned.
|
||||
/// </returns>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <param name="sector">Logical sector ID.</param>
|
||||
/// <param name="status">Status of request.</param>
|
||||
ErrorNumber ReadSectorLong(ushort track, byte head, ushort sector, out FloppySectorStatus status,
|
||||
out byte[] buffer);
|
||||
|
||||
/// <summary>Verifies a track.</summary>
|
||||
/// <returns>True if correct, false if incorrect, null if uncheckable.</returns>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
bool? VerifyTrack(ushort track, byte head);
|
||||
|
||||
/// <summary>Verifies a sector, relative to track.</summary>
|
||||
/// <returns>True if correct, false if incorrect, null if uncheckable.</returns>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <param name="sector">Logical sector ID.</param>
|
||||
bool? VerifySector(ushort track, byte head, ushort sector);
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IMediaImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines interface to be implemented by block addressable disk image
|
||||
// plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>Abstract class to implement disk image reading plugins.</summary>
|
||||
public interface IMediaImage
|
||||
{
|
||||
/// <summary>Image information</summary>
|
||||
ImageInfo Info { get; }
|
||||
/// <summary>Plugin name.</summary>
|
||||
string Name { get; }
|
||||
/// <summary>Plugin UUID.</summary>
|
||||
Guid Id { get; }
|
||||
/// <summary>Plugin author</summary>
|
||||
string Author { get; }
|
||||
/// <summary>Gets the image format.</summary>
|
||||
/// <value>The image format.</value>
|
||||
string Format { get; }
|
||||
/// <summary>List of dump hardware used to create the image from real media</summary>
|
||||
List<DumpHardwareType> DumpHardware { get; }
|
||||
/// <summary>Gets the CICM XML metadata for the image</summary>
|
||||
CICMMetadataType CicmMetadata { get; }
|
||||
|
||||
/// <summary>Identifies the image.</summary>
|
||||
/// <returns><c>true</c>, if image was identified, <c>false</c> otherwise.</returns>
|
||||
/// <param name="imageFilter">Image filter.</param>
|
||||
bool Identify(IFilter imageFilter);
|
||||
|
||||
/// <summary>Opens the image.</summary>
|
||||
/// <returns><c>true</c>, if image was opened, <c>false</c> otherwise.</returns>
|
||||
/// <param name="imageFilter">Image filter.</param>
|
||||
ErrorNumber Open(IFilter imageFilter);
|
||||
|
||||
/// <summary>Reads a disk tag.</summary>
|
||||
/// <returns></returns>
|
||||
/// <param name="tag">Tag type to read.</param>
|
||||
/// <param name="buffer">Disk tag</param>
|
||||
ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads a sector's user data.</summary>
|
||||
/// <returns>The sector's user data.</returns>
|
||||
/// <param name="sectorAddress">Sector address (LBA).</param>
|
||||
/// <param name="buffer"></param>
|
||||
ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads a sector's tag.</summary>
|
||||
/// <returns>The sector's tag.</returns>
|
||||
/// <param name="sectorAddress">Sector address (LBA).</param>
|
||||
/// <param name="tag">Tag type.</param>
|
||||
/// <param name="buffer"></param>
|
||||
ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads user data from several sectors.</summary>
|
||||
/// <returns>The sectors user data.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="buffer"></param>
|
||||
ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads tag from several sectors.</summary>
|
||||
/// <returns>The sectors tag.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="tag">Tag type.</param>
|
||||
/// <param name="buffer"></param>
|
||||
ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads a complete sector (user data + all tags).</summary>
|
||||
/// <returns>The complete sector. Format depends on disk type.</returns>
|
||||
/// <param name="sectorAddress">Sector address (LBA).</param>
|
||||
/// <param name="buffer"></param>
|
||||
ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads several complete sector (user data + all tags).</summary>
|
||||
/// <returns>The complete sectors. Format depends on disk type.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="buffer"></param>
|
||||
ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer);
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IOpticalMediaImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines the interface to be implemented by optical disc image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <inheritdoc cref="IMediaImage" />
|
||||
/// <summary>Abstract class to implement disk image reading plugins.</summary>
|
||||
public interface IOpticalMediaImage : IMediaImage, IPartitionableMediaImage, IVerifiableSectorsImage
|
||||
{
|
||||
/// <summary>Gets the disc track extents (start, length).</summary>
|
||||
/// <value>The track extents.</value>
|
||||
List<Track> Tracks { get; }
|
||||
/// <summary>Gets the sessions (optical discs only).</summary>
|
||||
/// <value>The sessions.</value>
|
||||
List<Session> Sessions { get; }
|
||||
|
||||
/// <summary>Reads a sector's user data, relative to track.</summary>
|
||||
/// <returns>The sector's user data.</returns>
|
||||
/// <param name="sectorAddress">Sector address (relative LBA).</param>
|
||||
/// <param name="track">Track.</param>
|
||||
/// <param name="buffer"></param>
|
||||
ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads a sector's tag, relative to track.</summary>
|
||||
/// <returns>The sector's tag.</returns>
|
||||
/// <param name="sectorAddress">Sector address (relative LBA).</param>
|
||||
/// <param name="track">Track.</param>
|
||||
/// <param name="tag">Tag type.</param>
|
||||
/// <param name="buffer"></param>
|
||||
ErrorNumber ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads user data from several sectors, relative to track.</summary>
|
||||
/// <returns>The sectors user data.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (relative LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="track">Track.</param>
|
||||
/// <param name="buffer"></param>
|
||||
ErrorNumber ReadSectors(ulong sectorAddress, uint length, uint track, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads tag from several sectors, relative to track.</summary>
|
||||
/// <returns>The sectors tag.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (relative LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="track">Track.</param>
|
||||
/// <param name="tag">Tag type.</param>
|
||||
/// <param name="buffer"></param>
|
||||
ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads a complete sector (user data + all tags), relative to track.</summary>
|
||||
/// <returns>The complete sector. Format depends on disk type.</returns>
|
||||
/// <param name="sectorAddress">Sector address (relative LBA).</param>
|
||||
/// <param name="track">Track.</param>
|
||||
/// <param name="buffer"></param>
|
||||
ErrorNumber ReadSectorLong(ulong sectorAddress, uint track, out byte[] buffer);
|
||||
|
||||
/// <summary>Reads several complete sector (user data + all tags), relative to track.</summary>
|
||||
/// <returns>The complete sectors. Format depends on disk type.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (relative LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="track">Track.</param>
|
||||
/// <param name="buffer"></param>
|
||||
ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, uint track, out byte[] buffer);
|
||||
|
||||
/// <summary>Gets the disc track extents for a specified session.</summary>
|
||||
/// <returns>The track extents for that session.</returns>
|
||||
/// <param name="session">Session.</param>
|
||||
List<Track> GetSessionTracks(Session session);
|
||||
|
||||
/// <summary>Gets the disc track extents for a specified session.</summary>
|
||||
/// <returns>The track extents for that session.</returns>
|
||||
/// <param name="session">Session.</param>
|
||||
List<Track> GetSessionTracks(ushort session);
|
||||
|
||||
/// <summary>Verifies several sectors, relative to track.</summary>
|
||||
/// <returns>True if all are correct, false if any is incorrect, null if any is uncheckable.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (relative LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="track">Track.</param>
|
||||
/// <param name="failingLbas">List of incorrect sectors</param>
|
||||
/// <param name="unknownLbas">List of uncheckable sectors</param>
|
||||
bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> failingLbas,
|
||||
out List<ulong> unknownLbas);
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IPartition.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Partitioning scheme plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines methods to be used by partitioning scheme plugins and several
|
||||
// constants.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>Abstract class to implement partitioning schemes interpreting plugins.</summary>
|
||||
public interface IPartition
|
||||
{
|
||||
/// <summary>Plugin name.</summary>
|
||||
string Name { get; }
|
||||
/// <summary>Plugin UUID.</summary>
|
||||
Guid Id { get; }
|
||||
/// <summary>Plugin author</summary>
|
||||
string Author { get; }
|
||||
|
||||
/// <summary>Interprets a partitioning scheme.</summary>
|
||||
/// <returns><c>true</c>, if partitioning scheme is recognized, <c>false</c> otherwise.</returns>
|
||||
/// <param name="imagePlugin">Disk image.</param>
|
||||
/// <param name="partitions">Returns list of partitions.</param>
|
||||
/// <param name="sectorOffset">At which sector to start searching for the partition scheme.</param>
|
||||
bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IPartitionableMediaImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Media image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines the interface to be implemented by image plugins that can
|
||||
// contain partitioned medias, usually optical discs and some newer tapes.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>Defines an image that can contain partitions</summary>
|
||||
public interface IPartitionableMediaImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an array partitions. Typically only useful for optical disc images where each track and index means a
|
||||
/// different partition, as reads can be relative to them.
|
||||
/// </summary>
|
||||
/// <value>The partitions.</value>
|
||||
List<Partition> Partitions { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IPluginsRegister.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Interfaces.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Interface that declares class and methods to call to register plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>Defines a register of all known plugins</summary>
|
||||
public interface IPluginRegister
|
||||
{
|
||||
/// <summary>Gets all checksum plugins</summary>
|
||||
/// <returns>List of checksum plugins</returns>
|
||||
List<Type> GetAllChecksumPlugins();
|
||||
|
||||
/// <summary>Gets all filesystem plugins</summary>
|
||||
/// <returns>List of filesystem plugins</returns>
|
||||
List<Type> GetAllFilesystemPlugins();
|
||||
|
||||
/// <summary>Gets all filter plugins</summary>
|
||||
/// <returns>List of filter plugins</returns>
|
||||
List<Type> GetAllFilterPlugins();
|
||||
|
||||
/// <summary>Gets all floppy image plugins</summary>
|
||||
/// <returns>List of floppy image plugins</returns>
|
||||
List<Type> GetAllFloppyImagePlugins();
|
||||
|
||||
/// <summary>Gets all media image plugins</summary>
|
||||
/// <returns>List of media image plugins</returns>
|
||||
List<Type> GetAllMediaImagePlugins();
|
||||
|
||||
/// <summary>Gets all partition plugins</summary>
|
||||
/// <returns>List of partition plugins</returns>
|
||||
List<Type> GetAllPartitionPlugins();
|
||||
|
||||
/// <summary>Gets all read-only filesystem plugins</summary>
|
||||
/// <returns>List of read-only filesystem plugins</returns>
|
||||
List<Type> GetAllReadOnlyFilesystemPlugins();
|
||||
|
||||
/// <summary>Gets all writable floppy image plugins</summary>
|
||||
/// <returns>List of writable floppy image plugins</returns>
|
||||
List<Type> GetAllWritableFloppyImagePlugins();
|
||||
|
||||
/// <summary>Gets all writable media image plugins</summary>
|
||||
/// <returns>List of writable media image plugins</returns>
|
||||
List<Type> GetAllWritableImagePlugins();
|
||||
|
||||
/// <summary>Gets all archive plugins</summary>
|
||||
/// <returns>List of archive plugins</returns>
|
||||
List<Type> GetAllArchivePlugins();
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IReadOnlyFilesystem.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Filesystem plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Interface for filesystem plugins that offer read-only support of their
|
||||
// contents.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Defines the interface to implement reading the contents of a filesystem</summary>
|
||||
public interface IReadOnlyFilesystem : IFilesystem
|
||||
{
|
||||
/// <summary>Retrieves a list of options supported by the filesystem, with name, type and description</summary>
|
||||
IEnumerable<(string name, Type type, string description)> SupportedOptions { get; }
|
||||
|
||||
/// <summary>Supported namespaces</summary>
|
||||
Dictionary<string, string> Namespaces { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes whatever internal structures the filesystem plugin needs to be able to read files and directories
|
||||
/// from the filesystem.
|
||||
/// </summary>
|
||||
/// <param name="imagePlugin"></param>
|
||||
/// <param name="partition"></param>
|
||||
/// <param name="encoding">Which encoding to use for this filesystem.</param>
|
||||
/// <param name="options">Dictionary of key=value pairs containing options to pass to the filesystem</param>
|
||||
/// <param name="namespace">Filename namespace</param>
|
||||
ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
|
||||
Dictionary<string, string> options, string @namespace);
|
||||
|
||||
/// <summary>Frees all internal structures created by <see cref="Mount" /></summary>
|
||||
ErrorNumber Unmount();
|
||||
|
||||
/// <summary>Maps a filesystem block from a file to a block from the underlying device.</summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="path">File path.</param>
|
||||
/// <param name="fileBlock">File block.</param>
|
||||
/// <param name="deviceBlock">Device block.</param>
|
||||
ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock);
|
||||
|
||||
/// <summary>Gets the attributes of a file or directory</summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="path">File path.</param>
|
||||
/// <param name="attributes">File attributes.</param>
|
||||
ErrorNumber GetAttributes(string path, out FileAttributes attributes);
|
||||
|
||||
/// <summary>Lists all extended attributes, alternate data streams and forks of the given file.</summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="path">Path.</param>
|
||||
/// <param name="xattrs">List of extended attributes, alternate data streams and forks.</param>
|
||||
ErrorNumber ListXAttr(string path, out List<string> xattrs);
|
||||
|
||||
/// <summary>Reads an extended attribute, alternate data stream or fork from the given file.</summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="path">File path.</param>
|
||||
/// <param name="xattr">Extended attribute, alternate data stream or fork name.</param>
|
||||
/// <param name="buf">Buffer.</param>
|
||||
ErrorNumber GetXattr(string path, string xattr, ref byte[] buf);
|
||||
|
||||
/// <summary>Reads data from a file (main/only data stream or data fork).</summary>
|
||||
/// <param name="path">File path.</param>
|
||||
/// <param name="offset">Offset.</param>
|
||||
/// <param name="size">Bytes to read.</param>
|
||||
/// <param name="buf">Buffer.</param>
|
||||
ErrorNumber Read(string path, long offset, long size, ref byte[] buf);
|
||||
|
||||
/// <summary>Lists contents from a directory.</summary>
|
||||
/// <param name="path">Directory path.</param>
|
||||
/// <param name="contents">Directory contents.</param>
|
||||
ErrorNumber ReadDir(string path, out List<string> contents);
|
||||
|
||||
/// <summary>Gets information about the mounted volume.</summary>
|
||||
/// <param name="stat">Information about the mounted volume.</param>
|
||||
ErrorNumber StatFs(out FileSystemInfo stat);
|
||||
|
||||
/// <summary>Gets information about a file or directory.</summary>
|
||||
/// <param name="path">File path.</param>
|
||||
/// <param name="stat">File information.</param>
|
||||
ErrorNumber Stat(string path, out FileEntryInfo stat);
|
||||
|
||||
/// <summary>Solves a symbolic link.</summary>
|
||||
/// <param name="path">Link path.</param>
|
||||
/// <param name="dest">Link destination.</param>
|
||||
ErrorNumber ReadLink(string path, out string dest);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ITapeImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines the interface to be implemented by block addressable sequential
|
||||
// tape image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Defines an image that can store the information from streaming, digital, tapes</summary>
|
||||
public interface ITapeImage : IMediaImage
|
||||
{
|
||||
/// <summary>Gets a list of all the files registered in the image</summary>
|
||||
List<TapeFile> Files { get; }
|
||||
/// <summary>Gets a list of all the partitions registered in the image</summary>
|
||||
List<TapePartition> TapePartitions { get; }
|
||||
/// <summary>If the media is a really a tape, as some formats can store non-tapes</summary>
|
||||
bool IsTape { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IVerifiableImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines interface to be implemented by image plugins that can verify the
|
||||
// image itself.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>Defines an image that can verify the integrity of the image itself, but not its contents</summary>
|
||||
public interface IVerifiableImage
|
||||
{
|
||||
/// <summary>Verifies media image internal checksum.</summary>
|
||||
/// <returns>True if correct, false if incorrect, null if there is no internal checksum available</returns>
|
||||
bool? VerifyMediaImage();
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IVerifiableSectorsImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines interface to be implemented by image plugins that can verify the
|
||||
// sectors contained in the image.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>Defines an image that can verify the integrity of the sectors it contains</summary>
|
||||
public interface IVerifiableSectorsImage
|
||||
{
|
||||
/// <summary>Verifies a sector.</summary>
|
||||
/// <returns>True if correct, false if incorrect, null if uncheckable.</returns>
|
||||
/// <param name="sectorAddress">Sector address (LBA).</param>
|
||||
bool? VerifySector(ulong sectorAddress);
|
||||
|
||||
/// <summary>Verifies several sectors.</summary>
|
||||
/// <returns>True if all are correct, false if any is incorrect, null if any is uncheckable.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="failingLbas">List of incorrect sectors</param>
|
||||
/// <param name="unknownLbas">List of uncheckable sectors</param>
|
||||
bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas, out List<ulong> unknownLbas);
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IFloppyImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines the interface to be implemented by floppy image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <inheritdoc cref="IWritableImage" />
|
||||
/// <summary>
|
||||
/// Abstract class to implement disk image reading plugins that can contain floppy images. This interface is
|
||||
/// needed because floppy formatting characteristics are not necessarily compatible with the whole LBA-oriented
|
||||
/// interface defined by <see cref="T:Aaru.CommonTypes.Interfaces.IMediaImage" />. All data expected by these methods
|
||||
/// is already decoded from its corresponding bitstream.
|
||||
/// </summary>
|
||||
public interface IWritableFloppyImage : IFloppyImage, IWritableImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the image plugin the floppy physical characteristics and must be called before following methods are
|
||||
/// called. Once this is called, LBA-based methods should not be used.
|
||||
/// </summary>
|
||||
/// <param name="info">
|
||||
/// Floppy info, contains information about physical characteristics of floppy, like size, bitrate,
|
||||
/// track density, etc...
|
||||
/// </param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool SetFloppyCharacteristics(FloppyInfo info);
|
||||
|
||||
/// <summary>Writes a sector's user data.</summary>
|
||||
/// <param name="data">
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Duplicated" /> one of the duplicates. If
|
||||
/// <see cref="status" /> is <see cref="FloppySectorStatus.Demagnetized" />, <see cref="FloppySectorStatus.Hole" />,
|
||||
/// <see cref="FloppySectorStatus.NotFound" /> it will be ignored. Otherwise, whatever data should be in the sector.
|
||||
/// </param>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <param name="sector">Logical sector ID.</param>
|
||||
/// <param name="status">Status of sector.</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSector(byte[] data, ushort track, byte head, ushort sector, FloppySectorStatus status);
|
||||
|
||||
/// <summary>Writes a whole track, including all gaps, address marks, sectors data, etc.</summary>
|
||||
/// <param name="data">The track data.</param>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteTrack(byte[] data, ushort track, byte head);
|
||||
|
||||
/// <summary>Writes a sector's data including all tags, address mark, and so, in a format dependent of represented media.</summary>
|
||||
/// <param name="data">
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Duplicated" /> one of the duplicates. If
|
||||
/// <see cref="status" /> is <see cref="FloppySectorStatus.Demagnetized" />, <see cref="FloppySectorStatus.Hole" />,
|
||||
/// <see cref="FloppySectorStatus.NotFound" /> it will be ignored. Otherwise, whatever data should be in the sector.
|
||||
/// </param>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <param name="sector">Logical sector ID.</param>
|
||||
/// <param name="status">Status of request.</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSectorLong(byte[] data, ushort track, byte head, ushort sector, out FloppySectorStatus status);
|
||||
}
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IWritableImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines the interface to be implemented by writable image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Abstract class to implement disk image writing plugins. TODO: This interface is subject to change until
|
||||
/// notice.
|
||||
/// </summary>
|
||||
public interface IWritableImage : IMediaImage
|
||||
{
|
||||
/// <summary>Gets a list of <see cref="MediaTagType" /> that are supported by the media image format</summary>
|
||||
IEnumerable<MediaTagType> SupportedMediaTags { get; }
|
||||
/// <summary>Gets a list of <see cref="SectorTagType" /> that are supported by the media image format</summary>
|
||||
IEnumerable<SectorTagType> SupportedSectorTags { get; }
|
||||
/// <summary>Gets a list of <see cref="MediaType" /> that are supported by the media image format</summary>
|
||||
IEnumerable<MediaType> SupportedMediaTypes { get; }
|
||||
/// <summary>Retrieves a list of options supported by the filesystem, with name, type and description</summary>
|
||||
IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions { get; }
|
||||
/// <summary>Gets a list of known extensions for format auto-choosing</summary>
|
||||
IEnumerable<string> KnownExtensions { get; }
|
||||
|
||||
/// <summary>If set to <c>true</c> means the image is opened for writing</summary>
|
||||
bool IsWriting { get; }
|
||||
/// <summary>Contains a description of the last error</summary>
|
||||
string ErrorMessage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new image in the specified path, for the specified <see cref="MediaType" />, with the specified
|
||||
/// options to hold a media with the specified number of sectors
|
||||
/// </summary>
|
||||
/// <param name="path">Path to the new image, with extension</param>
|
||||
/// <param name="mediaType"><see cref="MediaType" /> that will be written in the image</param>
|
||||
/// <param name="options">Options to be used when creating new image</param>
|
||||
/// <param name="sectors">How many sectors the media has.</param>
|
||||
/// <param name="sectorSize"></param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
|
||||
uint sectorSize);
|
||||
|
||||
/// <summary>Writes a media tag to the image</summary>
|
||||
/// <param name="data">Media tag</param>
|
||||
/// <param name="tag">
|
||||
/// <see cref="MediaTagType" />
|
||||
/// </param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteMediaTag(byte[] data, MediaTagType tag);
|
||||
|
||||
/// <summary>Writes a sector to the image</summary>
|
||||
/// <param name="data">Sector data</param>
|
||||
/// <param name="sectorAddress">Sector address</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSector(byte[] data, ulong sectorAddress);
|
||||
|
||||
/// <summary>Writes several sectors to the image</summary>
|
||||
/// <param name="data">Sectors data</param>
|
||||
/// <param name="sectorAddress">Sector starting address</param>
|
||||
/// <param name="length">How many sectors to write</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSectors(byte[] data, ulong sectorAddress, uint length);
|
||||
|
||||
/// <summary>Writes a sector to the image with main channel tags attached</summary>
|
||||
/// <param name="data">Sector data with its main channel tags attached</param>
|
||||
/// <param name="sectorAddress">Sector address</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSectorLong(byte[] data, ulong sectorAddress);
|
||||
|
||||
/// <summary>Writes several sectors to the image</summary>
|
||||
/// <param name="data">Sector data with their main channel tags attached</param>
|
||||
/// <param name="sectorAddress">Sector starting address</param>
|
||||
/// <param name="length">How many sectors to write</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length);
|
||||
|
||||
/// <summary>Closes and flushes to disk the image</summary>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool Close();
|
||||
|
||||
/// <summary>Sets image metadata</summary>
|
||||
/// <param name="metadata"><see cref="ImageInfo" /> containing image metadata</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool SetMetadata(ImageInfo metadata);
|
||||
|
||||
/// <summary>Sets media geometry</summary>
|
||||
/// <param name="cylinders">Cylinders</param>
|
||||
/// <param name="heads">Heads</param>
|
||||
/// <param name="sectorsPerTrack">Sectors per track</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack);
|
||||
|
||||
/// <summary>Writes parallel or subchannel sector tag for one sector</summary>
|
||||
/// <param name="data">Tag data to write</param>
|
||||
/// <param name="sectorAddress">Sector address</param>
|
||||
/// <param name="tag">Tag type</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag);
|
||||
|
||||
/// <summary>Writes parallel or subchannel sector tag for several sector</summary>
|
||||
/// <param name="data">Tag data to write</param>
|
||||
/// <param name="sectorAddress">Starting sector address</param>
|
||||
/// <param name="length">How many sectors to write</param>
|
||||
/// <param name="tag">Tag type</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag);
|
||||
|
||||
/// <summary>Sets the list of dump hardware used to create the image from real media</summary>
|
||||
bool SetDumpHardware(List<DumpHardwareType> dumpHardware);
|
||||
|
||||
/// <summary>Sets the CICM XML metadata for the image</summary>
|
||||
bool SetCicmMetadata(CICMMetadataType metadata);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IWritableOpticalImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines the interface to be implemented by writable image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>Defines an image that is writable and can store an optical disc (CD, DVD, etc)</summary>
|
||||
public interface IWritableOpticalImage : IWritableImage, IOpticalMediaImage
|
||||
{
|
||||
/// <summary>Image format capabilities</summary>
|
||||
OpticalImageCapabilities OpticalCapabilities { get; }
|
||||
|
||||
/// <summary>Sets tracks for optical media</summary>
|
||||
/// <param name="tracks">List of tracks</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool SetTracks(List<Track> tracks);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IWritableTapeImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines the interface to be implemented by writable block addressable
|
||||
// sequential tape image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes.Structs;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>Defines an image that is writable and can store information about a streaming, digital, tape</summary>
|
||||
public interface IWritableTapeImage : ITapeImage, IWritableImage
|
||||
{
|
||||
/// <summary>Registers a new file in the image</summary>
|
||||
/// <param name="file">Tape file descriptor</param>
|
||||
/// <returns><c>true</c> if successful, <c>false</c> otherwise</returns>
|
||||
bool AddFile(TapeFile file);
|
||||
|
||||
/// <summary>Registers a new partition</summary>
|
||||
/// <param name="partition">Tape partition descriptor</param>
|
||||
/// <returns><c>true</c> if successful, <c>false</c> otherwise</returns>
|
||||
bool AddPartition(TapePartition partition);
|
||||
|
||||
/// <summary>
|
||||
/// Tells the image plugin to set the internal structures to expect a tape (e.g. unknown block count and size).
|
||||
/// Must be called before <see cref="IWritableImage.Create" />
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if successful, <c>false</c> otherwise</returns>
|
||||
bool SetTape();
|
||||
}
|
||||
}
|
||||
@@ -1,390 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : DetectOS.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Interop services.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Detects underlying operating system.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace Aaru.CommonTypes.Interop
|
||||
{
|
||||
/// <summary>Detects the underlying execution framework and operating system</summary>
|
||||
public static class DetectOS
|
||||
{
|
||||
/// <summary>Are we running under Mono?</summary>
|
||||
public static readonly bool IsMono =
|
||||
RuntimeInformation.FrameworkDescription.StartsWith("Mono", StringComparison.Ordinal);
|
||||
/// <summary>Are we running under .NET Framework?</summary>
|
||||
public static readonly bool IsNetFramework =
|
||||
RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.Ordinal);
|
||||
/// <summary>Are we running under .NET Core?</summary>
|
||||
public static readonly bool IsNetCore =
|
||||
RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.Ordinal);
|
||||
/// <summary>Are we running under .NET Native?</summary>
|
||||
public static readonly bool IsNetNative =
|
||||
RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal);
|
||||
|
||||
/// <summary>Checks if the underlying runtime runs in 64-bit mode</summary>
|
||||
public static readonly bool Is64Bit = IntPtr.Size == 8;
|
||||
|
||||
/// <summary>Checks if the underlying runtime runs in 32-bit mode</summary>
|
||||
public static readonly bool Is32Bit = IntPtr.Size == 4;
|
||||
|
||||
/// <summary>Are we running under Windows?</summary>
|
||||
public static bool IsWindows => GetRealPlatformID() == PlatformID.Win32NT ||
|
||||
GetRealPlatformID() == PlatformID.Win32S ||
|
||||
GetRealPlatformID() == PlatformID.Win32Windows ||
|
||||
GetRealPlatformID() == PlatformID.WinCE ||
|
||||
GetRealPlatformID() == PlatformID.WindowsPhone ||
|
||||
GetRealPlatformID() == PlatformID.Xbox;
|
||||
|
||||
/// <summary>Are we running with administrative (root) privileges?</summary>
|
||||
public static bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!IsWindows)
|
||||
return Environment.UserName == "root";
|
||||
|
||||
bool isAdmin;
|
||||
WindowsIdentity user = null;
|
||||
|
||||
try
|
||||
{
|
||||
user = WindowsIdentity.GetCurrent();
|
||||
var principal = new WindowsPrincipal(user);
|
||||
isAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
catch(UnauthorizedAccessException)
|
||||
{
|
||||
isAdmin = false;
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
isAdmin = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
user?.Dispose();
|
||||
}
|
||||
|
||||
return isAdmin;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libc", SetLastError = true)]
|
||||
static extern int uname(out utsname name);
|
||||
|
||||
[DllImport("libc", SetLastError = true, EntryPoint = "sysctlbyname", CharSet = CharSet.Ansi)]
|
||||
static extern int OSX_sysctlbyname(string name, IntPtr oldp, IntPtr oldlenp, IntPtr newp, uint newlen);
|
||||
|
||||
/// <summary>Gets the real platform ID, not the incomplete .NET framework one</summary>
|
||||
/// <returns>Platform ID</returns>
|
||||
/// <exception cref="Exception">Unhandled exception</exception>
|
||||
public static PlatformID GetRealPlatformID()
|
||||
{
|
||||
if((int)Environment.OSVersion.Platform < 4 ||
|
||||
(int)Environment.OSVersion.Platform == 5)
|
||||
return (PlatformID)(int)Environment.OSVersion.Platform;
|
||||
|
||||
int error = uname(out utsname unixname);
|
||||
|
||||
if(error != 0)
|
||||
throw new Exception($"Unhandled exception calling uname: {Marshal.GetLastWin32Error()}");
|
||||
|
||||
switch(unixname.sysname)
|
||||
{
|
||||
// TODO: Differentiate Linux, Android, Tizen
|
||||
case "Linux":
|
||||
{
|
||||
#if __ANDROID__
|
||||
return PlatformID.Android;
|
||||
#else
|
||||
return PlatformID.Linux;
|
||||
#endif
|
||||
}
|
||||
|
||||
case "Darwin":
|
||||
{
|
||||
IntPtr pLen = Marshal.AllocHGlobal(sizeof(int));
|
||||
int osxError = OSX_sysctlbyname("hw.machine", IntPtr.Zero, pLen, IntPtr.Zero, 0);
|
||||
|
||||
if(osxError != 0)
|
||||
{
|
||||
Marshal.FreeHGlobal(pLen);
|
||||
|
||||
throw new Exception($"Unhandled exception calling uname: {Marshal.GetLastWin32Error()}");
|
||||
}
|
||||
|
||||
int length = Marshal.ReadInt32(pLen);
|
||||
IntPtr pStr = Marshal.AllocHGlobal(length);
|
||||
osxError = OSX_sysctlbyname("hw.machine", pStr, pLen, IntPtr.Zero, 0);
|
||||
|
||||
if(osxError != 0)
|
||||
{
|
||||
Marshal.FreeHGlobal(pStr);
|
||||
Marshal.FreeHGlobal(pLen);
|
||||
|
||||
throw new Exception($"Unhandled exception calling uname: {Marshal.GetLastWin32Error()}");
|
||||
}
|
||||
|
||||
string machine = Marshal.PtrToStringAnsi(pStr);
|
||||
|
||||
Marshal.FreeHGlobal(pStr);
|
||||
Marshal.FreeHGlobal(pLen);
|
||||
|
||||
if(machine != null &&
|
||||
(machine.StartsWith("iPad", StringComparison.Ordinal) ||
|
||||
machine.StartsWith("iPod", StringComparison.Ordinal) ||
|
||||
machine.StartsWith("iPhone", StringComparison.Ordinal)))
|
||||
return PlatformID.iOS;
|
||||
|
||||
return PlatformID.MacOSX;
|
||||
}
|
||||
|
||||
case "GNU": return PlatformID.Hurd;
|
||||
case "FreeBSD":
|
||||
case "GNU/kFreeBSD": return PlatformID.FreeBSD;
|
||||
case "DragonFly": return PlatformID.DragonFly;
|
||||
case "Haiku": return PlatformID.Haiku;
|
||||
case "HP-UX": return PlatformID.HPUX;
|
||||
case "AIX": return PlatformID.AIX;
|
||||
case "OS400": return PlatformID.OS400;
|
||||
case "IRIX":
|
||||
case "IRIX64": return PlatformID.IRIX;
|
||||
case "Minix": return PlatformID.Minix;
|
||||
case "NetBSD": return PlatformID.NetBSD;
|
||||
case "NONSTOP_KERNEL": return PlatformID.NonStop;
|
||||
case "OpenBSD": return PlatformID.OpenBSD;
|
||||
case "QNX": return PlatformID.QNX;
|
||||
case "SINIX-Y": return PlatformID.SINIX;
|
||||
case "SunOS": return PlatformID.Solaris;
|
||||
case "OSF1": return PlatformID.Tru64;
|
||||
case "ULTRIX": return PlatformID.Ultrix;
|
||||
case "SCO_SV": return PlatformID.OpenServer;
|
||||
case "UnixWare": return PlatformID.UnixWare;
|
||||
case "Interix":
|
||||
case "UWIN-W7": return PlatformID.Win32NT;
|
||||
default:
|
||||
{
|
||||
if(unixname.sysname.StartsWith("CYGWIN_NT", StringComparison.Ordinal) ||
|
||||
unixname.sysname.StartsWith("MINGW32_NT", StringComparison.Ordinal) ||
|
||||
unixname.sysname.StartsWith("MSYS_NT", StringComparison.Ordinal) ||
|
||||
unixname.sysname.StartsWith("UWIN", StringComparison.Ordinal))
|
||||
return PlatformID.Win32NT;
|
||||
|
||||
return PlatformID.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets a string for the current operating system REAL version (handles Darwin 1.4 and Windows 10 falsifying)</summary>
|
||||
/// <returns>Current operating system version</returns>
|
||||
public static string GetVersion()
|
||||
{
|
||||
string environ = Environment.OSVersion.Version.ToString();
|
||||
|
||||
switch(GetRealPlatformID())
|
||||
{
|
||||
case PlatformID.MacOSX:
|
||||
if(Environment.OSVersion.Version.Major != 1)
|
||||
return $"10.{Environment.OSVersion.Version.Major - 4}.{Environment.OSVersion.Version.Minor}";
|
||||
|
||||
switch(Environment.OSVersion.Version.Minor)
|
||||
{
|
||||
case 3: return "10.0";
|
||||
case 4: return "10.1";
|
||||
}
|
||||
|
||||
goto default;
|
||||
case PlatformID.Win32NT:
|
||||
// From Windows 8.1 the reported version is simply falsified...
|
||||
if((Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Major >= 2) ||
|
||||
Environment.OSVersion.Version.Major > 6)
|
||||
return FileVersionInfo.
|
||||
GetVersionInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System),
|
||||
"KERNEL32.DLL")).ProductVersion;
|
||||
|
||||
return environ;
|
||||
default: return environ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>From a platform ID and version returns a human-readable version</summary>
|
||||
/// <param name="id">Platform ID</param>
|
||||
/// <param name="version">Version number</param>
|
||||
/// <returns>Operating system name</returns>
|
||||
public static string GetPlatformName(PlatformID id, string version = null)
|
||||
{
|
||||
switch(id)
|
||||
{
|
||||
case PlatformID.AIX: return "AIX";
|
||||
case PlatformID.Android: return "Android";
|
||||
case PlatformID.DragonFly: return "DragonFly BSD";
|
||||
case PlatformID.FreeBSD: return "FreeBSD";
|
||||
case PlatformID.Haiku: return "Haiku";
|
||||
case PlatformID.HPUX: return "HP/UX";
|
||||
case PlatformID.Hurd: return "Hurd";
|
||||
case PlatformID.iOS: return "iOS";
|
||||
case PlatformID.IRIX: return "IRIX";
|
||||
case PlatformID.Linux:
|
||||
if(!File.Exists("/proc/version"))
|
||||
return "Linux";
|
||||
|
||||
string s = File.ReadAllText("/proc/version");
|
||||
|
||||
return s.Contains("Microsoft") || s.Contains("WSL") ? "Windows Subsystem for Linux" : "Linux";
|
||||
|
||||
case PlatformID.MacOSX:
|
||||
if(string.IsNullOrEmpty(version))
|
||||
return "macOS";
|
||||
|
||||
string[] pieces = version.Split('.');
|
||||
|
||||
if(pieces.Length < 2 ||
|
||||
!int.TryParse(pieces[1], out int minor))
|
||||
return "macOS";
|
||||
|
||||
if(minor >= 12)
|
||||
return "macOS";
|
||||
|
||||
if(minor >= 8)
|
||||
return "OS X";
|
||||
|
||||
return "Mac OS X";
|
||||
|
||||
case PlatformID.Minix: return "MINIX";
|
||||
case PlatformID.NetBSD: return "NetBSD";
|
||||
case PlatformID.NonStop: return "NonStop OS";
|
||||
case PlatformID.OpenBSD: return "OpenBSD";
|
||||
case PlatformID.OpenServer: return "SCO OpenServer";
|
||||
case PlatformID.OS400: return "OS/400";
|
||||
case PlatformID.PlayStation3: return "Sony CellOS";
|
||||
case PlatformID.PlayStation4: return "Sony Orbis OS";
|
||||
case PlatformID.QNX: return "QNX";
|
||||
case PlatformID.SINIX: return "SINIX";
|
||||
case PlatformID.Solaris: return "Sun Solaris";
|
||||
case PlatformID.Tizen: return "Samsung Tizen";
|
||||
case PlatformID.Tru64: return "Tru64 UNIX";
|
||||
case PlatformID.Ultrix: return "Ultrix";
|
||||
case PlatformID.Unix: return "UNIX";
|
||||
case PlatformID.UnixWare: return "SCO UnixWare";
|
||||
case PlatformID.Wii: return "Nintendo Wii";
|
||||
case PlatformID.WiiU: return "Nintendo Wii U";
|
||||
case PlatformID.Win32NT:
|
||||
if(string.IsNullOrEmpty(version))
|
||||
return "Windows NT/2000/XP/Vista/7/10";
|
||||
|
||||
if(version.StartsWith("3.", StringComparison.Ordinal) ||
|
||||
version.StartsWith("4.", StringComparison.Ordinal))
|
||||
return "Windows NT";
|
||||
|
||||
if(version.StartsWith("5.0", StringComparison.Ordinal))
|
||||
return "Windows 2000";
|
||||
|
||||
if(version.StartsWith("5.1", StringComparison.Ordinal))
|
||||
return "Windows XP";
|
||||
|
||||
if(version.StartsWith("5.2", StringComparison.Ordinal))
|
||||
return "Windows 2003";
|
||||
|
||||
if(version.StartsWith("6.0", StringComparison.Ordinal))
|
||||
return "Windows Vista";
|
||||
|
||||
if(version.StartsWith("6.1", StringComparison.Ordinal))
|
||||
return "Windows 7";
|
||||
|
||||
if(version.StartsWith("6.2", StringComparison.Ordinal))
|
||||
return "Windows 8";
|
||||
|
||||
if(version.StartsWith("6.3", StringComparison.Ordinal))
|
||||
return "Windows 8.1";
|
||||
|
||||
if(version.StartsWith("10.0", StringComparison.Ordinal))
|
||||
return "Windows 10";
|
||||
|
||||
return "Windows NT/2000/XP/Vista/7/10";
|
||||
case PlatformID.Win32S: return "Windows 3.x with win32s";
|
||||
case PlatformID.Win32Windows:
|
||||
if(string.IsNullOrEmpty(version))
|
||||
return "Windows 9x/Me";
|
||||
|
||||
if(version.StartsWith("4.0", StringComparison.Ordinal))
|
||||
return "Windows 95";
|
||||
|
||||
if(version.StartsWith("4.10.2222", StringComparison.Ordinal))
|
||||
return "Windows 98 SE";
|
||||
|
||||
if(version.StartsWith("4.1", StringComparison.Ordinal))
|
||||
return "Windows 98";
|
||||
|
||||
if(version.StartsWith("4.9", StringComparison.Ordinal))
|
||||
return "Windows Me";
|
||||
|
||||
return "Windows 9x/Me";
|
||||
case PlatformID.WinCE: return "Windows CE/Mobile";
|
||||
case PlatformID.WindowsPhone: return "Windows Phone";
|
||||
case PlatformID.Xbox: return "Xbox OS";
|
||||
case PlatformID.zOS: return "z/OS";
|
||||
default: return id.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>POSIX uname structure, size from OSX, big enough to handle extra fields</summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
struct utsname
|
||||
{
|
||||
/// <summary>System name</summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public readonly string sysname;
|
||||
/// <summary>Node name</summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public readonly string nodename;
|
||||
/// <summary>Release level</summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public readonly string release;
|
||||
/// <summary>Version level</summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public readonly string version;
|
||||
/// <summary>Hardware level</summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public readonly string machine;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : PlatformID.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Interop services.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains an enhanced PlatformID enumeration.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Aaru.CommonTypes.Interop
|
||||
{
|
||||
/// <summary>Contains an arbitrary list of OSes, even if .NET does not run on them</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum PlatformID
|
||||
{
|
||||
/// <summary>Win32s</summary>
|
||||
Win32S = 0,
|
||||
/// <summary>Win32 (Windows 9x)</summary>
|
||||
Win32Windows = 1,
|
||||
/// <summary>Windows NT</summary>
|
||||
Win32NT = 2,
|
||||
/// <summary>Windows Mobile</summary>
|
||||
WinCE = 3,
|
||||
/// <summary>UNIX (do not use, too generic)</summary>
|
||||
Unix = 4,
|
||||
/// <summary>Xbox 360</summary>
|
||||
Xbox = 5,
|
||||
/// <summary>OS X</summary>
|
||||
MacOSX = 6,
|
||||
/// <summary>iOS is not OS X</summary>
|
||||
iOS = 7,
|
||||
/// <summary>Linux</summary>
|
||||
Linux = 8,
|
||||
/// <summary>Sun Solaris</summary>
|
||||
Solaris = 9,
|
||||
/// <summary>NetBSD</summary>
|
||||
NetBSD = 10,
|
||||
/// <summary>OpenBSD</summary>
|
||||
OpenBSD = 11,
|
||||
/// <summary>FreeBSD</summary>
|
||||
FreeBSD = 12,
|
||||
/// <summary>DragonFly BSD</summary>
|
||||
DragonFly = 13,
|
||||
/// <summary>Nintendo Wii</summary>
|
||||
Wii = 14,
|
||||
/// <summary>Nintendo Wii U</summary>
|
||||
WiiU = 15,
|
||||
/// <summary>Sony PlayStation 3</summary>
|
||||
PlayStation3 = 16,
|
||||
/// <summary>Sony Playstation 4</summary>
|
||||
PlayStation4 = 17,
|
||||
/// <summary>Google Android</summary>
|
||||
Android = 18,
|
||||
/// <summary>Samsung Tizen</summary>
|
||||
Tizen = 19,
|
||||
/// <summary>Windows Phone</summary>
|
||||
WindowsPhone = 20,
|
||||
/// <summary>GNU/Hurd</summary>
|
||||
Hurd = 21,
|
||||
/// <summary>Haiku</summary>
|
||||
Haiku = 22,
|
||||
/// <summary>HP-UX</summary>
|
||||
HPUX = 23,
|
||||
/// <summary>AIX</summary>
|
||||
AIX = 24,
|
||||
/// <summary>OS/400</summary>
|
||||
OS400 = 25,
|
||||
/// <summary>IRIX</summary>
|
||||
IRIX = 26,
|
||||
/// <summary>Minix</summary>
|
||||
Minix = 27,
|
||||
/// <summary>NonStop</summary>
|
||||
NonStop = 28,
|
||||
/// <summary>QNX</summary>
|
||||
QNX = 29,
|
||||
/// <summary>SINIX</summary>
|
||||
SINIX = 30,
|
||||
/// <summary>Tru64 UNIX</summary>
|
||||
Tru64 = 31,
|
||||
/// <summary>Ultrix</summary>
|
||||
Ultrix = 32,
|
||||
/// <summary>SCO OpenServer / SCO UNIX</summary>
|
||||
OpenServer = 33,
|
||||
/// <summary>SCO UnixWare</summary>
|
||||
UnixWare = 34,
|
||||
/// <summary>IBM z/OS</summary>
|
||||
zOS = 35,
|
||||
/// <summary>Unknown</summary>
|
||||
Unknown = -1
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Version.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Interop services.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Returns Aaru version.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime;
|
||||
|
||||
namespace Aaru.CommonTypes.Interop
|
||||
{
|
||||
/// <summary>Gets our own, or the runtime's version</summary>
|
||||
public static class Version
|
||||
{
|
||||
/// <summary>Gets version string</summary>
|
||||
/// <returns>Version</returns>
|
||||
public static string GetVersion() => typeof(Version).Assembly.GetName().Version?.ToString();
|
||||
|
||||
/// <summary>Gets .NET Core version</summary>
|
||||
/// <returns>Version</returns>
|
||||
public static string GetNetCoreVersion()
|
||||
{
|
||||
Assembly assembly = typeof(GCSettings).Assembly;
|
||||
|
||||
string[] assemblyPath = assembly.CodeBase?.Split(new[]
|
||||
{
|
||||
'/', '\\'
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if(assemblyPath is null)
|
||||
return null;
|
||||
|
||||
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
|
||||
|
||||
if(netCoreAppIndex > 0 &&
|
||||
netCoreAppIndex < assemblyPath.Length - 2)
|
||||
return assemblyPath[netCoreAppIndex + 1];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Gets Mono version</summary>
|
||||
/// <returns>Version</returns>
|
||||
public static string GetMonoVersion()
|
||||
{
|
||||
if(!DetectOS.IsMono)
|
||||
return null;
|
||||
|
||||
MethodInfo monoDisplayName = Type.GetType("Mono.Runtime")?.
|
||||
GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
|
||||
if(monoDisplayName != null)
|
||||
return (string)monoDisplayName.Invoke(null, null);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,528 +0,0 @@
|
||||
Enum,Value,Summary
|
||||
"Unknown",0,"Unknown disk type"
|
||||
"UnknownMO",1,"Unknown magneto-optical"
|
||||
"GENERIC_HDD",2,"Generic hard disk"
|
||||
"Microdrive",3,"Microdrive type hard disk"
|
||||
"Zone_HDD",4,"Zoned hard disk"
|
||||
"FlashDrive",5,"USB flash drives"
|
||||
"UnknownTape",6,"Unknown data tape"
|
||||
"CD",10,"Any unknown or standard violating CD"
|
||||
"CDDA",11,"CD Digital Audio (Red Book)"
|
||||
"CDG",12,"CD+G (Red Book)"
|
||||
"CDEG",13,"CD+EG (Red Book)"
|
||||
"CDI",14,"CD-i (Green Book)"
|
||||
"CDROM",15,"CD-ROM (Yellow Book)"
|
||||
"CDROMXA",16,"CD-ROM XA (Yellow Book)"
|
||||
"CDPLUS",17,"CD+ (Blue Book)"
|
||||
"CDMO",18,"CD-MO (Orange Book)"
|
||||
"CDR",19,"CD-Recordable (Orange Book)"
|
||||
"CDRW",20,"CD-ReWritable (Orange Book)"
|
||||
"CDMRW",21,"Mount-Rainier CD-RW"
|
||||
"VCD",22,"Video CD (White Book)"
|
||||
"SVCD",23,"Super Video CD (White Book)"
|
||||
"PCD",24,"Photo CD (Beige Book)"
|
||||
"SACD",25,"Super Audio CD (Scarlet Book)"
|
||||
"DDCD",26,"Double-Density CD-ROM (Purple Book)"
|
||||
"DDCDR",27,"DD CD-R (Purple Book)"
|
||||
"DDCDRW",28,"DD CD-RW (Purple Book)"
|
||||
"DTSCD",29,"DTS audio CD (non-standard)"
|
||||
"CDMIDI",30,"CD-MIDI (Red Book)"
|
||||
"CDV",31,"CD-Video (ISO/IEC 61104)"
|
||||
"PD650",32,"120mm, Phase-Change, 1298496 sectors, 512 bytes/sector, PD650, ECMA-240, ISO 15485"
|
||||
"PD650_WORM",33,"120mm, Write-Once, 1281856 sectors, 512 bytes/sector, PD650, ECMA-240, ISO 15485"
|
||||
"CDIREADY",34,"CD-i Ready, contains a track before the first TOC track, in mode 2, and all TOC tracks are Audio. Subchannel marks track as audio pause."
|
||||
"FMTOWNS",35,
|
||||
"DVDROM",40,"DVD-ROM (applies to DVD Video and DVD Audio)"
|
||||
"DVDR",41,"DVD-R"
|
||||
"DVDRW",42,"DVD-RW"
|
||||
"DVDPR",43,"DVD+R"
|
||||
"DVDPRW",44,"DVD+RW"
|
||||
"DVDPRWDL",45,"DVD+RW DL"
|
||||
"DVDRDL",46,"DVD-R DL"
|
||||
"DVDPRDL",47,"DVD+R DL"
|
||||
"DVDRAM",48,"DVD-RAM"
|
||||
"DVDRWDL",49,"DVD-RW DL"
|
||||
"DVDDownload",50,"DVD-Download"
|
||||
"HDDVDROM",51,"HD DVD-ROM (applies to HD DVD Video)"
|
||||
"HDDVDRAM",52,"HD DVD-RAM"
|
||||
"HDDVDR",53,"HD DVD-R"
|
||||
"HDDVDRW",54,"HD DVD-RW"
|
||||
"HDDVDRDL",55,"HD DVD-R DL"
|
||||
"HDDVDRWDL",56,"HD DVD-RW DL"
|
||||
"BDROM",60,"BD-ROM (and BD Video)"
|
||||
"BDR",61,"BD-R"
|
||||
"BDRE",62,"BD-RE"
|
||||
"BDRXL",63,"BD-R XL"
|
||||
"BDREXL",64,"BD-RE XL"
|
||||
"UHDBD",65,"Ultra HD Blu-ray"
|
||||
"EVD",70,"Enhanced Versatile Disc"
|
||||
"FVD",71,"Forward Versatile Disc"
|
||||
"HVD",72,"Holographic Versatile Disc"
|
||||
"CBHD",73,"China Blue High Definition"
|
||||
"HDVMD",74,"High Definition Versatile Multilayer Disc"
|
||||
"VCDHD",75,"Versatile Compact Disc High Density"
|
||||
"SVOD",76,"Stacked Volumetric Optical Disc"
|
||||
"FDDVD",77,"Five Dimensional disc"
|
||||
"CVD",78,"China Video Disc"
|
||||
"LD",80,"Pioneer LaserDisc"
|
||||
"LDROM",81,"Pioneer LaserDisc data"
|
||||
"LDROM2",82,
|
||||
"LVROM",83,
|
||||
"MegaLD",84,
|
||||
"HiMD",90,"Sony Hi-MD"
|
||||
"MD",91,"Sony MiniDisc"
|
||||
"MDData",92,"Sony MD-Data"
|
||||
"MDData2",93,"Sony MD-Data2"
|
||||
"MD60",94,"Sony MiniDisc, 60 minutes, formatted with Hi-MD format"
|
||||
"MD74",95,"Sony MiniDisc, 74 minutes, formatted with Hi-MD format"
|
||||
"MD80",96,"Sony MiniDisc, 80 minutes, formatted with Hi-MD format"
|
||||
"UDO",100,"5.25"", Phase-Change, 1834348 sectors, 8192 bytes/sector, Ultra Density Optical, ECMA-350, ISO 17345"
|
||||
"UDO2",101,"5.25"", Phase-Change, 3669724 sectors, 8192 bytes/sector, Ultra Density Optical 2, ECMA-380, ISO 11976"
|
||||
"UDO2_WORM",102,"5.25"", Write-Once, 3668759 sectors, 8192 bytes/sector, Ultra Density Optical 2, ECMA-380, ISO 11976"
|
||||
"PlayStationMemoryCard",110,
|
||||
"PlayStationMemoryCard2",111,
|
||||
"PS1CD",112,"Sony PlayStation game CD"
|
||||
"PS2CD",113,"Sony PlayStation 2 game CD"
|
||||
"PS2DVD",114,"Sony PlayStation 2 game DVD"
|
||||
"PS3DVD",115,"Sony PlayStation 3 game DVD"
|
||||
"PS3BD",116,"Sony PlayStation 3 game Blu-ray"
|
||||
"PS4BD",117,"Sony PlayStation 4 game Blu-ray"
|
||||
"UMD",118,"Sony PlayStation Portable Universal Media Disc (ECMA-365)"
|
||||
"PlayStationVitaGameCard",119,
|
||||
"PS5BD",120,"Sony PlayStation 5 game Ultra HD Blu-ray"
|
||||
"XGD",130,"Microsoft X-box Game Disc"
|
||||
"XGD2",131,"Microsoft X-box 360 Game Disc"
|
||||
"XGD3",132,"Microsoft X-box 360 Game Disc"
|
||||
"XGD4",133,"Microsoft X-box One Game Disc"
|
||||
"MEGACD",150,"Sega MegaCD"
|
||||
"SATURNCD",151,"Sega Saturn disc"
|
||||
"GDROM",152,"Sega/Yamaha Gigabyte Disc"
|
||||
"GDR",153,"Sega/Yamaha recordable Gigabyte Disc"
|
||||
"SegaCard",154,
|
||||
"MilCD",155,
|
||||
"HuCard",170,"PC-Engine / TurboGrafx cartridge"
|
||||
"SuperCDROM2",171,"PC-Engine / TurboGrafx CD"
|
||||
"JaguarCD",172,"Atari Jaguar CD"
|
||||
"ThreeDO",173,"3DO CD"
|
||||
"PCFX",174,"NEC PC-FX"
|
||||
"NeoGeoCD",175,"NEO-GEO CD"
|
||||
"CDTV",176,"Commodore CDTV"
|
||||
"CD32",177,"Amiga CD32"
|
||||
"Nuon",178,"Nuon (DVD based videogame console)"
|
||||
"Playdia",179,"Bandai Playdia"
|
||||
"Apple32SS",180,"5.25"", SS, DD, 35 tracks, 13 spt, 256 bytes/sector, GCR"
|
||||
"Apple32DS",181,"5.25"", DS, DD, 35 tracks, 13 spt, 256 bytes/sector, GCR"
|
||||
"Apple33SS",182,"5.25"", SS, DD, 35 tracks, 16 spt, 256 bytes/sector, GCR"
|
||||
"Apple33DS",183,"5.25"", DS, DD, 35 tracks, 16 spt, 256 bytes/sector, GCR"
|
||||
"AppleSonySS",184,"3.5"", SS, DD, 80 tracks, 8 to 12 spt, 512 bytes/sector, GCR"
|
||||
"AppleSonyDS",185,"3.5"", DS, DD, 80 tracks, 8 to 12 spt, 512 bytes/sector, GCR"
|
||||
"AppleFileWare",186,"5.25"", DS, ?D, ?? tracks, ?? spt, 512 bytes/sector, GCR, opposite side heads, aka Twiggy"
|
||||
"DOS_525_SS_DD_8",190,"5.25"", SS, DD, 40 tracks, 8 spt, 512 bytes/sector, MFM"
|
||||
"DOS_525_SS_DD_9",191,"5.25"", SS, DD, 40 tracks, 9 spt, 512 bytes/sector, MFM"
|
||||
"DOS_525_DS_DD_8",192,"5.25"", DS, DD, 40 tracks, 8 spt, 512 bytes/sector, MFM"
|
||||
"DOS_525_DS_DD_9",193,"5.25"", DS, DD, 40 tracks, 9 spt, 512 bytes/sector, MFM"
|
||||
"DOS_525_HD",194,"5.25"", DS, HD, 80 tracks, 15 spt, 512 bytes/sector, MFM"
|
||||
"DOS_35_SS_DD_8",195,"3.5"", SS, DD, 80 tracks, 8 spt, 512 bytes/sector, MFM"
|
||||
"DOS_35_SS_DD_9",196,"3.5"", SS, DD, 80 tracks, 9 spt, 512 bytes/sector, MFM"
|
||||
"DOS_35_DS_DD_8",197,"3.5"", DS, DD, 80 tracks, 8 spt, 512 bytes/sector, MFM"
|
||||
"DOS_35_DS_DD_9",198,"3.5"", DS, DD, 80 tracks, 9 spt, 512 bytes/sector, MFM"
|
||||
"DOS_35_HD",199,"3.5"", DS, HD, 80 tracks, 18 spt, 512 bytes/sector, MFM"
|
||||
"DOS_35_ED",200,"3.5"", DS, ED, 80 tracks, 36 spt, 512 bytes/sector, MFM"
|
||||
"DMF",201,"3.5"", DS, HD, 80 tracks, 21 spt, 512 bytes/sector, MFM"
|
||||
"DMF_82",202,"3.5"", DS, HD, 82 tracks, 21 spt, 512 bytes/sector, MFM"
|
||||
"XDF_525",203,"5.25"", DS, HD, 80 tracks, ? spt, ??? + ??? + ??? bytes/sector, MFM track 0 = ??15 sectors, 512 bytes/sector, falsified to DOS as 19 spt, 512 bps"
|
||||
"XDF_35",204,"3.5"", DS, HD, 80 tracks, 4 spt, 8192 + 2048 + 1024 + 512 bytes/sector, MFM track 0 = 19 sectors, 512 bytes/sector, falsified to DOS as 23 spt, 512 bps"
|
||||
"IBM23FD",210,"8"", SS, SD, 32 tracks, 8 spt, 319 bytes/sector, FM"
|
||||
"IBM33FD_128",211,"8"", SS, SD, 73 tracks, 26 spt, 128 bytes/sector, FM"
|
||||
"IBM33FD_256",212,"8"", SS, SD, 74 tracks, 15 spt, 256 bytes/sector, FM, track 0 = 26 sectors, 128 bytes/sector"
|
||||
"IBM33FD_512",213,"8"", SS, SD, 74 tracks, 8 spt, 512 bytes/sector, FM, track 0 = 26 sectors, 128 bytes/sector"
|
||||
"IBM43FD_128",214,"8"", DS, SD, 74 tracks, 26 spt, 128 bytes/sector, FM, track 0 = 26 sectors, 128 bytes/sector"
|
||||
"IBM43FD_256",215,"8"", DS, SD, 74 tracks, 26 spt, 256 bytes/sector, FM, track 0 = 26 sectors, 128 bytes/sector"
|
||||
"IBM53FD_256",216,"8"", DS, DD, 74 tracks, 26 spt, 256 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128 bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector"
|
||||
"IBM53FD_512",217,"8"", DS, DD, 74 tracks, 15 spt, 512 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128 bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector"
|
||||
"IBM53FD_1024",218,"8"", DS, DD, 74 tracks, 8 spt, 1024 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128 bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector"
|
||||
"RX01",220,"8"", SS, DD, 77 tracks, 26 spt, 128 bytes/sector, FM"
|
||||
"RX02",221,"8"", SS, DD, 77 tracks, 26 spt, 256 bytes/sector, FM/MFM"
|
||||
"RX03",222,"8"", DS, DD, 77 tracks, 26 spt, 256 bytes/sector, FM/MFM"
|
||||
"RX50",223,"5.25"", SS, DD, 80 tracks, 10 spt, 512 bytes/sector, MFM"
|
||||
"ACORN_525_SS_SD_40",230,"5,25"", SS, SD, 40 tracks, 10 spt, 256 bytes/sector, FM"
|
||||
"ACORN_525_SS_SD_80",231,"5,25"", SS, SD, 80 tracks, 10 spt, 256 bytes/sector, FM"
|
||||
"ACORN_525_SS_DD_40",232,"5,25"", SS, DD, 40 tracks, 16 spt, 256 bytes/sector, MFM"
|
||||
"ACORN_525_SS_DD_80",233,"5,25"", SS, DD, 80 tracks, 16 spt, 256 bytes/sector, MFM"
|
||||
"ACORN_525_DS_DD",234,"5,25"", DS, DD, 80 tracks, 16 spt, 256 bytes/sector, MFM"
|
||||
"ACORN_35_DS_DD",235,"3,5"", DS, DD, 80 tracks, 5 spt, 1024 bytes/sector, MFM"
|
||||
"ACORN_35_DS_HD",236,"3,5"", DS, HD, 80 tracks, 10 spt, 1024 bytes/sector, MFM"
|
||||
"ATARI_525_SD",240,"5,25"", SS, SD, 40 tracks, 18 spt, 128 bytes/sector, FM"
|
||||
"ATARI_525_ED",241,"5,25"", SS, ED, 40 tracks, 26 spt, 128 bytes/sector, MFM"
|
||||
"ATARI_525_DD",242,"5,25"", SS, DD, 40 tracks, 18 spt, 256 bytes/sector, MFM"
|
||||
"ATARI_35_SS_DD",243,"3,5"", SS, DD, 80 tracks, 10 spt, 512 bytes/sector, MFM"
|
||||
"ATARI_35_DS_DD",244,"3,5"", DS, DD, 80 tracks, 10 spt, 512 bytes/sector, MFM"
|
||||
"ATARI_35_SS_DD_11",245,"3,5"", SS, DD, 80 tracks, 11 spt, 512 bytes/sector, MFM"
|
||||
"ATARI_35_DS_DD_11",246,"3,5"", DS, DD, 80 tracks, 11 spt, 512 bytes/sector, MFM"
|
||||
"CBM_35_DD",250,"3,5"", DS, DD, 80 tracks, 10 spt, 512 bytes/sector, MFM (1581)"
|
||||
"CBM_AMIGA_35_DD",251,"3,5"", DS, DD, 80 tracks, 11 spt, 512 bytes/sector, MFM (Amiga)"
|
||||
"CBM_AMIGA_35_HD",252,"3,5"", DS, HD, 80 tracks, 22 spt, 512 bytes/sector, MFM (Amiga)"
|
||||
"CBM_1540",253,"5,25"", SS, DD, 35 tracks, GCR"
|
||||
"CBM_1540_Ext",254,"5,25"", SS, DD, 40 tracks, GCR"
|
||||
"CBM_1571",255,"5,25"", DS, DD, 35 tracks, GCR"
|
||||
"NEC_8_SD",260,"8"", DS, SD, 77 tracks, 26 spt, 128 bytes/sector, FM"
|
||||
"NEC_8_DD",261,"8"", DS, DD, 77 tracks, 26 spt, 256 bytes/sector, MFM"
|
||||
"NEC_525_SS",262,"5.25"", SS, SD, 80 tracks, 16 spt, 256 bytes/sector, FM"
|
||||
"NEC_525_DS",263,"5.25"", DS, SD, 80 tracks, 16 spt, 256 bytes/sector, MFM"
|
||||
"NEC_525_HD",264,"5,25"", DS, HD, 77 tracks, 8 spt, 1024 bytes/sector, MFM"
|
||||
"NEC_35_HD_8",265,"3,5"", DS, HD, 77 tracks, 8 spt, 1024 bytes/sector, MFM, aka mode 3"
|
||||
"NEC_35_HD_15",266,"3,5"", DS, HD, 80 tracks, 15 spt, 512 bytes/sector, MFM"
|
||||
"NEC_35_TD",267,"3,5"", DS, TD, 240 tracks, 38 spt, 512 bytes/sector, MFM"
|
||||
"SHARP_525",NEC_525_HD,"5,25"", DS, HD, 77 tracks, 8 spt, 1024 bytes/sector, MFM"
|
||||
"SHARP_525_9",268,"3,5"", DS, HD, 80 tracks, 9 spt, 1024 bytes/sector, MFM"
|
||||
"SHARP_35",NEC_35_HD_8,"3,5"", DS, HD, 77 tracks, 8 spt, 1024 bytes/sector, MFM"
|
||||
"SHARP_35_9",269,"3,5"", DS, HD, 80 tracks, 9 spt, 1024 bytes/sector, MFM"
|
||||
"ECMA_99_8",270,"5,25"", DS, DD, 80 tracks, 8 spt, 1024 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128 bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector"
|
||||
"ECMA_99_15",271,"5,25"", DS, DD, 77 tracks, 15 spt, 512 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128 bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector"
|
||||
"ECMA_99_26",272,"5,25"", DS, DD, 77 tracks, 26 spt, 256 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128 bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector"
|
||||
"ECMA_100",DOS_35_DS_DD_9,"3,5"", DS, DD, 80 tracks, 9 spt, 512 bytes/sector, MFM"
|
||||
"ECMA_125",DOS_35_HD,"3,5"", DS, HD, 80 tracks, 18 spt, 512 bytes/sector, MFM"
|
||||
"ECMA_147",DOS_35_ED,"3,5"", DS, ED, 80 tracks, 36 spt, 512 bytes/sector, MFM"
|
||||
"ECMA_54",273,"8"", SS, SD, 77 tracks, 26 spt, 128 bytes/sector, FM"
|
||||
"ECMA_59",274,"8"", DS, SD, 77 tracks, 26 spt, 128 bytes/sector, FM"
|
||||
"ECMA_66",275,"5,25"", SS, DD, 35 tracks, 9 spt, 256 bytes/sector, FM, track 0 side 0 = 16 sectors, 128 bytes/sector"
|
||||
"ECMA_69_8",276,"8"", DS, DD, 77 tracks, 8 spt, 1024 bytes/sector, FM, track 0 side 0 = 26 sectors, 128 bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector"
|
||||
"ECMA_69_15",277,"8"", DS, DD, 77 tracks, 15 spt, 512 bytes/sector, FM, track 0 side 0 = 26 sectors, 128 bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector"
|
||||
"ECMA_69_26",278,"8"", DS, DD, 77 tracks, 26 spt, 256 bytes/sector, FM, track 0 side 0 = 26 sectors, 128 bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector"
|
||||
"ECMA_70",279,"5,25"", DS, DD, 40 tracks, 16 spt, 256 bytes/sector, FM, track 0 side 0 = 16 sectors, 128 bytes/sector, track 0 side 1 = 16 sectors, 256 bytes/sector"
|
||||
"ECMA_78",280,"5,25"", DS, DD, 80 tracks, 16 spt, 256 bytes/sector, FM, track 0 side 0 = 16 sectors, 128 bytes/sector, track 0 side 1 = 16 sectors, 256 bytes/sector"
|
||||
"ECMA_78_2",281,"5,25"", DS, DD, 80 tracks, 9 spt, 512 bytes/sector, FM"
|
||||
"FDFORMAT_525_DD",290,"5,25"", DS, DD, 82 tracks, 10 spt, 512 bytes/sector, MFM"
|
||||
"FDFORMAT_525_HD",291,"5,25"", DS, HD, 82 tracks, 17 spt, 512 bytes/sector, MFM"
|
||||
"FDFORMAT_35_DD",292,"3,5"", DS, DD, 82 tracks, 10 spt, 512 bytes/sector, MFM"
|
||||
"FDFORMAT_35_HD",293,"3,5"", DS, HD, 82 tracks, 21 spt, 512 bytes/sector, MFM"
|
||||
"Apricot_35",309,"3.5"", DS, DD, 70 tracks, 9 spt, 512 bytes/sector, MFM"
|
||||
"ADR2120",310,
|
||||
"ADR260",311,
|
||||
"ADR30",312,
|
||||
"ADR50",313,
|
||||
"AIT1",320,
|
||||
"AIT1Turbo",321,
|
||||
"AIT2",322,
|
||||
"AIT2Turbo",323,
|
||||
"AIT3",324,
|
||||
"AIT3Ex",325,
|
||||
"AIT3Turbo",326,
|
||||
"AIT4",327,
|
||||
"AIT5",328,
|
||||
"AITETurbo",329,
|
||||
"SAIT1",330,
|
||||
"SAIT2",331,
|
||||
"Bernoulli",340,"Obsolete type for 8""x11"" Bernoulli Box disk"
|
||||
"Bernoulli2",341,"Obsolete type for 5⅓"" Bernoulli Box II disks"
|
||||
"Ditto",342,
|
||||
"DittoMax",343,
|
||||
"Jaz",344,
|
||||
"Jaz2",345,
|
||||
"PocketZip",346,
|
||||
"REV120",347,
|
||||
"REV35",348,
|
||||
"REV70",349,
|
||||
"ZIP100",350,
|
||||
"ZIP250",351,
|
||||
"ZIP750",352,
|
||||
"Bernoulli35",353,"5⅓"" Bernoulli Box II disk with 35Mb capacity"
|
||||
"Bernoulli44",354,"5⅓"" Bernoulli Box II disk with 44Mb capacity"
|
||||
"Bernoulli65",355,"5⅓"" Bernoulli Box II disk with 65Mb capacity"
|
||||
"Bernoulli90",356,"5⅓"" Bernoulli Box II disk with 90Mb capacity"
|
||||
"Bernoulli105",357,"5⅓"" Bernoulli Box II disk with 105Mb capacity"
|
||||
"Bernoulli150",358,"5⅓"" Bernoulli Box II disk with 150Mb capacity"
|
||||
"Bernoulli230",359,"5⅓"" Bernoulli Box II disk with 230Mb capacity"
|
||||
"CompactCassette",360,
|
||||
"Data8",361,
|
||||
"MiniDV",362,
|
||||
"Dcas25",363,"D/CAS-25: Digital data on Compact Cassette form factor, special magnetic media, 9-track"
|
||||
"Dcas85",364,"D/CAS-85: Digital data on Compact Cassette form factor, special magnetic media, 17-track"
|
||||
"Dcas103",365,"D/CAS-103: Digital data on Compact Cassette form factor, special magnetic media, 21-track"
|
||||
"CFast",370,
|
||||
"CompactFlash",371,
|
||||
"CompactFlashType2",372,
|
||||
"DigitalAudioTape",380,
|
||||
"DAT160",381,
|
||||
"DAT320",382,
|
||||
"DAT72",383,
|
||||
"DDS1",384,
|
||||
"DDS2",385,
|
||||
"DDS3",386,
|
||||
"DDS4",387,
|
||||
"CompactTapeI",390,
|
||||
"CompactTapeII",391,
|
||||
"DECtapeII",392,
|
||||
"DLTtapeIII",393,
|
||||
"DLTtapeIIIxt",394,
|
||||
"DLTtapeIV",395,
|
||||
"DLTtapeS4",396,
|
||||
"SDLT1",397,
|
||||
"SDLT2",398,
|
||||
"VStapeI",399,
|
||||
"Exatape15m",400,
|
||||
"Exatape22m",401,
|
||||
"Exatape22mAME",402,
|
||||
"Exatape28m",403,
|
||||
"Exatape40m",404,
|
||||
"Exatape45m",405,
|
||||
"Exatape54m",406,
|
||||
"Exatape75m",407,
|
||||
"Exatape76m",408,
|
||||
"Exatape80m",409,
|
||||
"Exatape106m",410,
|
||||
"Exatape160mXL",411,
|
||||
"Exatape112m",412,
|
||||
"Exatape125m",413,
|
||||
"Exatape150m",414,
|
||||
"Exatape170m",415,
|
||||
"Exatape225m",416,
|
||||
"ExpressCard34",420,
|
||||
"ExpressCard54",421,
|
||||
"PCCardTypeI",422,
|
||||
"PCCardTypeII",423,
|
||||
"PCCardTypeIII",424,
|
||||
"PCCardTypeIV",425,
|
||||
"EZ135",430,"SyQuest 135Mb cartridge for use in EZ135 and EZFlyer drives"
|
||||
"EZ230",431,"SyQuest EZFlyer 230Mb cartridge for use in EZFlyer drive"
|
||||
"Quest",432,"SyQuest 4.7Gb for use in Quest drive"
|
||||
"SparQ",433,"SyQuest SparQ 1Gb cartridge"
|
||||
"SQ100",434,"SyQuest 5Mb cartridge for SQ306RD drive"
|
||||
"SQ200",435,"SyQuest 10Mb cartridge for SQ312RD drive"
|
||||
"SQ300",436,"SyQuest 15Mb cartridge for SQ319RD drive"
|
||||
"SQ310",437,"SyQuest 105Mb cartridge for SQ3105 and SQ3270 drives"
|
||||
"SQ327",438,"SyQuest 270Mb cartridge for SQ3270 drive"
|
||||
"SQ400",439,"SyQuest 44Mb cartridge for SQ555, SQ5110 and SQ5200C/SQ200 drives"
|
||||
"SQ800",440,"SyQuest 88Mb cartridge for SQ5110 and SQ5200C/SQ200 drives"
|
||||
"SQ1500",441,"SyQuest 1.5Gb cartridge for SyJet drive"
|
||||
"SQ2000",442,"SyQuest 200Mb cartridge for use in SQ5200C drive"
|
||||
"SyJet",443,"SyQuest 1.5Gb cartridge for SyJet drive"
|
||||
"FamicomGamePak",450,
|
||||
"GameBoyAdvanceGamePak",451,
|
||||
"GameBoyGamePak",452,
|
||||
"GOD",453,"Nintendo GameCube Optical Disc"
|
||||
"N64DD",454,
|
||||
"N64GamePak",455,
|
||||
"NESGamePak",456,
|
||||
"Nintendo3DSGameCard",457,
|
||||
"NintendoDiskCard",458,
|
||||
"NintendoDSGameCard",459,
|
||||
"NintendoDSiGameCard",460,
|
||||
"SNESGamePak",461,
|
||||
"SNESGamePakUS",462,
|
||||
"WOD",463,"Nintendo Wii Optical Disc"
|
||||
"WUOD",464,"Nintendo Wii U Optical Disc"
|
||||
"SwitchGameCard",465,
|
||||
"IBM3470",470,
|
||||
"IBM3480",471,
|
||||
"IBM3490",472,
|
||||
"IBM3490E",473,
|
||||
"IBM3592",474,
|
||||
"LTO",480,
|
||||
"LTO2",481,
|
||||
"LTO3",482,
|
||||
"LTO3WORM",483,
|
||||
"LTO4",484,
|
||||
"LTO4WORM",485,
|
||||
"LTO5",486,
|
||||
"LTO5WORM",487,
|
||||
"LTO6",488,
|
||||
"LTO6WORM",489,
|
||||
"LTO7",490,
|
||||
"LTO7WORM",491,
|
||||
"MemoryStick",510,
|
||||
"MemoryStickDuo",511,
|
||||
"MemoryStickMicro",512,
|
||||
"MemoryStickPro",513,
|
||||
"MemoryStickProDuo",514,
|
||||
"microSD",520,
|
||||
"miniSD",521,
|
||||
"SecureDigital",522,
|
||||
"MMC",530,
|
||||
"MMCmicro",531,
|
||||
"RSMMC",532,
|
||||
"MMCplus",533,
|
||||
"MMCmobile",534,
|
||||
"MLR1",540,
|
||||
"MLR1SL",541,
|
||||
"MLR3",542,
|
||||
"SLR1",543,
|
||||
"SLR2",544,
|
||||
"SLR3",545,
|
||||
"SLR32",546,
|
||||
"SLR32SL",547,
|
||||
"SLR4",548,
|
||||
"SLR5",549,
|
||||
"SLR5SL",550,
|
||||
"SLR6",551,
|
||||
"SLRtape7",552,
|
||||
"SLRtape7SL",553,
|
||||
"SLRtape24",554,
|
||||
"SLRtape24SL",555,
|
||||
"SLRtape40",556,
|
||||
"SLRtape50",557,
|
||||
"SLRtape60",558,
|
||||
"SLRtape75",559,
|
||||
"SLRtape100",560,
|
||||
"SLRtape140",561,
|
||||
"QIC11",570,
|
||||
"QIC120",571,
|
||||
"QIC1350",572,
|
||||
"QIC150",573,
|
||||
"QIC24",574,
|
||||
"QIC3010",575,
|
||||
"QIC3020",576,
|
||||
"QIC3080",577,
|
||||
"QIC3095",578,
|
||||
"QIC320",579,
|
||||
"QIC40",580,
|
||||
"QIC525",581,
|
||||
"QIC80",582,
|
||||
"STK4480",590,
|
||||
"STK4490",591,
|
||||
"STK9490",592,
|
||||
"T9840A",593,
|
||||
"T9840B",594,
|
||||
"T9840C",595,
|
||||
"T9840D",596,
|
||||
"T9940A",597,
|
||||
"T9940B",598,
|
||||
"T10000A",599,
|
||||
"T10000B",600,
|
||||
"T10000C",601,
|
||||
"T10000D",602,
|
||||
"Travan",610,
|
||||
"Travan1Ex",611,
|
||||
"Travan3",612,
|
||||
"Travan3Ex",613,
|
||||
"Travan4",614,
|
||||
"Travan5",615,
|
||||
"Travan7",616,
|
||||
"VXA1",620,
|
||||
"VXA2",621,
|
||||
"VXA3",622,
|
||||
"ECMA_153",630,"5,25"", M.O., WORM, 650Mb, 318750 sectors, 1024 bytes/sector, ECMA-153, ISO 11560"
|
||||
"ECMA_153_512",631,"5,25"", M.O., WORM, 600Mb, 581250 sectors, 512 bytes/sector, ECMA-153, ISO 11560"
|
||||
"ECMA_154",632,"3,5"", M.O., RW, 128Mb, 248826 sectors, 512 bytes/sector, ECMA-154, ISO 10090"
|
||||
"ECMA_183_512",633,"5,25"", M.O., RW/WORM, 1Gb, 904995 sectors, 512 bytes/sector, ECMA-183, ISO 13481"
|
||||
"ECMA_183",634,"5,25"", M.O., RW/WORM, 1Gb, 498526 sectors, 1024 bytes/sector, ECMA-183, ISO 13481"
|
||||
"ECMA_184_512",635,"5,25"", M.O., RW/WORM, 1.2Gb, 1165600 sectors, 512 bytes/sector, ECMA-184, ISO 13549"
|
||||
"ECMA_184",636,"5,25"", M.O., RW/WORM, 1.3Gb, 639200 sectors, 1024 bytes/sector, ECMA-184, ISO 13549"
|
||||
"ECMA_189",637,"300mm, M.O., WORM, ??? sectors, 1024 bytes/sector, ECMA-189, ISO 13614"
|
||||
"ECMA_190",638,"300mm, M.O., WORM, ??? sectors, 1024 bytes/sector, ECMA-190, ISO 13403"
|
||||
"ECMA_195",639,"5,25"", M.O., RW/WORM, 936921 or 948770 sectors, 1024 bytes/sector, ECMA-195, ISO 13842"
|
||||
"ECMA_195_512",640,"5,25"", M.O., RW/WORM, 1644581 or 1647371 sectors, 512 bytes/sector, ECMA-195, ISO 13842"
|
||||
"ECMA_201",641,"3,5"", M.O., 446325 sectors, 512 bytes/sector, ECMA-201, ISO 13963"
|
||||
"ECMA_201_ROM",642,"3,5"", M.O., 429975 sectors, 512 bytes/sector, embossed, ISO 13963"
|
||||
"ECMA_223",643,"3,5"", M.O., 371371 sectors, 1024 bytes/sector, ECMA-223"
|
||||
"ECMA_223_512",644,"3,5"", M.O., 694929 sectors, 512 bytes/sector, ECMA-223"
|
||||
"ECMA_238",645,"5,25"", M.O., 1244621 sectors, 1024 bytes/sector, ECMA-238, ISO 15486"
|
||||
"ECMA_239",646,"3,5"", M.O., 310352, 320332 or 321100 sectors, 2048 bytes/sector, ECMA-239, ISO 15498"
|
||||
"ECMA_260",647,"356mm, M.O., 14476734 sectors, 1024 bytes/sector, ECMA-260, ISO 15898"
|
||||
"ECMA_260_Double",648,"356mm, M.O., 24445990 sectors, 1024 bytes/sector, ECMA-260, ISO 15898"
|
||||
"ECMA_280",649,"5,25"", M.O., 1128134 sectors, 2048 bytes/sector, ECMA-280, ISO 18093"
|
||||
"ECMA_317",650,"300mm, M.O., 7355716 sectors, 2048 bytes/sector, ECMA-317, ISO 20162"
|
||||
"ECMA_322",651,"5,25"", M.O., 1095840 sectors, 4096 bytes/sector, ECMA-322, ISO 22092, 9.1Gb/cart"
|
||||
"ECMA_322_2k",652,"5,25"", M.O., 2043664 sectors, 2048 bytes/sector, ECMA-322, ISO 22092, 8.6Gb/cart"
|
||||
"GigaMo",653,"3,5"", M.O., 605846 sectors, 2048 bytes/sector, Cherry Book, GigaMo, ECMA-351, ISO 17346"
|
||||
"GigaMo2",654,"3,5"", M.O., 1063146 sectors, 2048 bytes/sector, Cherry Book 2, GigaMo 2, ECMA-353, ISO 22533"
|
||||
"ISO_15286",655,"5,25"", M.O., 1263472 sectors, 2048 bytes/sector, ISO 15286, 5.2Gb/cart"
|
||||
"ISO_15286_1024",656,"5,25"", M.O., 2319786 sectors, 1024 bytes/sector, ISO 15286, 4.8Gb/cart"
|
||||
"ISO_15286_512",657,"5,25"", M.O., ??????? sectors, 512 bytes/sector, ISO 15286, 4.1Gb/cart"
|
||||
"ISO_10089",658,"5,25"", M.O., 314569 sectors, 1024 bytes/sector, ISO 10089, 650Mb/cart"
|
||||
"ISO_10089_512",659,"5,25"", M.O., ?????? sectors, 512 bytes/sector, ISO 10089, 594Mb/cart"
|
||||
"CompactFloppy",660,
|
||||
"DemiDiskette",661,
|
||||
"Floptical",662,"3.5"", 652 tracks, 2 sides, 512 bytes/sector, Floptical, ECMA-207, ISO 14169"
|
||||
"HiFD",663,
|
||||
"QuickDisk",664,
|
||||
"UHD144",665,
|
||||
"VideoFloppy",666,
|
||||
"Wafer",667,
|
||||
"ZXMicrodrive",668,
|
||||
"BeeCard",670,
|
||||
"Borsu",671,
|
||||
"DataStore",672,
|
||||
"DIR",673,
|
||||
"DST",674,
|
||||
"DTF",675,
|
||||
"DTF2",676,
|
||||
"Flextra3020",677,
|
||||
"Flextra3225",678,
|
||||
"HiTC1",679,
|
||||
"HiTC2",680,
|
||||
"LT1",681,
|
||||
"MiniCard",872,
|
||||
"Orb",683,
|
||||
"Orb5",684,
|
||||
"SmartMedia",685,
|
||||
"xD",686,
|
||||
"XQD",687,
|
||||
"DataPlay",688,
|
||||
"AppleProfile",690,
|
||||
"AppleWidget",691,
|
||||
"AppleHD20",692,
|
||||
"PriamDataTower",693,
|
||||
"Pippin",694,
|
||||
"RA60",700,"2382 cylinders, 4 tracks/cylinder, 42 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 204890112 bytes"
|
||||
"RA80",701,"546 cylinders, 14 tracks/cylinder, 31 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 121325568 bytes"
|
||||
"RA81",702,"1248 cylinders, 14 tracks/cylinder, 51 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 456228864 bytes"
|
||||
"RC25",703,"302 cylinders, 4 tracks/cylinder, 42 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 25976832 bytes"
|
||||
"RD31",704,"615 cylinders, 4 tracks/cylinder, 17 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 21411840 bytes"
|
||||
"RD32",705,"820 cylinders, 6 tracks/cylinder, 17 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 42823680 bytes"
|
||||
"RD51",706,"306 cylinders, 4 tracks/cylinder, 17 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 10653696 bytes"
|
||||
"RD52",707,"480 cylinders, 7 tracks/cylinder, 18 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 30965760 bytes"
|
||||
"RD53",708,"1024 cylinders, 7 tracks/cylinder, 18 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 75497472 bytes"
|
||||
"RD54",709,"1225 cylinders, 8 tracks/cylinder, 18 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 159936000 bytes"
|
||||
"RK06",710,"411 cylinders, 3 tracks/cylinder, 22 sectors/track, 256 words/sector, 16 bits/word, 512 bytes/sector, 13888512 bytes"
|
||||
"RK06_18",711,"411 cylinders, 3 tracks/cylinder, 20 sectors/track, 256 words/sector, 18 bits/word, 576 bytes/sector, 14204160 bytes"
|
||||
"RK07",712,"815 cylinders, 3 tracks/cylinder, 22 sectors/track, 256 words/sector, 16 bits/word, 512 bytes/sector, 27540480 bytes"
|
||||
"RK07_18",713,"815 cylinders, 3 tracks/cylinder, 20 sectors/track, 256 words/sector, 18 bits/word, 576 bytes/sector, 28166400 bytes"
|
||||
"RM02",714,"823 cylinders, 5 tracks/cylinder, 32 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 67420160 bytes"
|
||||
"RM03",715,"823 cylinders, 5 tracks/cylinder, 32 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 67420160 bytes"
|
||||
"RM05",716,"823 cylinders, 19 tracks/cylinder, 32 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 256196608 bytes"
|
||||
"RP02",717,"203 cylinders, 10 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 22865920 bytes"
|
||||
"RP02_18",718,"203 cylinders, 10 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 bytes/sector, 23385600 bytes"
|
||||
"RP03",719,"400 cylinders, 10 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 45056000 bytes"
|
||||
"RP03_18",720,"400 cylinders, 10 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 bytes/sector, 46080000 bytes"
|
||||
"RP04",721,"411 cylinders, 19 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 87960576 bytes"
|
||||
"RP04_18",722,"411 cylinders, 19 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 bytes/sector, 89959680 bytes"
|
||||
"RP05",723,"411 cylinders, 19 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 87960576 bytes"
|
||||
"RP05_18",724,"411 cylinders, 19 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 bytes/sector, 89959680 bytes"
|
||||
"RP06",725,"815 cylinders, 19 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 174423040 bytes"
|
||||
"RP06_18",726,"815 cylinders, 19 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 bytes/sector, 178387200 bytes"
|
||||
"LS120",730,
|
||||
"LS240",731,
|
||||
"FD32MB",732,
|
||||
"RDX",733,
|
||||
"RDX320",734,"Imation 320Gb RDX"
|
||||
"VideoNow",740,
|
||||
"VideoNowColor",741,
|
||||
"VideoNowXp",742,
|
||||
"Bernoulli10",750,"8""x11"" Bernoulli Box disk with 10Mb capacity"
|
||||
"Bernoulli20",751,"8""x11"" Bernoulli Box disk with 20Mb capacity"
|
||||
"BernoulliBox2_20",752,"5⅓"" Bernoulli Box II disk with 20Mb capacity"
|
||||
"KodakVerbatim3",760,
|
||||
"KodakVerbatim6",761,
|
||||
"KodakVerbatim12",762,
|
||||
"ProfessionalDisc",770,"Professional Disc for video, single layer, rewritable, 23Gb"
|
||||
"ProfessionalDiscDual",771,"Professional Disc for video, dual layer, rewritable, 50Gb"
|
||||
"ProfessionalDiscTriple",772,"Professional Disc for video, triple layer, rewritable, 100Gb"
|
||||
"ProfessionalDiscQuad",773,"Professional Disc for video, quad layer, write once, 128Gb"
|
||||
"PDD",774,"Professional Disc for DATA, single layer, rewritable, 23Gb"
|
||||
"PDD_WORM",775,"Professional Disc for DATA, single layer, write once, 23Gb"
|
||||
"ArchivalDisc",776,"Archival Disc, 1st gen., 300Gb"
|
||||
"ArchivalDisc2",777,"Archival Disc, 2nd gen., 500Gb"
|
||||
"ArchivalDisc3",778,"Archival Disc, 3rd gen., 1Tb"
|
||||
"ODC300R",779,"Optical Disc archive, 1st gen., write once, 300Gb"
|
||||
"ODC300RE",780,"Optical Disc archive, 1st gen., rewritable, 300Gb"
|
||||
"ODC600R",781,"Optical Disc archive, 2nd gen., write once, 600Gb"
|
||||
"ODC600RE",782,"Optical Disc archive, 2nd gen., rewritable, 600Gb"
|
||||
"ODC1200RE",783,"Optical Disc archive, 3rd gen., rewritable, 1200Gb"
|
||||
"ODC1500R",784,"Optical Disc archive, 3rd gen., write once, 1500Gb"
|
||||
"ODC3300R",785,"Optical Disc archive, 4th gen., write once, 3300Gb"
|
||||
"ODC5500R",786,"Optical Disc archive, 5th gen., write once, 5500Gb"
|
||||
"ECMA_322_1k",800,"5,25"", M.O., 4383356 sectors, 1024 bytes/sector, ECMA-322, ISO 22092, 9.1Gb/cart"
|
||||
"ECMA_322_512",801,"5,25"", M.O., ??????? sectors, 512 bytes/sector, ECMA-322, ISO 22092, 9.1Gb/cart"
|
||||
"ISO_14517",802,"5,25"", M.O., 1273011 sectors, 1024 bytes/sector, ISO 14517, 2.6Gb/cart"
|
||||
"ISO_14517_512",803,"5,25"", M.O., 2244958 sectors, 512 bytes/sector, ISO 14517, 2.3Gb/cart"
|
||||
|
Binary file not shown.
@@ -1,73 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : FromAta.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Aaru common types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.CommonTypes
|
||||
{
|
||||
public static partial class MediaTypeFromDevice
|
||||
{
|
||||
/// <summary>Gets the media type from an ATA (not ATAPI) device</summary>
|
||||
/// <param name="manufacturer">Manufacturer string</param>
|
||||
/// <param name="model">Model string</param>
|
||||
/// <param name="removable">Is the device removable?</param>
|
||||
/// <param name="compactFlash">Does the device self-identify as CompactFlash?</param>
|
||||
/// <param name="pcmcia">Is the device attached thru PCMCIA or CardBus?</param>
|
||||
/// <param name="blocks">Number of blocks in device</param>
|
||||
/// <returns>The media type</returns>
|
||||
public static MediaType GetFromAta(string manufacturer, string model, bool removable, bool compactFlash,
|
||||
bool pcmcia, ulong blocks)
|
||||
{
|
||||
if(!removable)
|
||||
{
|
||||
if(compactFlash)
|
||||
return MediaType.CompactFlash;
|
||||
|
||||
return pcmcia ? MediaType.PCCardTypeI : MediaType.GENERIC_HDD;
|
||||
}
|
||||
|
||||
if(manufacturer.ToLowerInvariant() == "syquest" &&
|
||||
model.ToLowerInvariant() == "sparq" &&
|
||||
blocks == 1961069)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is SyQuest, media has 1961069 blocks of 512 bytes, setting media type to SparQ.");
|
||||
|
||||
return MediaType.SparQ;
|
||||
}
|
||||
|
||||
return MediaType.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : FromMmc.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Aaru common types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.CommonTypes
|
||||
{
|
||||
/// <summary>Gets the media type from a real device</summary>
|
||||
public static partial class MediaTypeFromDevice
|
||||
{
|
||||
/// <summary>Gets the media type from an SCSI MultiMedia Commands compliant device</summary>
|
||||
/// <param name="model">Model string</param>
|
||||
/// <param name="mediumType">Medium type from MODE SENSE</param>
|
||||
/// <param name="densityCode">Density code from MODE SENSE</param>
|
||||
/// <param name="blocks">Number of blocks in media</param>
|
||||
/// <param name="blockSize">Size of a block in bytes</param>
|
||||
/// <param name="isUsb">Is the device USB attached</param>
|
||||
/// <param name="opticalDisc">Is the media an optical disc</param>
|
||||
/// <returns>Media type</returns>
|
||||
static MediaType GetFromMmc(string model, byte mediumType, byte densityCode, ulong blocks, uint blockSize,
|
||||
bool isUsb, bool opticalDisc)
|
||||
{
|
||||
switch(mediumType)
|
||||
{
|
||||
case 0x00:
|
||||
if(blockSize == 512)
|
||||
if(blocks == 1281856)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to WORM PD-650.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.PD650_WORM;
|
||||
}
|
||||
else
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to PD-650.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.PD650;
|
||||
}
|
||||
else
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, setting media type to Compact Disc.",
|
||||
mediumType);
|
||||
|
||||
return MediaType.CD;
|
||||
}
|
||||
case 0x01:
|
||||
case 0x05:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, setting media type to CD-ROM.",
|
||||
mediumType);
|
||||
|
||||
return MediaType.CDROM;
|
||||
case 0x02:
|
||||
case 0x06:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, setting media type to Compact Disc Digital Audio.",
|
||||
mediumType);
|
||||
|
||||
return MediaType.CDDA;
|
||||
case 0x03:
|
||||
case 0x07:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, setting media type to CD+.", mediumType);
|
||||
|
||||
return MediaType.CDPLUS;
|
||||
case 0x04:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, setting media type to Photo CD.",
|
||||
mediumType);
|
||||
|
||||
return MediaType.PCD;
|
||||
case 0x10:
|
||||
case 0x11:
|
||||
case 0x12:
|
||||
case 0x13:
|
||||
case 0x14:
|
||||
case 0x15:
|
||||
case 0x16:
|
||||
case 0x17:
|
||||
case 0x18:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, setting media type to CD-R.", mediumType);
|
||||
|
||||
return MediaType.CDR;
|
||||
case 0x20:
|
||||
case 0x21:
|
||||
case 0x22:
|
||||
case 0x23:
|
||||
case 0x24:
|
||||
case 0x25:
|
||||
case 0x26:
|
||||
case 0x27:
|
||||
case 0x28:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, setting media type to CD-RW.", mediumType);
|
||||
|
||||
return MediaType.CDRW;
|
||||
case 0x40 when isUsb && !opticalDisc:
|
||||
case 0x41 when isUsb && !opticalDisc:
|
||||
case 0x42 when isUsb && !opticalDisc:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h and device is USB, setting media type to Flash Drive.",
|
||||
mediumType);
|
||||
|
||||
return MediaType.FlashDrive;
|
||||
case 0x80:
|
||||
if(model.ToLowerInvariant().StartsWith("ult", StringComparison.Ordinal))
|
||||
switch(densityCode)
|
||||
{
|
||||
case 0x42:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, density code is {1:X2}h, drive starts with \"ult\", setting media type to LTO-2.",
|
||||
mediumType, densityCode);
|
||||
|
||||
return MediaType.LTO2;
|
||||
case 0x44:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, density code is {1:X2}h, drive starts with \"ult\", setting media type to LTO-2.",
|
||||
mediumType, densityCode);
|
||||
|
||||
return MediaType.LTO3;
|
||||
case 0x46:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, density code is {1:X2}h, drive starts with \"ult\", setting media type to LTO-2.",
|
||||
mediumType, densityCode);
|
||||
|
||||
return MediaType.LTO4;
|
||||
case 0x58:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, density code is {1:X2}h, drive starts with \"ult\", setting media type to LTO-2.",
|
||||
mediumType, densityCode);
|
||||
|
||||
return MediaType.LTO5;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return MediaType.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,336 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : FromOdc.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Aaru common types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.CommonTypes
|
||||
{
|
||||
public static partial class MediaTypeFromDevice
|
||||
{
|
||||
/// <summary>Gets the device type from a SCSI Optical Device</summary>
|
||||
/// <param name="mediumType">Medium type from MODE SENSE</param>
|
||||
/// <param name="blocks">Number of blocks in device</param>
|
||||
/// <param name="blockSize">Size in bytes of a block</param>
|
||||
/// <returns>Media type</returns>
|
||||
static MediaType GetFromOdc(byte mediumType, ulong blocks, uint blockSize)
|
||||
{
|
||||
if(mediumType != 0x01 &&
|
||||
mediumType != 0x02 &&
|
||||
mediumType != 0x03 &&
|
||||
mediumType != 0x05 &&
|
||||
mediumType != 0x07)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, setting media type to unknown magneto-optical.",
|
||||
mediumType);
|
||||
|
||||
return MediaType.UnknownMO;
|
||||
}
|
||||
|
||||
switch(blockSize)
|
||||
{
|
||||
case 512:
|
||||
{
|
||||
switch(blocks)
|
||||
{
|
||||
case 248826:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-154 / ISO 10090 conforming 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_154;
|
||||
case 429975:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-201 / ISO 13963 conforming 3½\" embossed magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_201_ROM;
|
||||
case 446325:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-201 / ISO 13963 conforming 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_201;
|
||||
case 694929:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-223 conforming 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_223_512;
|
||||
case 904995:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-183 / ISO 13481 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_183_512;
|
||||
case 1128772:
|
||||
case 1163337:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-184 / ISO 13549 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_184_512;
|
||||
case 1281856:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to WORM PD-650.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.PD650_WORM;
|
||||
case 1298496:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to PD-650.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.PD650;
|
||||
case 1644581:
|
||||
case 1647371:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-195 / ISO 13842 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_195_512;
|
||||
case 2244958:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ISO 14517 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ISO_14517_512;
|
||||
default:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to unknown magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.UnknownMO;
|
||||
}
|
||||
}
|
||||
|
||||
case 1024:
|
||||
{
|
||||
switch(blocks)
|
||||
{
|
||||
case 314569:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ISO 10089 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ISO_10089;
|
||||
case 371371:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-223 conforming 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_223;
|
||||
case 498526:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-184 / ISO 13549 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_183;
|
||||
case 603466:
|
||||
case 637041:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-184 / ISO 13549 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_184;
|
||||
case 936921:
|
||||
case 948770:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-195 / ISO 13842 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_195;
|
||||
case 1244621:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-238 / ISO 15486 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_238;
|
||||
case 1273011:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ISO 14517 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ISO_14517;
|
||||
case 2319786:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ISO 15286 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ISO_15286_1024;
|
||||
case 4383356:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-322 / ISO 22092 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_322_1k;
|
||||
case 14476734:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-260 / ISO 15898 conforming 356mm magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_260;
|
||||
case 24445990:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-260 / ISO 15898 conforming 356mm magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_260_Double;
|
||||
default:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to unknown magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.UnknownMO;
|
||||
}
|
||||
}
|
||||
|
||||
case 2048:
|
||||
{
|
||||
switch(blocks)
|
||||
{
|
||||
case 310352: // Found in real media
|
||||
case 318988:
|
||||
case 320332:
|
||||
case 321100:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-239 / ISO 15498 conforming 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_239;
|
||||
case 605846:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to GigaMO 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.GigaMo;
|
||||
case 1063146:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to GigaMO 2 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.GigaMo2;
|
||||
case 1128134:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-280 / ISO 18093 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_280;
|
||||
case 1263472:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ISO 15286 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ISO_15286;
|
||||
case 2043664:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-322 / ISO 22092 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_322_2k;
|
||||
case 7355716:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-317 / ISO 20162 conforming 300mm magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_317;
|
||||
default:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to unknown magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.UnknownMO;
|
||||
}
|
||||
}
|
||||
|
||||
case 4096:
|
||||
{
|
||||
switch(blocks)
|
||||
{
|
||||
case 1095840:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-322 / ISO 22092 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_322;
|
||||
default:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to unknown magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.UnknownMO;
|
||||
}
|
||||
}
|
||||
|
||||
case 8192:
|
||||
{
|
||||
switch(blocks)
|
||||
{
|
||||
case 1834348:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to UDO.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.UDO;
|
||||
case 3668759:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to WORM UDO2.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.UDO2_WORM;
|
||||
case 3669724:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to UDO2.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.UDO2;
|
||||
default:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to unknown magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.UnknownMO;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to unknown magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.UnknownMO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,943 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : FromSbc.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Aaru common types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.CommonTypes
|
||||
{
|
||||
public static partial class MediaTypeFromDevice
|
||||
{
|
||||
/// <summary>Gets the media type from a SCSI Block Commands compliant device</summary>
|
||||
/// <param name="vendor">Vendor string</param>
|
||||
/// <param name="model">Model string</param>
|
||||
/// <param name="mediumType">Medium type from MODE SENSE</param>
|
||||
/// <param name="blocks">Number of blocks in device</param>
|
||||
/// <param name="blockSize">Size of a block in bytes</param>
|
||||
/// <returns>Media type</returns>
|
||||
static MediaType GetFromSbc(string vendor, string model, byte mediumType, ulong blocks, uint blockSize)
|
||||
{
|
||||
if(vendor.ToLowerInvariant() == "syquest" &&
|
||||
model.StartsWith("syjet", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is SyQuest, drive model is SyJet, setting media type to SyJet.");
|
||||
|
||||
return MediaType.SyJet;
|
||||
}
|
||||
|
||||
switch(mediumType)
|
||||
{
|
||||
case 0x09:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-54 formatted 8\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_54;
|
||||
case 0x0A:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-59 formatted 8\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_59;
|
||||
case 0x0B:
|
||||
switch(blockSize)
|
||||
{
|
||||
case 256:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-69 formatted 8\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_69_26;
|
||||
case 512:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-69 formatted 8\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_69_15;
|
||||
case 1024:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-69 formatted 8\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_69_8;
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to unknown.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.Unknown;
|
||||
case 0x0E:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-66 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_66;
|
||||
case 0x12:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-70 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_70;
|
||||
case 0x16:
|
||||
switch(blockSize)
|
||||
{
|
||||
case 256:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-78 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_78;
|
||||
case 512:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-78 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_78_2;
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to unknown.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.Unknown;
|
||||
case 0x1A:
|
||||
switch(blockSize)
|
||||
{
|
||||
case 256:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-99 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_99_26;
|
||||
case 512:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-99 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_99_15;
|
||||
case 1024:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-99 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_99_8;
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to unknown.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.Unknown;
|
||||
case 0x1E:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 3½\" double density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_35_DS_DD_9;
|
||||
case 0x41:
|
||||
switch(blocks)
|
||||
{
|
||||
case 58620544:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 120Gb REV.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.REV120;
|
||||
case 34185728:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 70Gb REV.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.REV70;
|
||||
case 17090880:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 35Gb REV.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.REV35;
|
||||
}
|
||||
|
||||
break;
|
||||
case 0x93:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to PC-98 formatted 3½\" high density floppy (15 sectors).",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.NEC_35_HD_15;
|
||||
case 0x94:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 3½\" high density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_35_HD;
|
||||
}
|
||||
|
||||
switch(blockSize)
|
||||
{
|
||||
case 128:
|
||||
switch(blocks)
|
||||
{
|
||||
case 720:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Atari formatted 5¼\" single density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ATARI_525_SD;
|
||||
case 1040:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Atari formatted 5¼\" double density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ATARI_525_DD;
|
||||
case 1898:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 8\" (33FD) floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.IBM33FD_128;
|
||||
case 2002:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-54 formatted 8\" single density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_54;
|
||||
case 3848:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 8\" (43FD) floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.IBM43FD_128;
|
||||
case 4004:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-59 formatted 8\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_59;
|
||||
}
|
||||
|
||||
break;
|
||||
case 256:
|
||||
switch(blocks)
|
||||
{
|
||||
case 322:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-56 formatted 5¼\" double density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_66;
|
||||
case 400:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Acorn formatted 5¼\" single density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ACORN_525_SS_SD_40;
|
||||
case 455:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Apple DOS 3.2 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.Apple32SS;
|
||||
case 560:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Apple DOS 3.3 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.Apple33SS;
|
||||
case 640:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Acorn formatted 5¼\" double density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ACORN_525_SS_DD_40;
|
||||
case 720:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Atari formatted 5¼\" double density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ATARI_525_DD;
|
||||
case 800:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Acorn formatted 5¼\" double density floppy (80 tracks).",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ACORN_525_SS_SD_80;
|
||||
case 910:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Apple DOS 3.2 formatted 5¼\" double sided floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.Apple32DS;
|
||||
case 1120:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Apple DOS 3.3 formatted 5¼\" double sided floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.Apple33DS;
|
||||
case 1121:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 8\" (33FD) floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.IBM33FD_256;
|
||||
case 1280 when mediumType == 0x01:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Acorn formatted 5¼\" double density floppy with 80 tracks.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ACORN_525_SS_DD_80;
|
||||
case 1280:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-70 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_70;
|
||||
case 2002:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to DEC RX02 floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.RX02;
|
||||
case 2560:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-78 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_78;
|
||||
case 3848:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 8\" (53FD) floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.IBM53FD_256;
|
||||
case 4004:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-99 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_99_26;
|
||||
case 39168 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase):
|
||||
case 41004 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is IOMEGA, media has {0} blocks of 256 bytes, setting media type to 10Mb Bernoulli Box.",
|
||||
blocks);
|
||||
|
||||
return MediaType.Bernoulli10;
|
||||
}
|
||||
|
||||
break;
|
||||
case 319:
|
||||
switch(blocks)
|
||||
{
|
||||
case 256:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 8\" (23FD) floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.IBM23FD;
|
||||
}
|
||||
|
||||
break;
|
||||
case 512:
|
||||
switch(blocks)
|
||||
{
|
||||
case 320:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 5¼\" double density single sided floppy (8 sectors).",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_525_SS_DD_8;
|
||||
case 360:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 5¼\" double density single sided floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_525_SS_DD_9;
|
||||
case 610:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 8\" (33FD) floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.IBM33FD_512;
|
||||
case 630 when mediumType == 0x01:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Apricot formatted 3½\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.Apricot_35;
|
||||
case 640 when mediumType == 0x01:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 3½\" double density single sided floppy (8 sectors).",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_35_SS_DD_8;
|
||||
case 640:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 5¼\" double density floppy (8 sectors).",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_525_DS_DD_8;
|
||||
case 720 when mediumType == 0x01:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 3½\" double density single sided floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_35_SS_DD_9;
|
||||
case 720:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 5¼\" double density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_525_DS_DD_9;
|
||||
case 800:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Apple formatted 3½\" double density single sided floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.AppleSonySS;
|
||||
case 1280:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 3½\" double density floppy (8 sectors).",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_35_DS_DD_8;
|
||||
case 1440:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 3½\" double density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_35_DS_DD_9;
|
||||
case 1640:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to FDFORMAT formatted 3½\" double density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.FDFORMAT_35_DD;
|
||||
case 1760:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Amiga formatted 3½\" double density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.CBM_AMIGA_35_DD;
|
||||
case 2242:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 8\" (53FD) floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.IBM53FD_512;
|
||||
case 2332:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-99 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_99_15;
|
||||
case 2400:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 5¼\" high density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_525_HD;
|
||||
case 2788:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to FDFORMAT formatted 5¼\" high density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.FDFORMAT_525_HD;
|
||||
case 2880:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 3½\" high density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_35_HD;
|
||||
case 3360:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Microsoft DMF formatted 3½\" high density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DMF;
|
||||
case 3444:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to FDFORMAT formatted 3½\" high density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.FDFORMAT_35_HD;
|
||||
case 3520:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Amiga formatted 3½\" high density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.CBM_AMIGA_35_HD;
|
||||
case 5760:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 3½\" extra density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.DOS_35_ED;
|
||||
case 40662 when mediumType == 0x20:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Floptical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.Floptical;
|
||||
case 65536 when model.ToLowerInvariant().StartsWith("ls-", StringComparison.Ordinal):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive model is LS (SuperDisk), media has 65536 blocks of 512 bytes, setting media type to FD32MB.");
|
||||
|
||||
return MediaType.FD32MB;
|
||||
case 78882 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is IOMEGA, media has 78882 blocks of 512 bytes, setting media type to PocketZIP.");
|
||||
|
||||
return MediaType.PocketZip;
|
||||
case 86700 when vendor.ToLowerInvariant() == "syquest":
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is SyQuest, media has 86700 blocks of 512 bytes, setting media type to SQ400.");
|
||||
|
||||
return MediaType.SQ400;
|
||||
case 87040 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is IOMEGA, media has 87040 blocks of 512 bytes, setting media type to 44Mb Bernoulli Box II.");
|
||||
|
||||
return MediaType.Bernoulli44;
|
||||
case 173456 when vendor.ToLowerInvariant() == "syquest":
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is SyQuest, media has 173456 blocks of 512 bytes, setting media type to SQ800.");
|
||||
|
||||
return MediaType.SQ800;
|
||||
case 175856 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is IOMEGA, media has 175856 blocks of 512 bytes, setting media type to 90Mb Bernoulli Box II.");
|
||||
|
||||
return MediaType.Bernoulli90;
|
||||
case 196608 when model.ToLowerInvariant().StartsWith("zip", StringComparison.OrdinalIgnoreCase):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is IOMEGA, drive model is ZIP, media has 196608 blocks of 512 bytes, setting media type to 100Mb ZIP.");
|
||||
|
||||
return MediaType.ZIP100;
|
||||
|
||||
case 215440 when vendor.ToLowerInvariant() == "syquest":
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is SyQuest, media has 215440 blocks of 512 bytes, setting media type to SQ310.");
|
||||
|
||||
return MediaType.SQ310;
|
||||
case 246528 when model.ToLowerInvariant().StartsWith("ls-", StringComparison.Ordinal):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive model is LS (SuperDisk), media has 246528 blocks of 512 bytes, setting media type to LS-120.");
|
||||
|
||||
return MediaType.LS120;
|
||||
case 248826 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-154 / ISO 10090 conforming 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_154;
|
||||
case 262144 when vendor.ToLowerInvariant() == "syquest":
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is SyQuest, media has 262144 blocks of 512 bytes, setting media type to EZ135.");
|
||||
|
||||
return MediaType.EZ135;
|
||||
case 294918 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is IOMEGA, media has 294918 blocks of 512 bytes, setting media type to 150Mb Bernoulli Box II.");
|
||||
|
||||
return MediaType.Bernoulli150;
|
||||
case 390696 when vendor.ToLowerInvariant() == "syquest":
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is SyQuest, media has 390696 blocks of 512 bytes, setting media type to SQ2000.");
|
||||
|
||||
return MediaType.SQ2000;
|
||||
case 393380 when model.ToLowerInvariant().StartsWith("hifd", StringComparison.Ordinal):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive model is HiFD, media has 393380 blocks of 512 bytes, setting media type to HiFD.",
|
||||
blocks, blockSize);
|
||||
|
||||
return MediaType.HiFD;
|
||||
case 429975 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-201 / ISO 13963 conforming 3½\" embossed magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_201_ROM;
|
||||
case 446325 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-201 / ISO 13963 conforming 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_201;
|
||||
case 450560 when vendor.ToLowerInvariant() == "syquest":
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is SyQuest, media has 450560 blocks of 512 bytes, setting media type to EZ230.");
|
||||
|
||||
return MediaType.EZ230;
|
||||
case 469504 when model.ToLowerInvariant().StartsWith("ls-", StringComparison.Ordinal):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive model is LS (SuperDisk), media has 469504 blocks of 512 bytes, setting media type to LS-240.");
|
||||
|
||||
return MediaType.LS240;
|
||||
case 489532 when model.ToLowerInvariant().StartsWith("zip", StringComparison.OrdinalIgnoreCase):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is IOMEGA, drive model is ZIP, media has 489532 blocks of 512 bytes, setting media type to 250Mb ZIP.");
|
||||
|
||||
return MediaType.ZIP250;
|
||||
case 524288 when vendor.ToLowerInvariant() == "syquest":
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is SyQuest, media has 524288 blocks of 512 bytes, setting media type to SQ327.");
|
||||
|
||||
return MediaType.SQ327;
|
||||
case 694929 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-223 conforming 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_223_512;
|
||||
case 904995 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-183 / ISO 13481 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_183_512;
|
||||
case 1128772 when mediumType == 0x01 || mediumType == 0x02:
|
||||
case 1163337 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-184 / ISO 13549 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_184_512;
|
||||
case 1281856 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to WORM PD-650.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.PD650_WORM;
|
||||
case 1298496 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to PD-650.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.PD650;
|
||||
case 1470500
|
||||
when model.ToLowerInvariant().StartsWith("zip", StringComparison.OrdinalIgnoreCase):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is IOMEGA, drive model is ZIP, media has 489532 blocks of 512 bytes, setting media type to 250Mb ZIP.");
|
||||
|
||||
return MediaType.ZIP750;
|
||||
case 1644581 when mediumType == 0x01 || mediumType == 0x02:
|
||||
case 1647371 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-195 / ISO 13842 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_195_512;
|
||||
case 1961069 when vendor.ToLowerInvariant() == "syquest":
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is SyQuest, media has 1961069 blocks of 512 bytes, setting media type to SparQ.");
|
||||
|
||||
return MediaType.SparQ;
|
||||
case 2091050 when model.ToLowerInvariant().StartsWith("jaz", StringComparison.Ordinal):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is IOMEGA, drive model is JAZ, media has 2091050 blocks of 512 bytes, setting media type to 1Gb JAZ.");
|
||||
|
||||
return MediaType.Jaz;
|
||||
case 2244958 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ISO 14517 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ISO_14517_512;
|
||||
case 3915600 when model.ToLowerInvariant().StartsWith("jaz", StringComparison.Ordinal):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive manufacturer is IOMEGA, drive model is JAZ, media has 3915600 blocks of 512 bytes, setting media type to 2Gb JAZ.");
|
||||
|
||||
return MediaType.Jaz2;
|
||||
case 4307184 when vendor.ToLowerInvariant().StartsWith("cws orb", StringComparison.Ordinal):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive model is Castlewood Orb, media has 4307184 blocks of 512 bytes, setting media type to Orb.");
|
||||
|
||||
return MediaType.Orb;
|
||||
case 625134256 when model.ToLowerInvariant().StartsWith("rdx", StringComparison.Ordinal):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive model is LS (SuperDisk), media has {0} blocks of {1} bytes, setting media type to unknown.",
|
||||
blocks, blockSize);
|
||||
|
||||
return MediaType.RDX320;
|
||||
}
|
||||
|
||||
break;
|
||||
case 1024:
|
||||
{
|
||||
switch(blocks)
|
||||
{
|
||||
case 800 when mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Acorn formatted 3½\" double density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ACORN_35_DS_DD;
|
||||
case 1220:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to IBM formatted 8\" (53FD) floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.IBM53FD_1024;
|
||||
case 1232 when model.ToLowerInvariant().StartsWith("ls-", StringComparison.Ordinal):
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"Drive model is LS (SuperDisk), media has 2880 blocks of 512 bytes, setting media type to PC-98 formatted 3½\" high density floppy.");
|
||||
|
||||
return MediaType.NEC_35_HD_8;
|
||||
case 1232:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Sharp formatted 3½\" high density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.SHARP_35;
|
||||
case 1268:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-69 formatted 8\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_69_8;
|
||||
case 1280:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to PC-98 formatted 5¼\" high density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.NEC_525_HD;
|
||||
case 1316:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-99 formatted 5¼\" floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_99_8;
|
||||
case 1600 when mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Acorn formatted 3½\" high density floppy.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ACORN_35_DS_HD;
|
||||
case 314569 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ISO 10089 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ISO_10089;
|
||||
case 371371 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-223 conforming 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_223;
|
||||
case 498526 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-183 / ISO 13481 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_183;
|
||||
case 603466 when mediumType == 0x01 || mediumType == 0x02:
|
||||
case 637041 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-184 / ISO 13549 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_184;
|
||||
case 936921 when mediumType == 0x01 || mediumType == 0x02:
|
||||
case 948770 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-195 / ISO 13842 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_195;
|
||||
case 1244621 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-238 / ISO 15486 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_238;
|
||||
case 1273011 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ISO 14517 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ISO_14517;
|
||||
case 2319786 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ISO 15286 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ISO_15286_1024;
|
||||
case 4383356 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-322 / ISO 22092 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_322_1k;
|
||||
case 14476734 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-260 / ISO 15898 conforming 356mm magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_260;
|
||||
case 24445990 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-260 / ISO 15898 conforming 356mm magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_260_Double;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 2048:
|
||||
{
|
||||
switch(blocks)
|
||||
{
|
||||
case 112311:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 60 minute MiniDisc.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.MD60;
|
||||
case 138363:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 74 minute MiniDisc.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.MD74;
|
||||
case 149373:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 80 minute MiniDisc.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.MD80;
|
||||
case 310352 when mediumType == 0x01 || mediumType == 0x02: // Found in real media
|
||||
case 318988 when mediumType == 0x01 || mediumType == 0x02:
|
||||
case 320332 when mediumType == 0x01 || mediumType == 0x02:
|
||||
case 321100 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-239 / ISO 15498 conforming 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_239;
|
||||
case 494023:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to Sony HiMD.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.HiMD;
|
||||
case 605846 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to GigaMO 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.GigaMo;
|
||||
case 1063146 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to GigaMO 2 3½\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.GigaMo2;
|
||||
case 1128134 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-280 / ISO 18093 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_280;
|
||||
case 1263472 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ISO 15286 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ISO_15286;
|
||||
case 2043664 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-322 / ISO 22092 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_322_2k;
|
||||
case 7355716 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-317 / ISO 20162 conforming 300mm magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_317;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 4096:
|
||||
{
|
||||
switch(blocks)
|
||||
{
|
||||
case 1095840 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to ECMA-322 / ISO 22092 conforming 5¼\" magneto-optical.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.ECMA_322;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 8192:
|
||||
{
|
||||
switch(blocks)
|
||||
{
|
||||
case 1834348 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to UDO.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.UDO;
|
||||
case 3668759 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to WORM UDO2.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.UDO2_WORM;
|
||||
case 3669724 when mediumType == 0x01 || mediumType == 0x02:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to UDO2.",
|
||||
mediumType, blocks, blockSize);
|
||||
|
||||
return MediaType.UDO2;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return MediaType.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : FromScsi.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Aaru common types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.CommonTypes
|
||||
{
|
||||
public static partial class MediaTypeFromDevice
|
||||
{
|
||||
/// <summary>Tries to guess, from SCSI information, the media type of a device and/or its inserted media</summary>
|
||||
/// <param name="scsiPeripheralType">The SCSI Peripheral Type as indicated in the INQUIRY response</param>
|
||||
/// <param name="vendor">The vendor string of the device</param>
|
||||
/// <param name="model">The model string of the device</param>
|
||||
/// <param name="mediumType">The medium type byte from MODE SENSE</param>
|
||||
/// <param name="densityCode">The density type byte from MODE SENSE</param>
|
||||
/// <param name="blocks">How many blocks are on the media</param>
|
||||
/// <param name="blockSize">Size in bytes of each block</param>
|
||||
/// <param name="isUsb">Device is USB</param>
|
||||
/// <param name="opticalDisc">Is media an optical disc?</param>
|
||||
/// <returns>The media type</returns>
|
||||
public static MediaType GetFromScsi(byte scsiPeripheralType, string vendor, string model, byte mediumType,
|
||||
byte densityCode, ulong blocks, uint blockSize, bool isUsb,
|
||||
bool opticalDisc)
|
||||
{
|
||||
switch(scsiPeripheralType)
|
||||
{
|
||||
// Direct access device
|
||||
case 0x00:
|
||||
// Simplified access device
|
||||
case 0x0E:
|
||||
if(mediumType == 0x03 ||
|
||||
mediumType == 0x05 ||
|
||||
mediumType == 0x07)
|
||||
goto case 0x07;
|
||||
|
||||
return GetFromSbc(vendor, model, mediumType, blocks, blockSize);
|
||||
|
||||
// Sequential access device
|
||||
case 0x01:
|
||||
return GetFromSsc(scsiPeripheralType, vendor, model, mediumType, densityCode, blocks, blockSize);
|
||||
|
||||
// Write-once device
|
||||
case 0x04:
|
||||
// Optical device
|
||||
case 0x07: return GetFromOdc(mediumType, blocks, blockSize);
|
||||
|
||||
// MultiMedia Device
|
||||
case 0x05: return GetFromMmc(model, mediumType, densityCode, blocks, blockSize, isUsb, opticalDisc);
|
||||
|
||||
// MD DATA drives
|
||||
case 0x10 when model.StartsWith("MDM", StringComparison.Ordinal) ||
|
||||
model.StartsWith("MDH", StringComparison.Ordinal):
|
||||
if(blockSize == 2048)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to MiniDisc for Data.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
return MediaType.MDData;
|
||||
}
|
||||
|
||||
switch(blocks)
|
||||
{
|
||||
case 57312:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 60 minute MiniDisc.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
return MediaType.MD60;
|
||||
case 70464:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 74 minute MiniDisc.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
return MediaType.MD74;
|
||||
case 76096:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 80 minute MiniDisc.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
return MediaType.MD80;
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 60 minute MiniDisc.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
return MediaType.MD;
|
||||
|
||||
// Host managed zoned block device
|
||||
case 0x14:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, setting media type to host managed zoned block device.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
return MediaType.Zone_HDD;
|
||||
}
|
||||
|
||||
return MediaType.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,58 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : CdOffset.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Device database.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Models Compact Disc read offset entries from AccurateRip database.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Aaru.CommonTypes.Metadata
|
||||
{
|
||||
/// <summary>Describes CD reading offset</summary>
|
||||
public class CdOffset
|
||||
{
|
||||
/// <summary>Drive manufacturer</summary>
|
||||
public string Manufacturer { get; set; }
|
||||
/// <summary>Drive model</summary>
|
||||
public string Model { get; set; }
|
||||
/// <summary>Reading offset</summary>
|
||||
public short Offset { get; set; }
|
||||
/// <summary>Number of times this offset has been submitted</summary>
|
||||
public int Submissions { get; set; }
|
||||
/// <summary>Percentage of submissions in agreement with this offset</summary>
|
||||
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:P0}")]
|
||||
public float Agreement { get; set; }
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,80 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Resume.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : XML metadata.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines XML format of a dump resume file.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.CommonTypes.Metadata
|
||||
{
|
||||
/// <summary>Information that allows to resume a dump</summary>
|
||||
[Serializable, XmlRoot("DicResume", Namespace = "", IsNullable = false)]
|
||||
public class Resume
|
||||
{
|
||||
/// <summary>List of blocks that returned an error on reading</summary>
|
||||
[XmlArrayItem("Block")]
|
||||
public List<ulong> BadBlocks;
|
||||
/// <summary>Date/time this resume file was created</summary>
|
||||
[XmlElement(DataType = "dateTime")]
|
||||
public DateTime CreationDate;
|
||||
/// <summary>Last block on media</summary>
|
||||
public ulong LastBlock;
|
||||
/// <summary>Date/time this resume file was last written to</summary>
|
||||
[XmlElement(DataType = "dateTime")]
|
||||
public DateTime LastWriteDate;
|
||||
/// <summary>Next block to read</summary>
|
||||
public ulong NextBlock;
|
||||
/// <summary>Is media removable?</summary>
|
||||
public bool Removable;
|
||||
/// <summary>Is media a tape?</summary>
|
||||
public bool Tape;
|
||||
/// <summary>List of CD subchannels that did not read correctly</summary>
|
||||
[XmlArrayItem("Block")]
|
||||
public List<int> BadSubchannels;
|
||||
/// <summary>Extents of BLANK sectors for magneto-opticals</summary>
|
||||
[XmlArrayItem("Extent")]
|
||||
public ExtentType[] BlankExtents;
|
||||
/// <summary>Title keys that has not been read</summary>
|
||||
[XmlArrayItem("Block")]
|
||||
public List<ulong> MissingTitleKeys;
|
||||
/// <summary>List of dump tries</summary>
|
||||
[XmlArrayItem("DumpTry")]
|
||||
public List<DumpHardwareType> Tries;
|
||||
}
|
||||
}
|
||||
@@ -1,309 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Statistics.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : XML metadata.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Define XML for statistics.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
// ReSharper disable ClassNeverInstantiated.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
namespace Aaru.CommonTypes.Metadata
|
||||
{
|
||||
/// <summary>Statistics</summary>
|
||||
[XmlRoot("DicStats", Namespace = "", IsNullable = false)]
|
||||
public class Stats
|
||||
{
|
||||
/// <summary>Executed commands</summary>
|
||||
public CommandsStats Commands;
|
||||
/// <summary>Operating systems Aaru has run from</summary>
|
||||
[XmlArrayItem("OperatingSystem")]
|
||||
public List<OsStats> OperatingSystems { get; set; }
|
||||
/// <summary>Aaru versions</summary>
|
||||
[XmlArrayItem("Version")]
|
||||
public List<NameValueStats> Versions { get; set; }
|
||||
/// <summary>Detected filesystems</summary>
|
||||
[XmlArrayItem("Filesystem")]
|
||||
public List<NameValueStats> Filesystems { get; set; }
|
||||
/// <summary>Detected partitioning schemes</summary>
|
||||
[XmlArrayItem("Scheme")]
|
||||
public List<NameValueStats> Partitions { get; set; }
|
||||
/// <summary>Media image formats</summary>
|
||||
[XmlArrayItem("Format")]
|
||||
public List<NameValueStats> MediaImages { get; set; }
|
||||
/// <summary>Used filters</summary>
|
||||
[XmlArrayItem("Filter", IsNullable = true)]
|
||||
public List<NameValueStats> Filters { get; set; }
|
||||
/// <summary>Found devices</summary>
|
||||
[XmlArrayItem("Device", IsNullable = true)]
|
||||
public List<DeviceStats> Devices { get; set; }
|
||||
/// <summary>Found media types, real, and in image</summary>
|
||||
[XmlArrayItem("Media")]
|
||||
public List<MediaStats> Medias { get; set; }
|
||||
/// <summary>Benchmark statistics</summary>
|
||||
public BenchmarkStats Benchmark { get; set; }
|
||||
/// <summary>Media scanning statistics</summary>
|
||||
public MediaScanStats MediaScan { get; set; }
|
||||
/// <summary>Image verification statistics</summary>
|
||||
public VerifyStats Verify { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>DTO for statistics</summary>
|
||||
[SuppressMessage("ReSharper", "CollectionNeverQueried.Global")]
|
||||
public class StatsDto
|
||||
{
|
||||
/// <summary>Executed commands</summary>
|
||||
public List<NameValueStats> Commands { get; set; }
|
||||
/// <summary>Operating systems Aaru has run from</summary>
|
||||
public List<OsStats> OperatingSystems { get; set; }
|
||||
/// <summary>Aaru versions</summary>
|
||||
public List<NameValueStats> Versions { get; set; }
|
||||
/// <summary>Detected filesystems</summary>
|
||||
public List<NameValueStats> Filesystems { get; set; }
|
||||
/// <summary>Detected partitioning schemes</summary>
|
||||
public List<NameValueStats> Partitions { get; set; }
|
||||
/// <summary>Media image formats</summary>
|
||||
public List<NameValueStats> MediaFormats { get; set; }
|
||||
/// <summary>Used filters</summary>
|
||||
public List<NameValueStats> Filters { get; set; }
|
||||
/// <summary>Found devices</summary>
|
||||
public List<DeviceStats> Devices { get; set; }
|
||||
/// <summary>Found media types, real, and in image</summary>
|
||||
public List<MediaStats> Medias { get; set; }
|
||||
/// <summary>Remote applications</summary>
|
||||
public List<OsStats> RemoteApplications { get; set; }
|
||||
/// <summary>Remote application architectures</summary>
|
||||
public List<NameValueStats> RemoteArchitectures { get; set; }
|
||||
/// <summary>Operating systems where a remote application has been running</summary>
|
||||
public List<OsStats> RemoteOperatingSystems { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>Command execution statistics</summary>
|
||||
[SuppressMessage("ReSharper", "UnassignedField.Global")]
|
||||
public class CommandsStats
|
||||
{
|
||||
/// <summary>Number of times the filesystem info command has been used</summary>
|
||||
public long Analyze;
|
||||
/// <summary>Number of times the benchmark command has been used</summary>
|
||||
public long Benchmark;
|
||||
/// <summary>Number of times the image checksum command has been used</summary>
|
||||
public long Checksum;
|
||||
/// <summary>Number of times the image compare command has been used</summary>
|
||||
public long Compare;
|
||||
/// <summary>Number of times the image convert command has been used</summary>
|
||||
public long ConvertImage;
|
||||
/// <summary>Number of times the image create-sidecar command has been used</summary>
|
||||
public long CreateSidecar;
|
||||
/// <summary>Number of times the image decode command has been used</summary>
|
||||
public long Decode;
|
||||
/// <summary>Number of times the device info command has been used</summary>
|
||||
public long DeviceInfo;
|
||||
/// <summary>Number of times the device report command has been used</summary>
|
||||
public long DeviceReport;
|
||||
/// <summary>Number of times the media dump command has been used</summary>
|
||||
public long DumpMedia;
|
||||
/// <summary>Number of times the image entropy command has been used</summary>
|
||||
public long Entropy;
|
||||
/// <summary>Number of times the filesystem extract command has been used</summary>
|
||||
public long ExtractFiles;
|
||||
/// <summary>Number of times the list formats command has been used</summary>
|
||||
public long Formats;
|
||||
/// <summary>Number of times the image info command has been used</summary>
|
||||
public long ImageInfo;
|
||||
/// <summary>Number of times the device list command has been used</summary>
|
||||
public long ListDevices;
|
||||
/// <summary>Number of times the list encodings command has been used</summary>
|
||||
public long ListEncodings;
|
||||
/// <summary>Number of times the filesystem ls command has been used</summary>
|
||||
public long Ls;
|
||||
/// <summary>Number of times the media info command has been used</summary>
|
||||
public long MediaInfo;
|
||||
/// <summary>Number of times the media scan command has been used</summary>
|
||||
public long MediaScan;
|
||||
/// <summary>Number of times the image printhex command has been used</summary>
|
||||
public long PrintHex;
|
||||
/// <summary>Number of times the image verify command has been used</summary>
|
||||
public long Verify;
|
||||
}
|
||||
|
||||
/// <summary>Statistics of verified media</summary>
|
||||
public class VerifiedItems
|
||||
{
|
||||
/// <summary>Number of correct images</summary>
|
||||
public long Correct;
|
||||
/// <summary>Number of failed images</summary>
|
||||
public long Failed;
|
||||
}
|
||||
|
||||
/// <summary>Verification statistics</summary>
|
||||
public class VerifyStats
|
||||
{
|
||||
/// <summary>Image verification statistics</summary>
|
||||
public VerifiedItems MediaImages;
|
||||
/// <summary>Image contents verification statistics</summary>
|
||||
public ScannedSectors Sectors;
|
||||
}
|
||||
|
||||
/// <summary>Image contents verification statistics</summary>
|
||||
public class ScannedSectors
|
||||
{
|
||||
/// <summary>Sectors found to be correct</summary>
|
||||
public long Correct;
|
||||
/// <summary>Sectors found to be incorrect</summary>
|
||||
public long Error;
|
||||
/// <summary>Total number of verified sectors</summary>
|
||||
public long Total;
|
||||
/// <summary>Total number of sectors that could not be verified</summary>
|
||||
public long Unverifiable;
|
||||
}
|
||||
|
||||
/// <summary>Media scanning time statistics</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class TimeStats
|
||||
{
|
||||
/// <summary>Number of sectors that took more than 3ms but less than 100ms to read</summary>
|
||||
public long LessThan10ms;
|
||||
/// <summary>Number of sectors that took more than 50ms but less than 150ms to read</summary>
|
||||
public long LessThan150ms;
|
||||
/// <summary>Number of sectors that took less than 3ms to read</summary>
|
||||
public long LessThan3ms;
|
||||
/// <summary>Number of sectors that took more than 150ms but less than 500ms to read</summary>
|
||||
public long LessThan500ms;
|
||||
/// <summary>Number of sectors that took more than 10ms but less than 50ms to read</summary>
|
||||
public long LessThan50ms;
|
||||
/// <summary>Number of sectors that took more than 500ms to read</summary>
|
||||
public long MoreThan500ms;
|
||||
}
|
||||
|
||||
/// <summary>Media scanning statistics</summary>
|
||||
public class MediaScanStats
|
||||
{
|
||||
/// <summary>Statistics of scanned sectors</summary>
|
||||
public ScannedSectors Sectors;
|
||||
/// <summary>Scan time statistics</summary>
|
||||
public TimeStats Times;
|
||||
}
|
||||
|
||||
/// <summary>Checksum type statistics</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class ChecksumStats
|
||||
{
|
||||
/// <summary>Checksum algorithm</summary>
|
||||
[XmlAttribute]
|
||||
public string algorithm;
|
||||
/// <summary>Time taken to execute algorithm</summary>
|
||||
[XmlText]
|
||||
public double Value;
|
||||
}
|
||||
|
||||
/// <summary>Benchmark statistics</summary>
|
||||
public class BenchmarkStats
|
||||
{
|
||||
/// <summary>Total time taken to run the checksum algorithms in parallel</summary>
|
||||
public double All;
|
||||
/// <summary>List of time taken by each checksum algorithm</summary>
|
||||
[XmlElement("Checksum")]
|
||||
public List<ChecksumStats> Checksum;
|
||||
/// <summary>Time taken to benchmark entropy calculation</summary>
|
||||
public double Entropy;
|
||||
/// <summary>Maximum amount of memory used while running the benchmark</summary>
|
||||
public long MaxMemory;
|
||||
/// <summary>Minimum amount of memory used while running the benchmark</summary>
|
||||
public long MinMemory;
|
||||
/// <summary>Total time taken to run the checksum algorithms sequentially</summary>
|
||||
public double Sequential;
|
||||
}
|
||||
|
||||
/// <summary>Media statistics</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class MediaStats
|
||||
{
|
||||
/// <summary>Found in a real device?</summary>
|
||||
[XmlAttribute]
|
||||
public bool real;
|
||||
/// <summary>Media type</summary>
|
||||
[XmlAttribute]
|
||||
public string type;
|
||||
/// <summary>Number of times it has been found</summary>
|
||||
[XmlText]
|
||||
public long Value;
|
||||
}
|
||||
|
||||
/// <summary>Device statistics</summary>
|
||||
public class DeviceStats
|
||||
{
|
||||
/// <summary>Is manufacturer null?</summary>
|
||||
[XmlIgnore]
|
||||
public bool ManufacturerSpecified;
|
||||
/// <summary>Manufacturer string</summary>
|
||||
public string Manufacturer { get; set; }
|
||||
/// <summary>Model string</summary>
|
||||
public string Model { get; set; }
|
||||
/// <summary>Revision or firmware version</summary>
|
||||
public string Revision { get; set; }
|
||||
/// <summary>Bus the device was attached to</summary>
|
||||
public string Bus { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>Name=value pair statistics</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class NameValueStats
|
||||
{
|
||||
/// <summary>Name</summary>
|
||||
[XmlAttribute]
|
||||
public string name { get; set; }
|
||||
/// <summary>Number of times it has been used/found</summary>
|
||||
[XmlText]
|
||||
public long Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>Operating system statistics</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class OsStats
|
||||
{
|
||||
/// <summary>Operating system name</summary>
|
||||
[XmlAttribute]
|
||||
public string name { get; set; }
|
||||
/// <summary>Operating system version</summary>
|
||||
[XmlAttribute]
|
||||
public string version { get; set; }
|
||||
/// <summary>Number of times Aaru run on it</summary>
|
||||
[XmlText]
|
||||
public long Value { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Statistics.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : XML metadata.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Returns Aaru version in XML software type format.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes.Interop;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.CommonTypes.Metadata
|
||||
{
|
||||
/// <summary>Manages Aaru's version for metadata</summary>
|
||||
public static class Version
|
||||
{
|
||||
/// <summary>Gets XML software type for the running version</summary>
|
||||
/// <returns>XML software type</returns>
|
||||
public static SoftwareType GetSoftwareType() => new SoftwareType
|
||||
{
|
||||
Name = "Aaru",
|
||||
OperatingSystem = DetectOS.GetRealPlatformID().ToString(),
|
||||
Version = typeof(Version).Assembly.GetName().Version?.ToString()
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Partition.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Aaru common types.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains common partition types.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Aaru.CommonTypes
|
||||
{
|
||||
/// <summary>Partition structure.</summary>
|
||||
public struct Partition : IEquatable<Partition>, IComparable<Partition>
|
||||
{
|
||||
/// <summary>Partition number, 0-started</summary>
|
||||
public ulong Sequence;
|
||||
/// <summary>Partition type</summary>
|
||||
public string Type;
|
||||
/// <summary>Partition name (if the scheme supports it)</summary>
|
||||
public string Name;
|
||||
/// <summary>Start of the partition, in bytes</summary>
|
||||
public ulong Offset;
|
||||
/// <summary>LBA of partition start</summary>
|
||||
public ulong Start;
|
||||
/// <summary>Length in bytes of the partition</summary>
|
||||
public ulong Size;
|
||||
/// <summary>Length in sectors of the partition</summary>
|
||||
public ulong Length;
|
||||
/// <summary>Information that does not find space in this struct</summary>
|
||||
public string Description;
|
||||
/// <summary>LBA of last partition sector</summary>
|
||||
public readonly ulong End => Start + Length - 1;
|
||||
/// <summary>Name of partition scheme that contains this partition</summary>
|
||||
public string Scheme;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Compares two partitions</summary>
|
||||
/// <param name="other">Partition to compare with</param>
|
||||
/// <returns>0 if both partitions start and end at the same sector</returns>
|
||||
public bool Equals(Partition other) => Start == other.Start && Length == other.Length;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj) => obj is Partition partition && Equals(partition);
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
// ReSharper disable once NonReadonlyMemberInGetHashCode
|
||||
public override int GetHashCode() => Start.GetHashCode() + End.GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// Compares this partition with another and returns an integer that indicates whether the current partition
|
||||
/// precedes, follows, or is in the same place as the other partition.
|
||||
/// </summary>
|
||||
/// <param name="other">Partition to compare with</param>
|
||||
/// <returns>A value that indicates the relative equality of the partitions being compared.</returns>
|
||||
/// <inheritdoc />
|
||||
public int CompareTo(Partition other)
|
||||
{
|
||||
if(Start == other.Start &&
|
||||
End == other.End)
|
||||
return 0;
|
||||
|
||||
if(Start > other.Start ||
|
||||
End > other.End)
|
||||
return 1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Define the equality operator.
|
||||
public static bool operator ==(Partition operand1, Partition operand2) => operand1.Equals(operand2);
|
||||
|
||||
// Define the inequality operator.
|
||||
public static bool operator !=(Partition operand1, Partition operand2) => !operand1.Equals(operand2);
|
||||
|
||||
// Define the is greater than operator.
|
||||
public static bool operator >(Partition operand1, Partition operand2) => operand1.CompareTo(operand2) == 1;
|
||||
|
||||
// Define the is less than operator.
|
||||
public static bool operator <(Partition operand1, Partition operand2) => operand1.CompareTo(operand2) == -1;
|
||||
|
||||
// Define the is greater than or equal to operator.
|
||||
public static bool operator >=(Partition operand1, Partition operand2) => operand1.CompareTo(operand2) >= 0;
|
||||
|
||||
// Define the is less than or equal to operator.
|
||||
public static bool operator <=(Partition operand1, Partition operand2) => operand1.CompareTo(operand2) <= 0;
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : PluginBase.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Core algorithms.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Class to hold all installed plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.CommonTypes
|
||||
{
|
||||
/// <summary>Contain all plugins (filesystem, partition and image)</summary>
|
||||
public class PluginBase
|
||||
{
|
||||
/// <summary>List of all archive formats</summary>
|
||||
public readonly SortedDictionary<string, IArchive> Archives;
|
||||
/// <summary>List of checksum plugins</summary>
|
||||
public readonly List<IChecksum> Checksums;
|
||||
/// <summary>List of filter plugins</summary>
|
||||
public readonly SortedDictionary<string, IFilter> Filters;
|
||||
/// <summary>List of floppy image plugins</summary>
|
||||
public readonly SortedDictionary<string, IFloppyImage> FloppyImages;
|
||||
/// <summary>List of all media image plugins</summary>
|
||||
public readonly SortedDictionary<string, IMediaImage> ImagePluginsList;
|
||||
/// <summary>List of all partition plugins</summary>
|
||||
public readonly SortedDictionary<string, IPartition> PartPluginsList;
|
||||
/// <summary>List of all filesystem plugins</summary>
|
||||
public readonly SortedDictionary<string, IFilesystem> PluginsList;
|
||||
/// <summary>List of read-only filesystem plugins</summary>
|
||||
public readonly SortedDictionary<string, IReadOnlyFilesystem> ReadOnlyFilesystems;
|
||||
/// <summary>List of writable floppy image plugins</summary>
|
||||
public readonly SortedDictionary<string, IWritableFloppyImage> WritableFloppyImages;
|
||||
/// <summary>List of writable media image plugins</summary>
|
||||
public readonly SortedDictionary<string, IWritableImage> WritableImages;
|
||||
|
||||
/// <summary>Initializes the plugins lists</summary>
|
||||
public PluginBase()
|
||||
{
|
||||
PluginsList = new SortedDictionary<string, IFilesystem>();
|
||||
ReadOnlyFilesystems = new SortedDictionary<string, IReadOnlyFilesystem>();
|
||||
PartPluginsList = new SortedDictionary<string, IPartition>();
|
||||
ImagePluginsList = new SortedDictionary<string, IMediaImage>();
|
||||
WritableImages = new SortedDictionary<string, IWritableImage>();
|
||||
Checksums = new List<IChecksum>();
|
||||
Filters = new SortedDictionary<string, IFilter>();
|
||||
FloppyImages = new SortedDictionary<string, IFloppyImage>();
|
||||
WritableFloppyImages = new SortedDictionary<string, IWritableFloppyImage>();
|
||||
Archives = new SortedDictionary<string, IArchive>();
|
||||
}
|
||||
|
||||
/// <summary>Adds plugins to the central plugin register</summary>
|
||||
/// <param name="pluginRegister">Plugin register</param>
|
||||
public void AddPlugins(IPluginRegister pluginRegister)
|
||||
{
|
||||
foreach(Type type in pluginRegister.GetAllChecksumPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{}) is IChecksum plugin)
|
||||
Checksums.Add(plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{}) is IFilesystem plugin &&
|
||||
!PluginsList.ContainsKey(plugin.Name.ToLower()))
|
||||
PluginsList.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllFilterPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{}) is IFilter plugin &&
|
||||
!Filters.ContainsKey(plugin.Name.ToLower()))
|
||||
Filters.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{}) is IFloppyImage plugin &&
|
||||
!FloppyImages.ContainsKey(plugin.Name.ToLower()))
|
||||
FloppyImages.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllMediaImagePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{}) is IMediaImage plugin &&
|
||||
!ImagePluginsList.ContainsKey(plugin.Name.ToLower()))
|
||||
ImagePluginsList.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllPartitionPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{}) is IPartition plugin &&
|
||||
!PartPluginsList.ContainsKey(plugin.Name.ToLower()))
|
||||
PartPluginsList.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllReadOnlyFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{}) is IReadOnlyFilesystem plugin &&
|
||||
!ReadOnlyFilesystems.ContainsKey(plugin.Name.ToLower()))
|
||||
ReadOnlyFilesystems.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllWritableFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{}) is IWritableFloppyImage plugin &&
|
||||
!WritableFloppyImages.ContainsKey(plugin.Name.ToLower()))
|
||||
WritableFloppyImages.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllWritableImagePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{}) is IWritableImage plugin &&
|
||||
!WritableImages.ContainsKey(plugin.Name.ToLower()))
|
||||
WritableImages.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllArchivePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{}) is IArchive plugin &&
|
||||
!Archives.ContainsKey(plugin.Name.ToLower()))
|
||||
Archives.Add(plugin.Name.ToLower(), plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,245 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Enums.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures for SCSI devices.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains various SCSI enumerations.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Aaru.CommonTypes.Structs.Devices.SCSI
|
||||
{
|
||||
/// <summary>List of known SCSI peripheral qualifiers</summary>
|
||||
public enum PeripheralQualifiers : byte
|
||||
{
|
||||
/// <summary>Peripheral qualifier: Device is connected and supported</summary>
|
||||
Supported = 0x00,
|
||||
/// <summary>Peripheral qualifier: Device is supported but not connected</summary>
|
||||
Unconnected = 0x01,
|
||||
/// <summary>Peripheral qualifier: Reserved value</summary>
|
||||
Reserved = 0x02,
|
||||
/// <summary>Peripheral qualifier: Device is connected but unsupported</summary>
|
||||
Unsupported = 0x03,
|
||||
/// <summary>Peripheral qualifier: Vendor values: 0x04, 0x05, 0x06 and 0x07</summary>
|
||||
VendorMask = 0x04
|
||||
}
|
||||
|
||||
/// <summary>List of known peripheral device types</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum PeripheralDeviceTypes : byte
|
||||
{
|
||||
/// <summary>Direct-access device</summary>
|
||||
DirectAccess = 0x00,
|
||||
/// <summary>Sequential-access device</summary>
|
||||
SequentialAccess = 0x01,
|
||||
/// <summary>Printer device</summary>
|
||||
PrinterDevice = 0x02,
|
||||
/// <summary>Processor device</summary>
|
||||
ProcessorDevice = 0x03,
|
||||
/// <summary>Write-once device</summary>
|
||||
WriteOnceDevice = 0x04,
|
||||
/// <summary>CD-ROM/DVD/etc device</summary>
|
||||
MultiMediaDevice = 0x05,
|
||||
/// <summary>Scanner device</summary>
|
||||
ScannerDevice = 0x06,
|
||||
/// <summary>Optical memory device</summary>
|
||||
OpticalDevice = 0x07,
|
||||
/// <summary>Medium change device</summary>
|
||||
MediumChangerDevice = 0x08,
|
||||
/// <summary>Communications device</summary>
|
||||
CommsDevice = 0x09,
|
||||
/// <summary>Graphics arts pre-press device (defined in ASC IT8)</summary>
|
||||
PrePressDevice1 = 0x0A,
|
||||
/// <summary>Graphics arts pre-press device (defined in ASC IT8)</summary>
|
||||
PrePressDevice2 = 0x0B,
|
||||
/// <summary>Array controller device</summary>
|
||||
ArrayControllerDevice = 0x0C,
|
||||
/// <summary>Enclosure services device</summary>
|
||||
EnclosureServiceDevice = 0x0D,
|
||||
/// <summary>Simplified direct-access device</summary>
|
||||
SimplifiedDevice = 0x0E,
|
||||
/// <summary>Optical card reader/writer device</summary>
|
||||
OCRWDevice = 0x0F,
|
||||
/// <summary>Bridging Expanders</summary>
|
||||
BridgingExpander = 0x10,
|
||||
/// <summary>Object-based Storage Device</summary>
|
||||
ObjectDevice = 0x11,
|
||||
/// <summary>Automation/Drive Interface</summary>
|
||||
ADCDevice = 0x12,
|
||||
/// <summary>Security Manager Device</summary>
|
||||
SCSISecurityManagerDevice = 0x13,
|
||||
/// <summary>Host managed zoned block device</summary>
|
||||
SCSIZonedBlockDevice = 0x14,
|
||||
/// <summary>Well known logical unit</summary>
|
||||
WellKnownDevice = 0x1E,
|
||||
/// <summary>Unknown or no device type</summary>
|
||||
UnknownDevice = 0x1F
|
||||
}
|
||||
|
||||
/// <summary>List of known ANSI SCSI standards</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum ANSIVersions : byte
|
||||
{
|
||||
/// <summary>Device does not claim conformance to any ANSI version</summary>
|
||||
ANSINoVersion = 0x00,
|
||||
/// <summary>Device complies with ANSI X3.131:1986</summary>
|
||||
ANSI1986Version = 0x01,
|
||||
/// <summary>Device complies with ANSI X3.131:1994</summary>
|
||||
ANSI1994Version = 0x02,
|
||||
/// <summary>Device complies with ANSI X3.301:1997</summary>
|
||||
ANSI1997Version = 0x03,
|
||||
/// <summary>Device complies with ANSI X3.351:2001</summary>
|
||||
ANSI2001Version = 0x04,
|
||||
/// <summary>Device complies with ANSI X3.408:2005.</summary>
|
||||
ANSI2005Version = 0x05,
|
||||
/// <summary>Device complies with SPC-4</summary>
|
||||
ANSI2008Version = 0x06
|
||||
}
|
||||
|
||||
/// <summary>List of known ECMA SCSI standards</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum ECMAVersions : byte
|
||||
{
|
||||
/// <summary>Device does not claim conformance to any ECMA version</summary>
|
||||
ECMANoVersion = 0x00,
|
||||
/// <summary>Device complies with a ECMA-111 standard</summary>
|
||||
ECMA111 = 0x01
|
||||
}
|
||||
|
||||
/// <summary>List of known ISO SCSI standards</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum ISOVersions : byte
|
||||
{
|
||||
/// <summary>Device does not claim conformance to any ISO/IEC version</summary>
|
||||
ISONoVersion = 0x00,
|
||||
/// <summary>Device complies with ISO/IEC 9316:1995</summary>
|
||||
ISO1995Version = 0x02
|
||||
}
|
||||
|
||||
/// <summary>List of known SCSI Parallel Interface clocking types</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum SPIClocking : byte
|
||||
{
|
||||
/// <summary>Supports only ST</summary>
|
||||
ST = 0x00,
|
||||
/// <summary>Supports only DT</summary>
|
||||
DT = 0x01,
|
||||
/// <summary>Reserved value</summary>
|
||||
Reserved = 0x02,
|
||||
/// <summary>Supports ST and DT</summary>
|
||||
STandDT = 0x03
|
||||
}
|
||||
|
||||
/// <summary>List of known TGPS values</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum TGPSValues : byte
|
||||
{
|
||||
/// <summary>Asymmetrical access not supported</summary>
|
||||
NotSupported = 0x00,
|
||||
/// <summary>Only implicit asymmetrical access is supported</summary>
|
||||
OnlyImplicit = 0x01,
|
||||
/// <summary>Only explicit asymmetrical access is supported</summary>
|
||||
OnlyExplicit = 0x02,
|
||||
/// <summary>Both implicit and explicit asymmetrical access are supported</summary>
|
||||
Both = 0x03
|
||||
}
|
||||
|
||||
/// <summary>List of known SCSI protocols</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum ProtocolIdentifiers : byte
|
||||
{
|
||||
/// <summary>Fibre Channel</summary>
|
||||
FibreChannel = 0,
|
||||
/// <summary>Parallel SCSI</summary>
|
||||
SCSI = 1,
|
||||
/// <summary>SSA</summary>
|
||||
SSA = 2,
|
||||
/// <summary>IEEE-1394</summary>
|
||||
Firewire = 3,
|
||||
/// <summary>SCSI Remote Direct Memory Access Protocol</summary>
|
||||
RDMAP = 4,
|
||||
/// <summary>Internet SCSI</summary>
|
||||
iSCSI = 5,
|
||||
/// <summary>Serial SCSI</summary>
|
||||
SAS = 6,
|
||||
/// <summary>Automation/Drive Interface Transport Protocol</summary>
|
||||
ADT = 7,
|
||||
/// <summary>AT Attachment Interface (ATA/ATAPI)</summary>
|
||||
ATA = 8,
|
||||
/// <summary>USB Attached SCSI</summary>
|
||||
UAS = 9,
|
||||
/// <summary>SCSI over PCI Express</summary>
|
||||
SCSIe = 10,
|
||||
/// <summary>PCI Express</summary>
|
||||
PCIe = 11,
|
||||
/// <summary>No specific protocol</summary>
|
||||
NoProtocol = 15
|
||||
}
|
||||
|
||||
/// <summary>List of known SCSI definitions</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum ScsiDefinitions : byte
|
||||
{
|
||||
/// <summary>Unknown</summary>
|
||||
Current = 0,
|
||||
/// <summary>SCSI-1</summary>
|
||||
SCSI1 = 1,
|
||||
/// <summary>Unknown</summary>
|
||||
CCS = 2,
|
||||
/// <summary>SCSI-2</summary>
|
||||
SCSI2 = 3,
|
||||
/// <summary>SCSI-3</summary>
|
||||
SCSI3 = 4
|
||||
}
|
||||
|
||||
/// <summary>List of known SCSI physical interfaces</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum PhysicalInterfaces : uint
|
||||
{
|
||||
/// <summary>Unspecified physical interface</summary>
|
||||
Unspecified = 0,
|
||||
/// <summary>SCSI</summary>
|
||||
SCSI = 1,
|
||||
/// <summary>ATAPI</summary>
|
||||
ATAPI = 2,
|
||||
/// <summary>IEEE-1394/1995</summary>
|
||||
IEEE1394 = 3,
|
||||
/// <summary>IEEE-1394A</summary>
|
||||
IEEE1394A = 4,
|
||||
/// <summary>Fibre Channel</summary>
|
||||
FC = 5,
|
||||
/// <summary>IEEE-1394B</summary>
|
||||
IEEE1394B = 6,
|
||||
/// <summary>Serial ATAPI</summary>
|
||||
SerialATAPI = 7,
|
||||
/// <summary>USB</summary>
|
||||
USB = 8,
|
||||
/// <summary>Vendor unique</summary>
|
||||
Vendor = 0xFFFF
|
||||
}
|
||||
}
|
||||
@@ -1,788 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Inquiry.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures for SCSI devices.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines a high level interpretation of the SCSI INQUIRY response.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.CommonTypes.Structs.Devices.SCSI
|
||||
{
|
||||
/// <summary>
|
||||
/// Information from the following standards: T9/375-D revision 10l T10/995-D revision 10 T10/1236-D revision 20
|
||||
/// T10/1416-D revision 23 T10/1731-D revision 16 T10/502 revision 05 RFC 7144 ECMA-111
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
|
||||
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public struct Inquiry
|
||||
{
|
||||
/// <summary>Peripheral qualifier Byte 0, bits 7 to 5</summary>
|
||||
public byte PeripheralQualifier;
|
||||
/// <summary>Peripheral device type Byte 0, bits 4 to 0</summary>
|
||||
public byte PeripheralDeviceType;
|
||||
/// <summary>Removable device Byte 1, bit 7</summary>
|
||||
public bool RMB;
|
||||
/// <summary>SCSI-1 vendor-specific qualification codes Byte 1, bits 6 to 0</summary>
|
||||
public byte DeviceTypeModifier;
|
||||
/// <summary>ISO/IEC SCSI Standard Version Byte 2, bits 7 to 6, mask = 0xC0, >> 6</summary>
|
||||
public byte ISOVersion;
|
||||
/// <summary>ECMA SCSI Standard Version Byte 2, bits 5 to 3, mask = 0x38, >> 3</summary>
|
||||
public byte ECMAVersion;
|
||||
/// <summary>ANSI SCSI Standard Version Byte 2, bits 2 to 0, mask = 0x07</summary>
|
||||
public byte ANSIVersion;
|
||||
/// <summary>Asynchronous Event Reporting Capability supported Byte 3, bit 7</summary>
|
||||
public bool AERC;
|
||||
/// <summary>Device supports TERMINATE TASK command Byte 3, bit 6</summary>
|
||||
public bool TrmTsk;
|
||||
/// <summary>Supports setting Normal ACA Byte 3, bit 5</summary>
|
||||
public bool NormACA;
|
||||
/// <summary>Supports LUN hierarchical addressing Byte 3, bit 4</summary>
|
||||
public bool HiSup;
|
||||
/// <summary>Responde data format Byte 3, bit 3 to 0</summary>
|
||||
public byte ResponseDataFormat;
|
||||
/// <summary>Lenght of total INQUIRY response minus 4 Byte 4</summary>
|
||||
public byte AdditionalLength;
|
||||
/// <summary>Device contains an embedded storage array controller Byte 5, bit 7</summary>
|
||||
public bool SCCS;
|
||||
/// <summary>Device contains an Access Control Coordinator Byte 5, bit 6</summary>
|
||||
public bool ACC;
|
||||
/// <summary>Supports asymetrical logical unit access Byte 5, bits 5 to 4</summary>
|
||||
public byte TPGS;
|
||||
/// <summary>Supports third-party copy commands Byte 5, bit 3</summary>
|
||||
public bool ThreePC;
|
||||
/// <summary>Reserved Byte 5, bits 2 to 1</summary>
|
||||
public byte Reserved2;
|
||||
/// <summary>Supports protection information Byte 5, bit 0</summary>
|
||||
public bool Protect;
|
||||
/// <summary>Supports basic queueing Byte 6, bit 7</summary>
|
||||
public bool BQue;
|
||||
/// <summary>Device contains an embedded enclosure services component Byte 6, bit 6</summary>
|
||||
public bool EncServ;
|
||||
/// <summary>Vendor-specific Byte 6, bit 5</summary>
|
||||
public bool VS1;
|
||||
/// <summary>Multi-port device Byte 6, bit 4</summary>
|
||||
public bool MultiP;
|
||||
/// <summary>Device contains or is attached to a medium changer Byte 6, bit 3</summary>
|
||||
public bool MChngr;
|
||||
/// <summary>Device supports request and acknowledge handshakes Byte 6, bit 2</summary>
|
||||
public bool ACKREQQ;
|
||||
/// <summary>Supports 32-bit wide SCSI addresses Byte 6, bit 1</summary>
|
||||
public bool Addr32;
|
||||
/// <summary>Supports 16-bit wide SCSI addresses Byte 6, bit 0</summary>
|
||||
public bool Addr16;
|
||||
/// <summary>Device supports relative addressing Byte 7, bit 7</summary>
|
||||
public bool RelAddr;
|
||||
/// <summary>Supports 32-bit wide data transfers Byte 7, bit 6</summary>
|
||||
public bool WBus32;
|
||||
/// <summary>Supports 16-bit wide data transfers Byte 7, bit 5</summary>
|
||||
public bool WBus16;
|
||||
/// <summary>Supports synchronous data transfer Byte 7, bit 4</summary>
|
||||
public bool Sync;
|
||||
/// <summary>Supports linked commands Byte 7, bit 3</summary>
|
||||
public bool Linked;
|
||||
/// <summary>Supports CONTINUE TASK and TARGET TRANSFER DISABLE commands Byte 7, bit 2</summary>
|
||||
public bool TranDis;
|
||||
/// <summary>Supports TCQ queue Byte 7, bit 1</summary>
|
||||
public bool CmdQue;
|
||||
/// <summary>Indicates that the devices responds to RESET with soft reset Byte 7, bit 0</summary>
|
||||
public bool SftRe;
|
||||
/// <summary>Vendor identification Bytes 8 to 15</summary>
|
||||
public byte[] VendorIdentification;
|
||||
/// <summary>Product identification Bytes 16 to 31</summary>
|
||||
public byte[] ProductIdentification;
|
||||
/// <summary>Product revision level Bytes 32 to 35</summary>
|
||||
public byte[] ProductRevisionLevel;
|
||||
/// <summary>Vendor-specific data Bytes 36 to 55</summary>
|
||||
public byte[] VendorSpecific;
|
||||
/// <summary>Byte 56, bits 7 to 4</summary>
|
||||
public byte Reserved3;
|
||||
/// <summary>Supported SPI clocking Byte 56, bits 3 to 2</summary>
|
||||
public byte Clocking;
|
||||
/// <summary>Device supports Quick Arbitration and Selection Byte 56, bit 1</summary>
|
||||
public bool QAS;
|
||||
/// <summary>Supports information unit transfers Byte 56, bit 0</summary>
|
||||
public bool IUS;
|
||||
/// <summary>Reserved Byte 57</summary>
|
||||
public byte Reserved4;
|
||||
/// <summary>Array of version descriptors Bytes 58 to 73</summary>
|
||||
public ushort[] VersionDescriptors;
|
||||
/// <summary>Reserved Bytes 74 to 95</summary>
|
||||
public byte[] Reserved5;
|
||||
/// <summary>Reserved Bytes 96 to end</summary>
|
||||
public byte[] VendorSpecific2;
|
||||
|
||||
// Per DLT4000/DLT4500/DLT4700 Cartridge Tape Subsystem Product Manual
|
||||
|
||||
#region Quantum vendor unique inquiry data structure
|
||||
/// <summary>Means that the INQUIRY response contains 56 bytes or more, so this data has been filled</summary>
|
||||
public bool QuantumPresent;
|
||||
/// <summary>The product family. Byte 36, bits 7 to 5</summary>
|
||||
public byte Qt_ProductFamily;
|
||||
/// <summary>The released firmware. Byte 36, bits 4 to 0</summary>
|
||||
public byte Qt_ReleasedFirmware;
|
||||
/// <summary>The firmware major version. Byte 37</summary>
|
||||
public byte Qt_FirmwareMajorVersion;
|
||||
/// <summary>The firmware minor version. Byte 38</summary>
|
||||
public byte Qt_FirmwareMinorVersion;
|
||||
/// <summary>The EEPROM format major version. Byte 39</summary>
|
||||
public byte Qt_EEPROMFormatMajorVersion;
|
||||
/// <summary>The EEPROM format minor version. Byte 40</summary>
|
||||
public byte Qt_EEPROMFormatMinorVersion;
|
||||
/// <summary>The firmware personality. Byte 41</summary>
|
||||
public byte Qt_FirmwarePersonality;
|
||||
/// <summary>The firmware sub personality. Byte 42</summary>
|
||||
public byte Qt_FirmwareSubPersonality;
|
||||
/// <summary>The tape directory format version. Byte 43</summary>
|
||||
public byte Qt_TapeDirectoryFormatVersion;
|
||||
/// <summary>The controller hardware version. Byte 44</summary>
|
||||
public byte Qt_ControllerHardwareVersion;
|
||||
/// <summary>The drive EEPROM version. Byte 45</summary>
|
||||
public byte Qt_DriveEEPROMVersion;
|
||||
/// <summary>The drive hardware version. Byte 46</summary>
|
||||
public byte Qt_DriveHardwareVersion;
|
||||
/// <summary>The media loader firmware version. Byte 47</summary>
|
||||
public byte Qt_MediaLoaderFirmwareVersion;
|
||||
/// <summary>The media loader hardware version. Byte 48</summary>
|
||||
public byte Qt_MediaLoaderHardwareVersion;
|
||||
/// <summary>The media loader mechanical version. Byte 49</summary>
|
||||
public byte Qt_MediaLoaderMechanicalVersion;
|
||||
/// <summary>Is a media loader present? Byte 50</summary>
|
||||
public bool Qt_MediaLoaderPresent;
|
||||
/// <summary>Is a library present? Byte 51</summary>
|
||||
public bool Qt_LibraryPresent;
|
||||
/// <summary>The module revision. Bytes 52 to 55</summary>
|
||||
public byte[] Qt_ModuleRevision;
|
||||
#endregion Quantum vendor unique inquiry data structure
|
||||
|
||||
#region IBM vendor unique inquiry data structure
|
||||
/// <summary>Means that the INQUIRY response contains 56 bytes or more, so this data has been filled</summary>
|
||||
public bool IBMPresent;
|
||||
/// <summary>Drive is not capable of automation Byte 36 bit 0</summary>
|
||||
public bool IBM_AutDis;
|
||||
/// <summary>If not zero, limit in MB/s = Max * (this / 256) Byte 37</summary>
|
||||
public byte IBM_PerformanceLimit;
|
||||
/// <summary>Byte 41</summary>
|
||||
public byte IBM_OEMSpecific;
|
||||
#endregion IBM vendor unique inquiry data structure
|
||||
|
||||
#region HP vendor unique inquiry data structure
|
||||
/// <summary>Means that the INQUIRY response contains 49 bytes or more, so this data has been filled</summary>
|
||||
public bool HPPresent;
|
||||
/// <summary>WORM version Byte 40 bits 7 to 1</summary>
|
||||
public byte HP_WORMVersion;
|
||||
/// <summary>WORM supported Byte 40 bit 0</summary>
|
||||
public bool HP_WORM;
|
||||
/// <summary>Bytes 43 to 48</summary>
|
||||
public byte[] HP_OBDR;
|
||||
#endregion HP vendor unique inquiry data structure
|
||||
|
||||
#region Seagate vendor unique inquiry data structure
|
||||
/// <summary>Means that bytes 36 to 43 are filled</summary>
|
||||
public bool SeagatePresent;
|
||||
/// <summary>Drive Serial Number Bytes 36 to 43</summary>
|
||||
public byte[] Seagate_DriveSerialNumber;
|
||||
/// <summary>Means that bytes 96 to 143 are filled</summary>
|
||||
public bool Seagate2Present;
|
||||
/// <summary>Contains Seagate copyright notice Bytes 96 to 143</summary>
|
||||
public byte[] Seagate_Copyright;
|
||||
/// <summary>Means that bytes 144 to 147 are filled</summary>
|
||||
public bool Seagate3Present;
|
||||
/// <summary>Reserved Seagate field Bytes 144 to 147</summary>
|
||||
public byte[] Seagate_ServoPROMPartNo;
|
||||
#endregion Seagate vendor unique inquiry data structure
|
||||
|
||||
#region Kreon vendor unique inquiry data structure
|
||||
/// <summary>Means that firmware is Kreon</summary>
|
||||
public bool KreonPresent;
|
||||
/// <summary>Kreon identifier Bytes 36 to 40</summary>
|
||||
public byte[] KreonIdentifier;
|
||||
/// <summary>Kreon just a 0x20 Bytes 41</summary>
|
||||
public byte KreonSpace;
|
||||
/// <summary>Kreon version string Bytes 42 to 46</summary>
|
||||
public byte[] KreonVersion;
|
||||
#endregion Kreon vendor unique inquiry data structure
|
||||
|
||||
#region Sony Hi-MD data
|
||||
/// <summary>Set if Hi-MD signature is present</summary>
|
||||
public bool IsHiMD;
|
||||
/// <summary>Hi-MD signature, bytes 36 to 44</summary>
|
||||
public byte[] HiMDSignature;
|
||||
/// <summary>Unknown data, bytes 44 to 55</summary>
|
||||
public byte[] HiMDSpecific;
|
||||
#endregion Sony Hi-MD data
|
||||
|
||||
static readonly byte[] HiMDSignatureContents =
|
||||
{
|
||||
0x48, 0x69, 0x2D, 0x4D, 0x44, 0x20, 0x20, 0x20
|
||||
};
|
||||
|
||||
/// <summary>Decodes a SCSI INQUIRY response</summary>
|
||||
/// <param name="SCSIInquiryResponse">INQUIRY raw response data</param>
|
||||
/// <returns>Decoded SCSI INQUIRY</returns>
|
||||
#region Public methods
|
||||
public static Inquiry? Decode(byte[] SCSIInquiryResponse)
|
||||
{
|
||||
if(SCSIInquiryResponse == null)
|
||||
return null;
|
||||
|
||||
if(SCSIInquiryResponse.Length < 36 &&
|
||||
SCSIInquiryResponse.Length != 5)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("SCSI INQUIRY decoder",
|
||||
"INQUIRY response is {0} bytes, less than minimum of 36 bytes, decoded data can be incorrect, not decoding.",
|
||||
SCSIInquiryResponse.Length);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length < SCSIInquiryResponse[4] + 4 &&
|
||||
SCSIInquiryResponse.Length != SCSIInquiryResponse[4])
|
||||
{
|
||||
AaruConsole.DebugWriteLine("SCSI INQUIRY decoder",
|
||||
"INQUIRY response length ({0} bytes) is different than specified in length field ({1} bytes), decoded data can be incorrect, not decoding.",
|
||||
SCSIInquiryResponse.Length, SCSIInquiryResponse[4] + 4);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var decoded = new Inquiry();
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 1)
|
||||
{
|
||||
decoded.PeripheralQualifier = (byte)((SCSIInquiryResponse[0] & 0xE0) >> 5);
|
||||
decoded.PeripheralDeviceType = (byte)(SCSIInquiryResponse[0] & 0x1F);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 2)
|
||||
{
|
||||
decoded.RMB = Convert.ToBoolean(SCSIInquiryResponse[1] & 0x80);
|
||||
decoded.DeviceTypeModifier = (byte)(SCSIInquiryResponse[1] & 0x7F);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 3)
|
||||
{
|
||||
decoded.ISOVersion = (byte)((SCSIInquiryResponse[2] & 0xC0) >> 6);
|
||||
decoded.ECMAVersion = (byte)((SCSIInquiryResponse[2] & 0x38) >> 3);
|
||||
decoded.ANSIVersion = (byte)(SCSIInquiryResponse[2] & 0x07);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 4)
|
||||
{
|
||||
decoded.AERC = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x80);
|
||||
decoded.TrmTsk = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x40);
|
||||
decoded.NormACA = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x20);
|
||||
decoded.HiSup = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x10);
|
||||
decoded.ResponseDataFormat = (byte)(SCSIInquiryResponse[3] & 0x07);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 5)
|
||||
decoded.AdditionalLength = SCSIInquiryResponse[4];
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 6)
|
||||
{
|
||||
decoded.SCCS = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x80);
|
||||
decoded.ACC = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x40);
|
||||
decoded.TPGS = (byte)((SCSIInquiryResponse[5] & 0x30) >> 4);
|
||||
decoded.ThreePC = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x08);
|
||||
decoded.Reserved2 = (byte)((SCSIInquiryResponse[5] & 0x06) >> 1);
|
||||
decoded.Protect = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x01);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 7)
|
||||
{
|
||||
decoded.BQue = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x80);
|
||||
decoded.EncServ = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x40);
|
||||
decoded.VS1 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x20);
|
||||
decoded.MultiP = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x10);
|
||||
decoded.MChngr = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x08);
|
||||
decoded.ACKREQQ = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x04);
|
||||
decoded.Addr32 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x02);
|
||||
decoded.Addr16 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x01);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 8)
|
||||
{
|
||||
decoded.RelAddr = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x80);
|
||||
decoded.WBus32 = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x40);
|
||||
decoded.WBus16 = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x20);
|
||||
decoded.Sync = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x10);
|
||||
decoded.Linked = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x08);
|
||||
decoded.TranDis = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x04);
|
||||
decoded.CmdQue = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x02);
|
||||
decoded.SftRe = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x01);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 16)
|
||||
{
|
||||
decoded.VendorIdentification = new byte[8];
|
||||
Array.Copy(SCSIInquiryResponse, 8, decoded.VendorIdentification, 0, 8);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 32)
|
||||
{
|
||||
decoded.ProductIdentification = new byte[16];
|
||||
Array.Copy(SCSIInquiryResponse, 16, decoded.ProductIdentification, 0, 16);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 36)
|
||||
{
|
||||
decoded.ProductRevisionLevel = new byte[4];
|
||||
Array.Copy(SCSIInquiryResponse, 32, decoded.ProductRevisionLevel, 0, 4);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 44)
|
||||
{
|
||||
// Seagate 1
|
||||
decoded.SeagatePresent = true;
|
||||
decoded.Seagate_DriveSerialNumber = new byte[8];
|
||||
Array.Copy(SCSIInquiryResponse, 36, decoded.Seagate_DriveSerialNumber, 0, 8);
|
||||
|
||||
// Hi-MD
|
||||
decoded.HiMDSignature = new byte[8];
|
||||
Array.Copy(SCSIInquiryResponse, 36, decoded.HiMDSignature, 0, 8);
|
||||
decoded.IsHiMD = HiMDSignatureContents.SequenceEqual(decoded.HiMDSignature);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 46)
|
||||
{
|
||||
// Kreon
|
||||
decoded.KreonIdentifier = new byte[5];
|
||||
Array.Copy(SCSIInquiryResponse, 36, decoded.KreonIdentifier, 0, 5);
|
||||
decoded.KreonSpace = SCSIInquiryResponse[41];
|
||||
decoded.KreonVersion = new byte[5];
|
||||
Array.Copy(SCSIInquiryResponse, 42, decoded.KreonVersion, 0, 5);
|
||||
|
||||
if(decoded.KreonSpace == 0x20 &&
|
||||
decoded.KreonIdentifier.SequenceEqual(new byte[]
|
||||
{
|
||||
0x4B, 0x52, 0x45, 0x4F, 0x4E
|
||||
}))
|
||||
decoded.KreonPresent = true;
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 49)
|
||||
{
|
||||
// HP
|
||||
decoded.HPPresent = true;
|
||||
decoded.HP_WORM |= (SCSIInquiryResponse[40] & 0x01) == 0x01;
|
||||
decoded.HP_WORMVersion = (byte)((SCSIInquiryResponse[40] & 0x7F) >> 1);
|
||||
decoded.HP_OBDR = new byte[6];
|
||||
Array.Copy(SCSIInquiryResponse, 43, decoded.HP_OBDR, 0, 6);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 56)
|
||||
{
|
||||
if(decoded.IsHiMD)
|
||||
{
|
||||
decoded.HiMDSpecific = new byte[12];
|
||||
Array.Copy(SCSIInquiryResponse, 44, decoded.HiMDSpecific, 0, 12);
|
||||
}
|
||||
else
|
||||
{
|
||||
decoded.VendorSpecific = new byte[20];
|
||||
Array.Copy(SCSIInquiryResponse, 36, decoded.VendorSpecific, 0, 20);
|
||||
}
|
||||
|
||||
// Quantum
|
||||
decoded.QuantumPresent = true;
|
||||
decoded.Qt_ProductFamily = (byte)((SCSIInquiryResponse[36] & 0xF0) >> 4);
|
||||
decoded.Qt_ReleasedFirmware = (byte)(SCSIInquiryResponse[36] & 0x0F);
|
||||
decoded.Qt_FirmwareMajorVersion = SCSIInquiryResponse[37];
|
||||
decoded.Qt_FirmwareMinorVersion = SCSIInquiryResponse[38];
|
||||
decoded.Qt_EEPROMFormatMajorVersion = SCSIInquiryResponse[39];
|
||||
decoded.Qt_EEPROMFormatMinorVersion = SCSIInquiryResponse[40];
|
||||
decoded.Qt_FirmwarePersonality = SCSIInquiryResponse[41];
|
||||
decoded.Qt_FirmwareSubPersonality = SCSIInquiryResponse[42];
|
||||
decoded.Qt_TapeDirectoryFormatVersion = SCSIInquiryResponse[43];
|
||||
decoded.Qt_ControllerHardwareVersion = SCSIInquiryResponse[44];
|
||||
decoded.Qt_DriveEEPROMVersion = SCSIInquiryResponse[45];
|
||||
decoded.Qt_DriveHardwareVersion = SCSIInquiryResponse[46];
|
||||
decoded.Qt_MediaLoaderFirmwareVersion = SCSIInquiryResponse[47];
|
||||
decoded.Qt_MediaLoaderHardwareVersion = SCSIInquiryResponse[48];
|
||||
decoded.Qt_MediaLoaderMechanicalVersion = SCSIInquiryResponse[49];
|
||||
decoded.Qt_MediaLoaderPresent = SCSIInquiryResponse[50] > 0;
|
||||
decoded.Qt_LibraryPresent = SCSIInquiryResponse[51] > 0;
|
||||
decoded.Qt_ModuleRevision = new byte[4];
|
||||
Array.Copy(SCSIInquiryResponse, 52, decoded.Qt_ModuleRevision, 0, 4);
|
||||
|
||||
// IBM
|
||||
decoded.IBMPresent = true;
|
||||
decoded.IBM_AutDis |= (SCSIInquiryResponse[36] & 0x01) == 0x01;
|
||||
decoded.IBM_PerformanceLimit = SCSIInquiryResponse[37];
|
||||
decoded.IBM_OEMSpecific = SCSIInquiryResponse[41];
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 57)
|
||||
{
|
||||
decoded.Reserved3 = (byte)((SCSIInquiryResponse[56] & 0xF0) >> 4);
|
||||
decoded.Clocking = (byte)((SCSIInquiryResponse[56] & 0x0C) >> 2);
|
||||
decoded.QAS = Convert.ToBoolean(SCSIInquiryResponse[56] & 0x02);
|
||||
decoded.IUS = Convert.ToBoolean(SCSIInquiryResponse[56] & 0x01);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 58)
|
||||
decoded.Reserved4 = SCSIInquiryResponse[57];
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 60)
|
||||
{
|
||||
int descriptorsNo;
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 74)
|
||||
descriptorsNo = 8;
|
||||
else
|
||||
descriptorsNo = (SCSIInquiryResponse.Length - 58) / 2;
|
||||
|
||||
decoded.VersionDescriptors = new ushort[descriptorsNo];
|
||||
|
||||
for(int i = 0; i < descriptorsNo; i++)
|
||||
decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + (i * 2));
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 75 &&
|
||||
SCSIInquiryResponse.Length < 96)
|
||||
{
|
||||
decoded.Reserved5 = new byte[SCSIInquiryResponse.Length - 74];
|
||||
Array.Copy(SCSIInquiryResponse, 74, decoded.Reserved5, 0, SCSIInquiryResponse.Length - 74);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 96)
|
||||
{
|
||||
decoded.Reserved5 = new byte[22];
|
||||
Array.Copy(SCSIInquiryResponse, 74, decoded.Reserved5, 0, 22);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length > 96)
|
||||
{
|
||||
decoded.VendorSpecific2 = new byte[SCSIInquiryResponse.Length - 96];
|
||||
Array.Copy(SCSIInquiryResponse, 96, decoded.VendorSpecific2, 0, SCSIInquiryResponse.Length - 96);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 144)
|
||||
{
|
||||
// Seagate 2
|
||||
decoded.Seagate2Present = true;
|
||||
decoded.Seagate_Copyright = new byte[48];
|
||||
Array.Copy(SCSIInquiryResponse, 96, decoded.Seagate_Copyright, 0, 48);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length < 148)
|
||||
return decoded;
|
||||
|
||||
// Seagate 2
|
||||
decoded.Seagate3Present = true;
|
||||
decoded.Seagate_ServoPROMPartNo = new byte[4];
|
||||
Array.Copy(SCSIInquiryResponse, 144, decoded.Seagate_ServoPROMPartNo, 0, 4);
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
/// <summary>Encodes a SCSI INQUIRY response</summary>
|
||||
/// <param name="inq">Decoded SCSI INQUIRY</param>
|
||||
/// <returns>Raw SCSI INQUIRY response</returns>
|
||||
public static byte[] Encode(Inquiry? inq)
|
||||
{
|
||||
if(inq is null)
|
||||
return null;
|
||||
|
||||
Inquiry decoded = inq.Value;
|
||||
|
||||
byte[] buffer = new byte[512];
|
||||
byte length = 0;
|
||||
|
||||
buffer[0] = (byte)(decoded.PeripheralQualifier << 5);
|
||||
buffer[0] += decoded.PeripheralDeviceType;
|
||||
|
||||
if(decoded.RMB)
|
||||
buffer[1] = 0x80;
|
||||
|
||||
buffer[1] += decoded.DeviceTypeModifier;
|
||||
|
||||
buffer[2] = (byte)(decoded.ISOVersion << 6);
|
||||
buffer[2] += (byte)(decoded.ECMAVersion << 3);
|
||||
buffer[2] += decoded.ANSIVersion;
|
||||
|
||||
if(decoded.AERC)
|
||||
buffer[3] = 0x80;
|
||||
|
||||
if(decoded.TrmTsk)
|
||||
buffer[3] += 0x40;
|
||||
|
||||
if(decoded.NormACA)
|
||||
buffer[3] += 0x20;
|
||||
|
||||
if(decoded.HiSup)
|
||||
buffer[3] += 0x10;
|
||||
|
||||
buffer[3] += decoded.ResponseDataFormat;
|
||||
|
||||
if(decoded.AdditionalLength > 0)
|
||||
{
|
||||
length = 5;
|
||||
buffer[4] = decoded.AdditionalLength;
|
||||
}
|
||||
|
||||
if(decoded.SCCS ||
|
||||
decoded.ACC ||
|
||||
decoded.TPGS > 0 ||
|
||||
decoded.ThreePC ||
|
||||
decoded.Reserved2 > 0 ||
|
||||
decoded.Protect)
|
||||
{
|
||||
length = 6;
|
||||
|
||||
if(decoded.SCCS)
|
||||
buffer[5] = 0x80;
|
||||
|
||||
if(decoded.ACC)
|
||||
buffer[5] += 0x40;
|
||||
|
||||
buffer[5] += (byte)(decoded.TPGS << 4);
|
||||
|
||||
if(decoded.ThreePC)
|
||||
buffer[5] += 0x08;
|
||||
|
||||
buffer[5] += (byte)(decoded.Reserved2 << 1);
|
||||
|
||||
if(decoded.Protect)
|
||||
buffer[5] += 0x01;
|
||||
}
|
||||
|
||||
if(decoded.BQue ||
|
||||
decoded.EncServ ||
|
||||
decoded.VS1 ||
|
||||
decoded.MultiP ||
|
||||
decoded.MChngr ||
|
||||
decoded.ACKREQQ ||
|
||||
decoded.Addr32 ||
|
||||
decoded.Addr16)
|
||||
{
|
||||
length = 7;
|
||||
|
||||
if(decoded.BQue)
|
||||
buffer[6] = 0x80;
|
||||
|
||||
if(decoded.EncServ)
|
||||
buffer[6] += 0x40;
|
||||
|
||||
if(decoded.VS1)
|
||||
buffer[6] += 0x20;
|
||||
|
||||
if(decoded.MultiP)
|
||||
buffer[6] += 0x10;
|
||||
|
||||
if(decoded.MChngr)
|
||||
buffer[6] += 0x08;
|
||||
|
||||
if(decoded.ACKREQQ)
|
||||
buffer[6] += 0x04;
|
||||
|
||||
if(decoded.Addr32)
|
||||
buffer[6] += 0x02;
|
||||
|
||||
if(decoded.Addr16)
|
||||
buffer[6] += 0x01;
|
||||
}
|
||||
|
||||
if(decoded.RelAddr ||
|
||||
decoded.WBus32 ||
|
||||
decoded.WBus16 ||
|
||||
decoded.Sync ||
|
||||
decoded.Linked ||
|
||||
decoded.TranDis ||
|
||||
decoded.CmdQue ||
|
||||
decoded.SftRe)
|
||||
|
||||
{
|
||||
length = 8;
|
||||
|
||||
if(decoded.RelAddr)
|
||||
buffer[7] = 0x80;
|
||||
|
||||
if(decoded.WBus32)
|
||||
buffer[7] += 0x40;
|
||||
|
||||
if(decoded.WBus16)
|
||||
buffer[7] += 0x20;
|
||||
|
||||
if(decoded.Sync)
|
||||
buffer[7] += 0x10;
|
||||
|
||||
if(decoded.Linked)
|
||||
buffer[7] += 0x08;
|
||||
|
||||
if(decoded.TranDis)
|
||||
buffer[7] += 0x04;
|
||||
|
||||
if(decoded.CmdQue)
|
||||
buffer[7] += 0x02;
|
||||
|
||||
if(decoded.SftRe)
|
||||
buffer[7] += 0x01;
|
||||
}
|
||||
|
||||
if(decoded.VendorIdentification != null)
|
||||
{
|
||||
length = 16;
|
||||
|
||||
Array.Copy(decoded.VendorIdentification, 0, buffer, 8,
|
||||
decoded.VendorIdentification.Length >= 8 ? 8 : decoded.VendorIdentification.Length);
|
||||
}
|
||||
|
||||
if(decoded.ProductIdentification != null)
|
||||
{
|
||||
length = 32;
|
||||
|
||||
Array.Copy(decoded.ProductIdentification, 0, buffer, 16,
|
||||
decoded.ProductIdentification.Length >= 16 ? 16 : decoded.ProductIdentification.Length);
|
||||
}
|
||||
|
||||
if(decoded.ProductRevisionLevel != null)
|
||||
{
|
||||
length = 36;
|
||||
|
||||
Array.Copy(decoded.ProductRevisionLevel, 0, buffer, 32,
|
||||
decoded.ProductRevisionLevel.Length >= 4 ? 4 : decoded.ProductRevisionLevel.Length);
|
||||
}
|
||||
|
||||
if(decoded.Seagate_DriveSerialNumber != null)
|
||||
{
|
||||
length = 44;
|
||||
Array.Copy(decoded.Seagate_DriveSerialNumber, 0, buffer, 36, 8);
|
||||
}
|
||||
|
||||
if(decoded.KreonIdentifier != null &&
|
||||
decoded.KreonVersion != null)
|
||||
{
|
||||
length = 46;
|
||||
Array.Copy(decoded.KreonIdentifier, 0, buffer, 36, 5);
|
||||
buffer[41] = decoded.KreonSpace;
|
||||
Array.Copy(decoded.KreonVersion, 0, buffer, 42, 5);
|
||||
}
|
||||
|
||||
if(decoded.HP_WORM ||
|
||||
decoded.HP_WORMVersion > 0 ||
|
||||
decoded.HP_OBDR != null)
|
||||
{
|
||||
length = 49;
|
||||
|
||||
if(decoded.HP_WORM)
|
||||
buffer[40] = 0x01;
|
||||
|
||||
buffer[40] += (byte)(decoded.HP_WORMVersion << 1);
|
||||
Array.Copy(decoded.HP_OBDR, 0, buffer, 43, 6);
|
||||
}
|
||||
|
||||
if(decoded.IsHiMD)
|
||||
{
|
||||
length = 56;
|
||||
Array.Copy(HiMDSignatureContents, 0, buffer, 36, 8);
|
||||
|
||||
if(decoded.HiMDSpecific != null)
|
||||
Array.Copy(decoded.HiMDSpecific, 0, buffer, 44, 12);
|
||||
}
|
||||
|
||||
if(decoded.VendorSpecific != null &&
|
||||
!decoded.IsHiMD)
|
||||
{
|
||||
length = 56;
|
||||
Array.Copy(decoded.VendorSpecific, 0, buffer, 36, 20);
|
||||
}
|
||||
|
||||
if(decoded.Reserved3 > 0 ||
|
||||
decoded.Clocking > 0 ||
|
||||
decoded.QAS ||
|
||||
decoded.IUS)
|
||||
{
|
||||
length = 57;
|
||||
buffer[56] = (byte)(decoded.Reserved3 << 4);
|
||||
buffer[56] += (byte)(decoded.Clocking << 2);
|
||||
|
||||
if(decoded.QAS)
|
||||
buffer[56] += 0x02;
|
||||
|
||||
if(decoded.IUS)
|
||||
buffer[56] += 0x01;
|
||||
}
|
||||
|
||||
if(decoded.Reserved4 != 0)
|
||||
{
|
||||
length = 58;
|
||||
buffer[57] = decoded.Reserved4;
|
||||
}
|
||||
|
||||
if(decoded.VersionDescriptors != null)
|
||||
{
|
||||
length = (byte)(58 + (decoded.VersionDescriptors.Length * 2));
|
||||
|
||||
for(int i = 0; i < decoded.VersionDescriptors.Length; i++)
|
||||
Array.Copy(BitConverter.GetBytes(decoded.VersionDescriptors[i]), 0, buffer, 56 + (i * 2), 2);
|
||||
}
|
||||
|
||||
if(decoded.Reserved5 != null)
|
||||
{
|
||||
length = (byte)(74 + decoded.Reserved5.Length);
|
||||
Array.Copy(decoded.Reserved5, 0, buffer, 74, decoded.Reserved5.Length);
|
||||
}
|
||||
|
||||
if(decoded.VendorSpecific2 != null)
|
||||
{
|
||||
length = (byte)(96 + decoded.VendorSpecific2.Length);
|
||||
Array.Copy(decoded.VendorSpecific2, 0, buffer, 96, decoded.VendorSpecific2.Length);
|
||||
}
|
||||
|
||||
if(decoded.Seagate_Copyright != null)
|
||||
{
|
||||
length = 144;
|
||||
Array.Copy(decoded.Seagate_Copyright, 0, buffer, 96, 48);
|
||||
}
|
||||
|
||||
if(decoded.Seagate_ServoPROMPartNo != null)
|
||||
{
|
||||
length = 148;
|
||||
Array.Copy(decoded.Seagate_ServoPROMPartNo, 0, buffer, 144, 4);
|
||||
}
|
||||
|
||||
buffer[4] = length;
|
||||
byte[] dest = new byte[length];
|
||||
Array.Copy(buffer, 0, dest, 0, length);
|
||||
|
||||
return dest;
|
||||
}
|
||||
#endregion Public methods
|
||||
}
|
||||
}
|
||||
@@ -1,514 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : 2A.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures for SCSI devices.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Decodes SCSI MODE PAGE 2Ah: CD-ROM capabilities page.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Aaru.CommonTypes.Structs.Devices.SCSI.Modes
|
||||
{
|
||||
#region Mode Page 0x2A: CD-ROM capabilities page
|
||||
/// <summary>
|
||||
/// CD-ROM capabilities page Page code 0x2A 16 bytes in OB-U0077C 20 bytes in SFF-8020i 22 bytes in MMC-1 26 bytes
|
||||
/// in MMC-2 Variable bytes in MMC-3
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
|
||||
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
||||
public class ModePage_2A
|
||||
{
|
||||
/// <summary>Write speed performance descriptors</summary>
|
||||
public ModePage_2A_WriteDescriptor[] WriteSpeedPerformanceDescriptors;
|
||||
/// <summary>Parameters can be saved</summary>
|
||||
public bool PS { get; set; }
|
||||
/// <summary>Drive supports multi-session and/or Photo-CD</summary>
|
||||
public bool MultiSession { get; set; }
|
||||
/// <summary>Drive is capable of reading sectors in Mode 2 Form 2 format</summary>
|
||||
public bool Mode2Form2 { get; set; }
|
||||
/// <summary>Drive is capable of reading sectors in Mode 2 Form 1 format</summary>
|
||||
public bool Mode2Form1 { get; set; }
|
||||
/// <summary>Drive is capable of playing audio</summary>
|
||||
public bool AudioPlay { get; set; }
|
||||
/// <summary>Drive can return the ISRC</summary>
|
||||
public bool ISRC { get; set; }
|
||||
/// <summary>Drive can return the media catalogue number</summary>
|
||||
public bool UPC { get; set; }
|
||||
/// <summary>Drive can return C2 pointers</summary>
|
||||
public bool C2Pointer { get; set; }
|
||||
/// <summary>Drive can read, deinterlave and correct R-W subchannels</summary>
|
||||
public bool DeinterlaveSubchannel { get; set; }
|
||||
/// <summary>Drive can read interleaved and uncorrected R-W subchannels</summary>
|
||||
public bool Subchannel { get; set; }
|
||||
/// <summary>Drive can continue from a loss of streaming on audio reading</summary>
|
||||
public bool AccurateCDDA { get; set; }
|
||||
/// <summary>Audio can be read as digital data</summary>
|
||||
public bool CDDACommand { get; set; }
|
||||
/// <summary>Loading Mechanism Type</summary>
|
||||
public byte LoadingMechanism { get; set; }
|
||||
/// <summary>Drive can eject discs</summary>
|
||||
public bool Eject { get; set; }
|
||||
/// <summary>Drive's optional prevent jumper status</summary>
|
||||
public bool PreventJumper { get; set; }
|
||||
/// <summary>Current lock status</summary>
|
||||
public bool LockState { get; set; }
|
||||
/// <summary>Drive can lock media</summary>
|
||||
public bool Lock { get; set; }
|
||||
/// <summary>Each channel can be muted independently</summary>
|
||||
public bool SeparateChannelMute { get; set; }
|
||||
/// <summary>Each channel's volume can be controlled independently</summary>
|
||||
public bool SeparateChannelVolume { get; set; }
|
||||
/// <summary>Maximum drive speed in Kbytes/second</summary>
|
||||
public ushort MaximumSpeed { get; set; }
|
||||
/// <summary>Supported volume levels</summary>
|
||||
public ushort SupportedVolumeLevels { get; set; }
|
||||
/// <summary>Buffer size in Kbytes</summary>
|
||||
public ushort BufferSize { get; set; }
|
||||
/// <summary>Current drive speed in Kbytes/second</summary>
|
||||
public ushort CurrentSpeed { get; set; }
|
||||
|
||||
/// <summary>Can read packet media</summary>
|
||||
public bool Method2 { get; set; }
|
||||
/// <summary>Can read CD-RW</summary>
|
||||
public bool ReadCDRW { get; set; }
|
||||
/// <summary>Can read CD-R</summary>
|
||||
public bool ReadCDR { get; set; }
|
||||
/// <summary>Can write CD-RW</summary>
|
||||
public bool WriteCDRW { get; set; }
|
||||
/// <summary>Can write CD-R</summary>
|
||||
public bool WriteCDR { get; set; }
|
||||
/// <summary>Supports IEC-958 digital output on port 2</summary>
|
||||
public bool DigitalPort2 { get; set; }
|
||||
/// <summary>Supports IEC-958 digital output on port 1</summary>
|
||||
public bool DigitalPort1 { get; set; }
|
||||
/// <summary>Can deliver a composite audio and video data stream</summary>
|
||||
public bool Composite { get; set; }
|
||||
/// <summary>This bit controls the behavior of the LOAD/UNLOAD command when trying to load a Slot with no Disc present</summary>
|
||||
public bool SSS { get; set; }
|
||||
/// <summary>Contains a changer that can report the exact contents of the slots</summary>
|
||||
public bool SDP { get; set; }
|
||||
/// <summary>Page length</summary>
|
||||
public byte Length { get; set; }
|
||||
/// <summary>Set if LSB comes first</summary>
|
||||
public bool LSBF { get; set; }
|
||||
/// <summary>Set if HIGH on LRCK indicates left channel. Clear if HIGH on LRCK indicates right channel.</summary>
|
||||
public bool RCK { get; set; }
|
||||
/// <summary>
|
||||
/// Set if data valid on the falling edge of the BCK signal. Clear if data valid on the rising edge of the BCK
|
||||
/// signal
|
||||
/// </summary>
|
||||
public bool BCK { get; set; }
|
||||
|
||||
/// <summary>Can do a test write</summary>
|
||||
public bool TestWrite { get; set; }
|
||||
/// <summary>Maximum write speed</summary>
|
||||
public ushort MaxWriteSpeed { get; set; }
|
||||
/// <summary>Current write speed</summary>
|
||||
public ushort CurrentWriteSpeed { get; set; }
|
||||
/// <summary>Can read disc's barcode</summary>
|
||||
public bool ReadBarcode { get; set; }
|
||||
/// <summary>Can read DVD-RAM</summary>
|
||||
public bool ReadDVDRAM { get; set; }
|
||||
/// <summary>Can read DVD-R</summary>
|
||||
public bool ReadDVDR { get; set; }
|
||||
/// <summary>Can read DVD-ROM</summary>
|
||||
public bool ReadDVDROM { get; set; }
|
||||
/// <summary>Can write DVD-RAM</summary>
|
||||
public bool WriteDVDRAM { get; set; }
|
||||
/// <summary>Can write DVD-R</summary>
|
||||
public bool WriteDVDR { get; set; }
|
||||
/// <summary>Can read raw R-W subchannel from the Lead-In</summary>
|
||||
public bool LeadInPW { get; set; }
|
||||
/// <summary>Can read both sides of a disc</summary>
|
||||
public bool SCC { get; set; }
|
||||
/// <summary>Support copyright management</summary>
|
||||
public ushort CMRSupported { get; set; }
|
||||
/// <summary>Supports buffer under-run free recording</summary>
|
||||
public bool BUF { get; set; }
|
||||
/// <summary>Selected rotational control</summary>
|
||||
public byte RotationControlSelected { get; set; }
|
||||
/// <summary>Current write speed selected</summary>
|
||||
public ushort CurrentWriteSpeedSelected { get; set; }
|
||||
|
||||
/// <summary>Database ID</summary>
|
||||
[JsonIgnore, Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>Decodes the page 2Ah of a MODE SENSE response</summary>
|
||||
/// <param name="pageResponse">Raw page 2Ah</param>
|
||||
/// <returns>Decoded page 2Ah</returns>
|
||||
public static ModePage_2A Decode(byte[] pageResponse)
|
||||
{
|
||||
if((pageResponse?[0] & 0x40) == 0x40)
|
||||
return null;
|
||||
|
||||
if((pageResponse?[0] & 0x3F) != 0x2A)
|
||||
return null;
|
||||
|
||||
if(pageResponse[1] + 2 != pageResponse.Length)
|
||||
return null;
|
||||
|
||||
if(pageResponse.Length < 16)
|
||||
return null;
|
||||
|
||||
var decoded = new ModePage_2A();
|
||||
|
||||
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
|
||||
|
||||
decoded.AudioPlay |= (pageResponse[4] & 0x01) == 0x01;
|
||||
decoded.Mode2Form1 |= (pageResponse[4] & 0x10) == 0x10;
|
||||
decoded.Mode2Form2 |= (pageResponse[4] & 0x20) == 0x20;
|
||||
decoded.MultiSession |= (pageResponse[4] & 0x40) == 0x40;
|
||||
|
||||
decoded.CDDACommand |= (pageResponse[5] & 0x01) == 0x01;
|
||||
decoded.AccurateCDDA |= (pageResponse[5] & 0x02) == 0x02;
|
||||
decoded.Subchannel |= (pageResponse[5] & 0x04) == 0x04;
|
||||
decoded.DeinterlaveSubchannel |= (pageResponse[5] & 0x08) == 0x08;
|
||||
decoded.C2Pointer |= (pageResponse[5] & 0x10) == 0x10;
|
||||
decoded.UPC |= (pageResponse[5] & 0x20) == 0x20;
|
||||
decoded.ISRC |= (pageResponse[5] & 0x40) == 0x40;
|
||||
|
||||
decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5);
|
||||
decoded.Lock |= (pageResponse[6] & 0x01) == 0x01;
|
||||
decoded.LockState |= (pageResponse[6] & 0x02) == 0x02;
|
||||
decoded.PreventJumper |= (pageResponse[6] & 0x04) == 0x04;
|
||||
decoded.Eject |= (pageResponse[6] & 0x08) == 0x08;
|
||||
|
||||
decoded.SeparateChannelVolume |= (pageResponse[7] & 0x01) == 0x01;
|
||||
decoded.SeparateChannelMute |= (pageResponse[7] & 0x02) == 0x02;
|
||||
|
||||
decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
|
||||
decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
|
||||
decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
|
||||
decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]);
|
||||
|
||||
if(pageResponse.Length < 20)
|
||||
return decoded;
|
||||
|
||||
decoded.Method2 |= (pageResponse[2] & 0x04) == 0x04;
|
||||
decoded.ReadCDRW |= (pageResponse[2] & 0x02) == 0x02;
|
||||
decoded.ReadCDR |= (pageResponse[2] & 0x01) == 0x01;
|
||||
|
||||
decoded.WriteCDRW |= (pageResponse[3] & 0x02) == 0x02;
|
||||
decoded.WriteCDR |= (pageResponse[3] & 0x01) == 0x01;
|
||||
|
||||
decoded.Composite |= (pageResponse[4] & 0x02) == 0x02;
|
||||
decoded.DigitalPort1 |= (pageResponse[4] & 0x04) == 0x04;
|
||||
decoded.DigitalPort2 |= (pageResponse[4] & 0x08) == 0x08;
|
||||
|
||||
decoded.SDP |= (pageResponse[7] & 0x04) == 0x04;
|
||||
decoded.SSS |= (pageResponse[7] & 0x08) == 0x08;
|
||||
|
||||
decoded.Length = (byte)((pageResponse[17] & 0x30) >> 4);
|
||||
decoded.LSBF |= (pageResponse[17] & 0x08) == 0x08;
|
||||
decoded.RCK |= (pageResponse[17] & 0x04) == 0x04;
|
||||
decoded.BCK |= (pageResponse[17] & 0x02) == 0x02;
|
||||
|
||||
if(pageResponse.Length < 22)
|
||||
return decoded;
|
||||
|
||||
decoded.TestWrite |= (pageResponse[3] & 0x04) == 0x04;
|
||||
decoded.MaxWriteSpeed = (ushort)((pageResponse[18] << 8) + pageResponse[19]);
|
||||
decoded.CurrentWriteSpeed = (ushort)((pageResponse[20] << 8) + pageResponse[21]);
|
||||
|
||||
decoded.ReadBarcode |= (pageResponse[5] & 0x80) == 0x80;
|
||||
|
||||
if(pageResponse.Length < 26)
|
||||
return decoded;
|
||||
|
||||
decoded.ReadDVDRAM |= (pageResponse[2] & 0x20) == 0x20;
|
||||
decoded.ReadDVDR |= (pageResponse[2] & 0x10) == 0x10;
|
||||
decoded.ReadDVDROM |= (pageResponse[2] & 0x08) == 0x08;
|
||||
|
||||
decoded.WriteDVDRAM |= (pageResponse[3] & 0x20) == 0x20;
|
||||
decoded.WriteDVDR |= (pageResponse[3] & 0x10) == 0x10;
|
||||
|
||||
decoded.LeadInPW |= (pageResponse[3] & 0x20) == 0x20;
|
||||
decoded.SCC |= (pageResponse[3] & 0x10) == 0x10;
|
||||
|
||||
decoded.CMRSupported = (ushort)((pageResponse[22] << 8) + pageResponse[23]);
|
||||
|
||||
if(pageResponse.Length < 32)
|
||||
return decoded;
|
||||
|
||||
decoded.BUF |= (pageResponse[4] & 0x80) == 0x80;
|
||||
decoded.RotationControlSelected = (byte)(pageResponse[27] & 0x03);
|
||||
decoded.CurrentWriteSpeedSelected = (ushort)((pageResponse[28] << 8) + pageResponse[29]);
|
||||
|
||||
ushort descriptors = (ushort)((pageResponse.Length - 32) / 4);
|
||||
decoded.WriteSpeedPerformanceDescriptors = new ModePage_2A_WriteDescriptor[descriptors];
|
||||
|
||||
for(int i = 0; i < descriptors; i++)
|
||||
decoded.WriteSpeedPerformanceDescriptors[i] = new ModePage_2A_WriteDescriptor
|
||||
{
|
||||
RotationControl = (byte)(pageResponse[1 + 32 + (i * 4)] & 0x07),
|
||||
WriteSpeed = (ushort)((pageResponse[2 + 32 + (i * 4)] << 8) + pageResponse[3 + 32 + (i * 4)])
|
||||
};
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
/// <summary>Encodes a page 2Ah of a MODE SENSE response</summary>
|
||||
/// <param name="decoded">Decoded page 2Ah</param>
|
||||
/// <returns>Raw page 2Ah</returns>
|
||||
public static byte[] Encode(ModePage_2A decoded)
|
||||
{
|
||||
byte[] pageResponse = new byte[512];
|
||||
byte length = 16;
|
||||
|
||||
pageResponse[0] = 0x2A;
|
||||
|
||||
if(decoded.PS)
|
||||
pageResponse[0] += 0x80;
|
||||
|
||||
if(decoded.AudioPlay)
|
||||
pageResponse[4] += 0x01;
|
||||
|
||||
if(decoded.Mode2Form1)
|
||||
pageResponse[4] += 0x10;
|
||||
|
||||
if(decoded.Mode2Form2)
|
||||
pageResponse[4] += 0x20;
|
||||
|
||||
if(decoded.MultiSession)
|
||||
pageResponse[4] += 0x40;
|
||||
|
||||
if(decoded.CDDACommand)
|
||||
pageResponse[5] += 0x01;
|
||||
|
||||
if(decoded.AccurateCDDA)
|
||||
pageResponse[5] += 0x02;
|
||||
|
||||
if(decoded.Subchannel)
|
||||
pageResponse[5] += 0x04;
|
||||
|
||||
if(decoded.DeinterlaveSubchannel)
|
||||
pageResponse[5] += 0x08;
|
||||
|
||||
if(decoded.C2Pointer)
|
||||
pageResponse[5] += 0x10;
|
||||
|
||||
if(decoded.UPC)
|
||||
pageResponse[5] += 0x20;
|
||||
|
||||
if(decoded.ISRC)
|
||||
pageResponse[5] += 0x40;
|
||||
|
||||
decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5);
|
||||
|
||||
if(decoded.Lock)
|
||||
pageResponse[6] += 0x01;
|
||||
|
||||
if(decoded.LockState)
|
||||
pageResponse[6] += 0x02;
|
||||
|
||||
if(decoded.PreventJumper)
|
||||
pageResponse[6] += 0x04;
|
||||
|
||||
if(decoded.Eject)
|
||||
pageResponse[6] += 0x08;
|
||||
|
||||
if(decoded.SeparateChannelVolume)
|
||||
pageResponse[7] += 0x01;
|
||||
|
||||
if(decoded.SeparateChannelMute)
|
||||
pageResponse[7] += 0x02;
|
||||
|
||||
decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
|
||||
decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
|
||||
decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
|
||||
decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]);
|
||||
|
||||
if(decoded.Method2 ||
|
||||
decoded.ReadCDRW ||
|
||||
decoded.ReadCDR ||
|
||||
decoded.WriteCDRW ||
|
||||
decoded.WriteCDR ||
|
||||
decoded.Composite ||
|
||||
decoded.DigitalPort1 ||
|
||||
decoded.DigitalPort2 ||
|
||||
decoded.SDP ||
|
||||
decoded.SSS ||
|
||||
decoded.Length > 0 ||
|
||||
decoded.LSBF ||
|
||||
decoded.RCK ||
|
||||
decoded.BCK)
|
||||
{
|
||||
length = 20;
|
||||
|
||||
if(decoded.Method2)
|
||||
pageResponse[2] += 0x04;
|
||||
|
||||
if(decoded.ReadCDRW)
|
||||
pageResponse[2] += 0x02;
|
||||
|
||||
if(decoded.ReadCDR)
|
||||
pageResponse[2] += 0x01;
|
||||
|
||||
if(decoded.WriteCDRW)
|
||||
pageResponse[3] += 0x02;
|
||||
|
||||
if(decoded.WriteCDR)
|
||||
pageResponse[3] += 0x01;
|
||||
|
||||
if(decoded.Composite)
|
||||
pageResponse[4] += 0x02;
|
||||
|
||||
if(decoded.DigitalPort1)
|
||||
pageResponse[4] += 0x04;
|
||||
|
||||
if(decoded.DigitalPort2)
|
||||
pageResponse[4] += 0x08;
|
||||
|
||||
if(decoded.SDP)
|
||||
pageResponse[7] += 0x04;
|
||||
|
||||
if(decoded.SSS)
|
||||
pageResponse[7] += 0x08;
|
||||
|
||||
pageResponse[17] = (byte)(decoded.Length << 4);
|
||||
|
||||
if(decoded.LSBF)
|
||||
pageResponse[17] += 0x08;
|
||||
|
||||
if(decoded.RCK)
|
||||
pageResponse[17] += 0x04;
|
||||
|
||||
if(decoded.BCK)
|
||||
pageResponse[17] += 0x02;
|
||||
}
|
||||
|
||||
if(decoded.TestWrite ||
|
||||
decoded.MaxWriteSpeed > 0 ||
|
||||
decoded.CurrentWriteSpeed > 0 ||
|
||||
decoded.ReadBarcode)
|
||||
{
|
||||
length = 22;
|
||||
|
||||
if(decoded.TestWrite)
|
||||
pageResponse[3] += 0x04;
|
||||
|
||||
pageResponse[18] = (byte)((decoded.MaxWriteSpeed & 0xFF00) >> 8);
|
||||
pageResponse[19] = (byte)(decoded.MaxWriteSpeed & 0xFF);
|
||||
pageResponse[20] = (byte)((decoded.CurrentWriteSpeed & 0xFF00) >> 8);
|
||||
pageResponse[21] = (byte)(decoded.CurrentWriteSpeed & 0xFF);
|
||||
|
||||
if(decoded.ReadBarcode)
|
||||
pageResponse[5] += 0x80;
|
||||
}
|
||||
|
||||
if(decoded.ReadDVDRAM ||
|
||||
decoded.ReadDVDR ||
|
||||
decoded.ReadDVDROM ||
|
||||
decoded.WriteDVDRAM ||
|
||||
decoded.WriteDVDR ||
|
||||
decoded.LeadInPW ||
|
||||
decoded.SCC ||
|
||||
decoded.CMRSupported > 0)
|
||||
|
||||
{
|
||||
length = 26;
|
||||
|
||||
if(decoded.ReadDVDRAM)
|
||||
pageResponse[2] += 0x20;
|
||||
|
||||
if(decoded.ReadDVDR)
|
||||
pageResponse[2] += 0x10;
|
||||
|
||||
if(decoded.ReadDVDROM)
|
||||
pageResponse[2] += 0x08;
|
||||
|
||||
if(decoded.WriteDVDRAM)
|
||||
pageResponse[3] += 0x20;
|
||||
|
||||
if(decoded.WriteDVDR)
|
||||
pageResponse[3] += 0x10;
|
||||
|
||||
if(decoded.LeadInPW)
|
||||
pageResponse[3] += 0x20;
|
||||
|
||||
if(decoded.SCC)
|
||||
pageResponse[3] += 0x10;
|
||||
|
||||
pageResponse[22] = (byte)((decoded.CMRSupported & 0xFF00) >> 8);
|
||||
pageResponse[23] = (byte)(decoded.CMRSupported & 0xFF);
|
||||
}
|
||||
|
||||
if(decoded.BUF ||
|
||||
decoded.RotationControlSelected > 0 ||
|
||||
decoded.CurrentWriteSpeedSelected > 0)
|
||||
{
|
||||
length = 32;
|
||||
|
||||
if(decoded.BUF)
|
||||
pageResponse[4] += 0x80;
|
||||
|
||||
pageResponse[27] += decoded.RotationControlSelected;
|
||||
pageResponse[28] = (byte)((decoded.CurrentWriteSpeedSelected & 0xFF00) >> 8);
|
||||
pageResponse[29] = (byte)(decoded.CurrentWriteSpeedSelected & 0xFF);
|
||||
}
|
||||
|
||||
if(decoded.WriteSpeedPerformanceDescriptors != null)
|
||||
{
|
||||
length = 32;
|
||||
|
||||
for(int i = 0; i < decoded.WriteSpeedPerformanceDescriptors.Length; i++)
|
||||
{
|
||||
length += 4;
|
||||
pageResponse[1 + 32 + (i * 4)] = decoded.WriteSpeedPerformanceDescriptors[i].RotationControl;
|
||||
|
||||
pageResponse[2 + 32 + (i * 4)] =
|
||||
(byte)((decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF00) >> 8);
|
||||
|
||||
pageResponse[3 + 32 + (i * 4)] =
|
||||
(byte)(decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
pageResponse[1] = (byte)(length - 2);
|
||||
byte[] buf = new byte[length];
|
||||
Array.Copy(pageResponse, 0, buf, 0, length);
|
||||
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Page 2Ah write descriptor</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public struct ModePage_2A_WriteDescriptor
|
||||
{
|
||||
/// <summary>Rotational control</summary>
|
||||
public byte RotationControl;
|
||||
/// <summary>Write speed</summary>
|
||||
public ushort WriteSpeed;
|
||||
}
|
||||
#endregion Mode Page 0x2A: CD-ROM capabilities page
|
||||
}
|
||||
@@ -1,281 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Structs.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains enumerations and structures of common usage by filesystem
|
||||
// plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Aaru.CommonTypes.Structs
|
||||
{
|
||||
/// <summary>File attributes.</summary>
|
||||
[Flags]
|
||||
public enum FileAttributes : ulong
|
||||
{
|
||||
/// <summary>File has no attributes</summary>
|
||||
None = 0,
|
||||
/// <summary>File is an alias (Mac OS)</summary>
|
||||
Alias = 0x01,
|
||||
/// <summary>Indicates that the file can only be writable appended</summary>
|
||||
AppendOnly = 0x02,
|
||||
/// <summary>File is candidate for archival/backup</summary>
|
||||
Archive = 0x04,
|
||||
/// <summary>File is a block device</summary>
|
||||
BlockDevice = 0x08,
|
||||
/// <summary>File is stored on filesystem block units instead of device sectors</summary>
|
||||
BlockUnits = 0x10,
|
||||
/// <summary>Directory is a bundle or file contains a BNDL resource</summary>
|
||||
Bundle = 0x20,
|
||||
/// <summary>File is a char device</summary>
|
||||
CharDevice = 0x40,
|
||||
/// <summary>File is compressed</summary>
|
||||
Compressed = 0x80,
|
||||
/// <summary>File is compressed and should not be uncompressed on read</summary>
|
||||
CompressedRaw = 0x100,
|
||||
/// <summary>File has compression errors</summary>
|
||||
CompressionError = 0x200,
|
||||
/// <summary>Compressed file is dirty</summary>
|
||||
CompressionDirty = 0x400,
|
||||
/// <summary>File is a device</summary>
|
||||
Device = 0x800,
|
||||
/// <summary>File is a directory</summary>
|
||||
Directory = 0x1000,
|
||||
/// <summary>File is encrypted</summary>
|
||||
Encrypted = 0x2000,
|
||||
/// <summary>File is stored on disk using extents</summary>
|
||||
Extents = 0x4000,
|
||||
/// <summary>File is a FIFO</summary>
|
||||
FIFO = 0x8000,
|
||||
/// <summary>File is a normal file</summary>
|
||||
File = 0x10000,
|
||||
/// <summary>File is a Mac OS file containing desktop databases that has already been added to the desktop database</summary>
|
||||
HasBeenInited = 0x20000,
|
||||
/// <summary>File contains an icon resource / EA</summary>
|
||||
HasCustomIcon = 0x40000,
|
||||
/// <summary>File is a Mac OS extension or control panel lacking INIT resources</summary>
|
||||
HasNoINITs = 0x80000,
|
||||
/// <summary>File is hidden/invisible</summary>
|
||||
Hidden = 0x100000,
|
||||
/// <summary>File cannot be written, deleted, modified or linked to</summary>
|
||||
Immutable = 0x200000,
|
||||
/// <summary>Directory is indexed using hashed trees</summary>
|
||||
IndexedDirectory = 0x400000,
|
||||
/// <summary>File contents are stored alongside its inode (or equivalent)</summary>
|
||||
Inline = 0x800000,
|
||||
/// <summary>File contains integrity checks</summary>
|
||||
IntegrityStream = 0x1000000,
|
||||
/// <summary>File is on desktop</summary>
|
||||
IsOnDesk = 0x2000000,
|
||||
/// <summary>File changes are written to filesystem journal before being written to file itself</summary>
|
||||
Journaled = 0x4000000,
|
||||
/// <summary>Access time will not be modified</summary>
|
||||
NoAccessTime = 0x8000000,
|
||||
/// <summary>File will not be subject to copy-on-write</summary>
|
||||
NoCopyOnWrite = 0x10000000,
|
||||
/// <summary>File will not be backed up</summary>
|
||||
NoDump = 0x20000000,
|
||||
/// <summary>File contents should not be scrubbed</summary>
|
||||
NoScrub = 0x40000000,
|
||||
/// <summary>File contents should not be indexed</summary>
|
||||
NotIndexed = 0x80000000,
|
||||
/// <summary>File is offline</summary>
|
||||
Offline = 0x100000000,
|
||||
/// <summary>File is password protected, but contents are not encrypted on disk</summary>
|
||||
Password = 0x200000000,
|
||||
/// <summary>File is read-only</summary>
|
||||
ReadOnly = 0x400000000,
|
||||
/// <summary>File is a reparse point</summary>
|
||||
ReparsePoint = 0x800000000,
|
||||
/// <summary>When file is removed its content will be overwritten with zeroes</summary>
|
||||
Secured = 0x1000000000,
|
||||
/// <summary>File contents are sparse</summary>
|
||||
Sparse = 0x2000000000,
|
||||
/// <summary>File is a shadow (OS/2)</summary>
|
||||
Shadow = 0x4000000000,
|
||||
/// <summary>File is shared</summary>
|
||||
Shared = 0x8000000000,
|
||||
/// <summary>File is a stationery</summary>
|
||||
Stationery = 0x10000000000,
|
||||
/// <summary>File is a symbolic link</summary>
|
||||
Symlink = 0x20000000000,
|
||||
/// <summary>File writes are synchronously written to disk</summary>
|
||||
Sync = 0x40000000000,
|
||||
/// <summary>File belongs to the operating system</summary>
|
||||
System = 0x80000000000,
|
||||
/// <summary>If file end is a partial block its content will be merged with other files</summary>
|
||||
TailMerged = 0x100000000000,
|
||||
/// <summary>File is temporary</summary>
|
||||
Temporary = 0x200000000000,
|
||||
/// <summary>Subdirectories inside of this directory are not related and should be allocated elsewhere</summary>
|
||||
TopDirectory = 0x400000000000,
|
||||
/// <summary>If file is deleted, contents should be stored, for a possible future undeletion</summary>
|
||||
Undeletable = 0x800000000000,
|
||||
/// <summary>File is a pipe</summary>
|
||||
Pipe = 0x1000000000000,
|
||||
/// <summary>File is a socket</summary>
|
||||
Socket = 0x2000000000000
|
||||
}
|
||||
|
||||
/// <summary>Information about a file entry</summary>
|
||||
public class FileEntryInfo
|
||||
{
|
||||
/// <summary>File attributes</summary>
|
||||
public FileAttributes Attributes { get; set; }
|
||||
/// <summary>File length in blocks</summary>
|
||||
public long Blocks { get; set; }
|
||||
/// <summary>File block size in bytes</summary>
|
||||
public long BlockSize { get; set; }
|
||||
/// <summary>If file points to a device, device number. Null if the underlying filesystem does not support them.</summary>
|
||||
public ulong? DeviceNo { get; set; }
|
||||
/// <summary>POSIX group ID. Null if the underlying filesystem does not support them.</summary>
|
||||
public ulong? GID { get; set; }
|
||||
/// <summary>inode number for this file (or other unique identifier for the volume)</summary>
|
||||
public ulong Inode { get; set; }
|
||||
/// <summary>File length in bytes</summary>
|
||||
public long Length { get; set; }
|
||||
/// <summary>Number of hard links pointing to this file (. and .. entries count as hard links)</summary>
|
||||
public ulong Links { get; set; }
|
||||
/// <summary>POSIX permissions/mode for this file. Null if the underlying filesystem does not support them.</summary>
|
||||
public uint? Mode { get; set; }
|
||||
/// <summary>POSIX owner ID. Null if the underlying filesystem does not support them.</summary>
|
||||
public ulong? UID { get; set; }
|
||||
/// <summary>File creation date in UTC. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? CreationTimeUtc { get; set; }
|
||||
/// <summary>File last access date in UTC. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? AccessTimeUtc { get; set; }
|
||||
/// <summary>File attributes change date in UTC. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? StatusChangeTimeUtc { get; set; }
|
||||
/// <summary>File last backup date in UTC. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? BackupTimeUtc { get; set; }
|
||||
/// <summary>File last modification date in UTC. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? LastWriteTimeUtc { get; set; }
|
||||
|
||||
/// <summary>File creation date. Null if the underlying filesystem does not support them.</summary>
|
||||
[JsonIgnore]
|
||||
public DateTime? CreationTime
|
||||
{
|
||||
get => CreationTimeUtc?.ToLocalTime();
|
||||
set => CreationTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
|
||||
/// <summary>File last access date. Null if the underlying filesystem does not support them.</summary>
|
||||
[JsonIgnore]
|
||||
public DateTime? AccessTime
|
||||
{
|
||||
get => AccessTimeUtc?.ToLocalTime();
|
||||
set => AccessTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
|
||||
/// <summary>File attributes change date. Null if the underlying filesystem does not support them.</summary>
|
||||
[JsonIgnore]
|
||||
public DateTime? StatusChangeTime
|
||||
{
|
||||
get => StatusChangeTimeUtc?.ToLocalTime();
|
||||
set => StatusChangeTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
|
||||
/// <summary>File last backup date. Null if the underlying filesystem does not support them.</summary>
|
||||
[JsonIgnore]
|
||||
public DateTime? BackupTime
|
||||
{
|
||||
get => BackupTimeUtc?.ToLocalTime();
|
||||
set => BackupTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
|
||||
/// <summary>File last modification date. Null if the underlying filesystem does not support them.</summary>
|
||||
[JsonIgnore]
|
||||
public DateTime? LastWriteTime
|
||||
{
|
||||
get => LastWriteTimeUtc?.ToLocalTime();
|
||||
set => LastWriteTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Information about a volume</summary>
|
||||
public class FileSystemInfo
|
||||
{
|
||||
/// <summary>Blocks for this filesystem</summary>
|
||||
public ulong Blocks;
|
||||
/// <summary>Maximum length of filenames on this filesystem</summary>
|
||||
public ushort FilenameLength;
|
||||
/// <summary>Files on this filesystem</summary>
|
||||
public ulong Files;
|
||||
/// <summary>Blocks free on this filesystem</summary>
|
||||
public ulong FreeBlocks;
|
||||
/// <summary>Free inodes on this filesystem</summary>
|
||||
public ulong FreeFiles;
|
||||
/// <summary>Filesystem ID</summary>
|
||||
public FileSystemId Id;
|
||||
/// <summary>ID of plugin for this file</summary>
|
||||
public Guid PluginId;
|
||||
/// <summary>Filesystem type</summary>
|
||||
public string Type;
|
||||
|
||||
/// <summary>Initializes an empty instance of this structure</summary>
|
||||
public FileSystemInfo() => Id = new FileSystemId();
|
||||
|
||||
/// <summary>Gets a clone of this structure</summary>
|
||||
/// <returns>Clone of this structure</returns>
|
||||
public FileSystemInfo ShallowCopy() => (FileSystemInfo)MemberwiseClone();
|
||||
}
|
||||
|
||||
/// <summary>Stores a filesystem volume unique identifier or serial number</summary>
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct FileSystemId
|
||||
{
|
||||
/// <summary>Set to <c>true</c> if the identifier is a 32-bit integer</summary>
|
||||
[FieldOffset(0)]
|
||||
public bool IsInt;
|
||||
/// <summary>Set to <c>true</c> if the identifier is a 64-bit integer</summary>
|
||||
[FieldOffset(1)]
|
||||
public bool IsLong;
|
||||
/// <summary>Set to <c>true</c> if the identifier is a GUID</summary>
|
||||
[FieldOffset(2)]
|
||||
public bool IsGuid;
|
||||
|
||||
/// <summary>Identifier as a 32-bit integer</summary>
|
||||
[FieldOffset(3)]
|
||||
public uint Serial32;
|
||||
/// <summary>Identifier as a 64-bit integer</summary>
|
||||
[FieldOffset(3)]
|
||||
public ulong Serial64;
|
||||
/// <summary>Identifier as a GUID</summary>
|
||||
[FieldOffset(3)]
|
||||
public Guid uuid;
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IMediaImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines structures to be used by media image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.CommonTypes.Structs
|
||||
{
|
||||
/// <summary>Contains information about a dump image and its contents</summary>
|
||||
public struct ImageInfo
|
||||
{
|
||||
/// <summary>Image contains partitions (or tracks for optical media)</summary>
|
||||
public bool HasPartitions;
|
||||
/// <summary>Image contains sessions (optical media only)</summary>
|
||||
public bool HasSessions;
|
||||
/// <summary>Size of the image without headers</summary>
|
||||
public ulong ImageSize;
|
||||
/// <summary>Sectors contained in the image</summary>
|
||||
public ulong Sectors;
|
||||
/// <summary>Size of sectors contained in the image</summary>
|
||||
public uint SectorSize;
|
||||
/// <summary>Media tags contained by the image</summary>
|
||||
public List<MediaTagType> ReadableMediaTags;
|
||||
/// <summary>Sector tags contained by the image</summary>
|
||||
public List<SectorTagType> ReadableSectorTags;
|
||||
/// <summary>Image version</summary>
|
||||
public string Version;
|
||||
/// <summary>Application that created the image</summary>
|
||||
public string Application;
|
||||
/// <summary>Version of the application that created the image</summary>
|
||||
public string ApplicationVersion;
|
||||
/// <summary>Who (person) created the image?</summary>
|
||||
public string Creator;
|
||||
/// <summary>Image creation time</summary>
|
||||
public DateTime CreationTime;
|
||||
/// <summary>Image last modification time</summary>
|
||||
public DateTime LastModificationTime;
|
||||
/// <summary>Title of the media represented by the image</summary>
|
||||
public string MediaTitle;
|
||||
/// <summary>Image comments</summary>
|
||||
public string Comments;
|
||||
/// <summary>Manufacturer of the media represented by the image</summary>
|
||||
public string MediaManufacturer;
|
||||
/// <summary>Model of the media represented by the image</summary>
|
||||
public string MediaModel;
|
||||
/// <summary>Serial number of the media represented by the image</summary>
|
||||
public string MediaSerialNumber;
|
||||
/// <summary>Barcode of the media represented by the image</summary>
|
||||
public string MediaBarcode;
|
||||
/// <summary>Part number of the media represented by the image</summary>
|
||||
public string MediaPartNumber;
|
||||
/// <summary>Media type represented by the image</summary>
|
||||
public MediaType MediaType;
|
||||
/// <summary>Number in sequence for the media represented by the image</summary>
|
||||
public int MediaSequence;
|
||||
/// <summary>Last media of the sequence the media represented by the image corresponds to</summary>
|
||||
public int LastMediaSequence;
|
||||
/// <summary>Manufacturer of the drive used to read the media represented by the image</summary>
|
||||
public string DriveManufacturer;
|
||||
/// <summary>Model of the drive used to read the media represented by the image</summary>
|
||||
public string DriveModel;
|
||||
/// <summary>Serial number of the drive used to read the media represented by the image</summary>
|
||||
public string DriveSerialNumber;
|
||||
/// <summary>Firmware revision of the drive used to read the media represented by the image</summary>
|
||||
public string DriveFirmwareRevision;
|
||||
/// <summary>Type of the media represented by the image to use in XML sidecars</summary>
|
||||
public XmlMediaType XmlMediaType;
|
||||
|
||||
// CHS geometry...
|
||||
/// <summary>Cylinders of the media represented by the image</summary>
|
||||
public uint Cylinders;
|
||||
/// <summary>Heads of the media represented by the image</summary>
|
||||
public uint Heads;
|
||||
/// <summary>Sectors per track of the media represented by the image (for variable image, the smallest)</summary>
|
||||
public uint SectorsPerTrack;
|
||||
}
|
||||
|
||||
/// <summary>Session defining structure.</summary>
|
||||
public struct Session
|
||||
{
|
||||
/// <summary>Session number, 1-started</summary>
|
||||
public ushort Sequence;
|
||||
/// <summary>First track present on this session</summary>
|
||||
public uint StartTrack;
|
||||
/// <summary>Last track present on this session</summary>
|
||||
public uint EndTrack;
|
||||
/// <summary>First sector present on this session</summary>
|
||||
public ulong StartSector;
|
||||
/// <summary>Last sector present on this session</summary>
|
||||
public ulong EndSector;
|
||||
}
|
||||
|
||||
/// <summary>Track defining structure.</summary>
|
||||
public class Track
|
||||
{
|
||||
/// <summary>How many main channel / user data bytes are per sector in this track</summary>
|
||||
public int BytesPerSector;
|
||||
/// <summary>Information that does not find space in this struct</summary>
|
||||
public string Description;
|
||||
/// <summary>Track ending sector</summary>
|
||||
public ulong EndSector;
|
||||
/// <summary>Which file stores this track</summary>
|
||||
public string File;
|
||||
/// <summary>Starting at which byte is this track stored</summary>
|
||||
public ulong FileOffset;
|
||||
/// <summary>What kind of file is storing this track</summary>
|
||||
public string FileType;
|
||||
/// <summary>Which filter stores this track</summary>
|
||||
public IFilter Filter;
|
||||
/// <summary>Indexes, 00 to 99 and sector offset</summary>
|
||||
public Dictionary<ushort, int> Indexes;
|
||||
/// <summary>Track pre-gap</summary>
|
||||
public ulong Pregap;
|
||||
/// <summary>How many main channel bytes per sector are in the file with this track</summary>
|
||||
public int RawBytesPerSector;
|
||||
/// <summary>Track number, 1-started</summary>
|
||||
public uint Sequence;
|
||||
/// <summary>Session this track belongs to</summary>
|
||||
public ushort Session;
|
||||
/// <summary>Track starting sector</summary>
|
||||
public ulong StartSector;
|
||||
/// <summary>Which file stores this track's subchannel</summary>
|
||||
public string SubchannelFile;
|
||||
/// <summary>Which filter stores this track's subchannel</summary>
|
||||
public IFilter SubchannelFilter;
|
||||
/// <summary>Starting at which byte are this track's subchannel stored</summary>
|
||||
public ulong SubchannelOffset;
|
||||
/// <summary>Type of subchannel stored for this track</summary>
|
||||
public TrackSubchannelType SubchannelType;
|
||||
/// <summary>Partition type</summary>
|
||||
public TrackType Type;
|
||||
|
||||
/// <summary>Initializes an empty instance of this structure</summary>
|
||||
public Track() => Indexes = new Dictionary<ushort, int>();
|
||||
}
|
||||
|
||||
/// <summary>Floppy physical characteristics structure.</summary>
|
||||
public struct FloppyInfo
|
||||
{
|
||||
/// <summary>Physical floppy type.</summary>
|
||||
public FloppyTypes Type;
|
||||
/// <summary>Bitrate in bits per second used to write the floppy, 0 if unknown or track-variable.</summary>
|
||||
public uint Bitrate;
|
||||
/// <summary>Physical magnetic density (coercivity) of floppy medium.</summary>
|
||||
public FloppyDensities Coercivity;
|
||||
/// <summary>How many physical tracks are actually written in the floppy image.</summary>
|
||||
public ushort Tracks;
|
||||
/// <summary>How many physical heads are actually written in the floppy image.</summary>
|
||||
public byte Heads;
|
||||
/// <summary>How many tracks per inch are actually written in the floppy image.</summary>
|
||||
public ushort TrackDensity;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : TapeFile.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines a structure to hold information about a tape file object.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.CommonTypes.Structs
|
||||
{
|
||||
/// <summary>Describes a tape file</summary>
|
||||
public struct TapeFile
|
||||
{
|
||||
/// <summary>File number</summary>
|
||||
public uint File;
|
||||
/// <summary>Partition number</summary>
|
||||
public byte Partition;
|
||||
/// <summary>First block, inclusive, of the file</summary>
|
||||
public ulong FirstBlock;
|
||||
/// <summary>Last block, inclusive, of the file</summary>
|
||||
public ulong LastBlock;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : TapeFile.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines a structure to hold information about a tape partition.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.CommonTypes.Structs
|
||||
{
|
||||
/// <summary>Describes a tape partition</summary>
|
||||
public struct TapePartition
|
||||
{
|
||||
/// <summary>Partition number</summary>
|
||||
public byte Number;
|
||||
/// <summary>First block, inclusive, of the partition</summary>
|
||||
public ulong FirstBlock;
|
||||
/// <summary>Last block, inclusive, of the partition</summary>
|
||||
public ulong LastBlock;
|
||||
}
|
||||
}
|
||||
@@ -1,632 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
next_line = crlf
|
||||
insert_final_newline = false
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
# Generic non-language specific ones for Resharper and friends
|
||||
brace_style = next_line
|
||||
int_align = true
|
||||
keep_existing_arrangement = false
|
||||
place_simple_blocks_on_single_line = true
|
||||
place_simple_declaration_blocks_on_single_line = true
|
||||
place_attribute_on_same_line = false
|
||||
space_after_unary_operator = false
|
||||
space_after_comma = true
|
||||
space_around_ternary_operator = true
|
||||
space_around_binary_operator = true
|
||||
space_around_member_access_operator = false
|
||||
space_before_open_square_brackets = false
|
||||
space_after_keywords_in_control_flow_statements = true
|
||||
space_before_comma = false
|
||||
space_between_method_call_name_and_opening_parenthesis = false
|
||||
space_between_method_declaration_name_and_open_parenthesis = false
|
||||
space_between_square_brackets = false
|
||||
space_between_parentheses_of_control_flow_statements = false
|
||||
accessor_owner_declaration_braces = next_line
|
||||
accessor_declaration_braces = next_line
|
||||
case_block_braces = next_line
|
||||
initializer_braces = next_line
|
||||
other_braces = next_line
|
||||
allow_comment_after_lbrace = false
|
||||
empty_block_style = together_same_line
|
||||
braces_for_ifelse = not_required
|
||||
braces_for_for = not_required
|
||||
braces_for_foreach = not_required
|
||||
braces_for_while = not_required
|
||||
braces_for_dowhile = not_required
|
||||
braces_for_using = not_required
|
||||
braces_for_lock = not_required
|
||||
braces_for_fixed = not_required
|
||||
method_or_operator_body = expression_body
|
||||
local_function_body = expression_body
|
||||
constructor_or_destructor_body = expression_body
|
||||
accessor_owner_body = expression_body
|
||||
force_attribute_style = join
|
||||
function_braces = next_line
|
||||
force_control_statements_braces = always_remove
|
||||
space_in_singleline_accessorholder = true
|
||||
type_declaration_braces = next_line
|
||||
invocable_declaration_braces = next_line
|
||||
anonymous_method_declaration_braces = next_line
|
||||
space_between_accessors_in_singleline_property = true
|
||||
indent_nested_usings_stmt = true
|
||||
space_within_empty_braces = false
|
||||
indent_nested_fixed_stmt = true
|
||||
indent_nested_lock_stmt = true
|
||||
indent_nested_for_stmt = true
|
||||
indent_nested_foreach_stmt = true
|
||||
indent_nested_while_stmt = true
|
||||
use_continuous_indent_inside_parens = true
|
||||
indent_method_decl_pars = inside
|
||||
indent_invocation_pars = inside
|
||||
indent_statement_pars = inside
|
||||
indent_typeparam_angles = inside
|
||||
indent_typearg_angles = inside
|
||||
indent_pars = inside
|
||||
indent_preprocessor_if = outdent
|
||||
indent_preprocessor_region = usual_indent
|
||||
indent_preprocessor_other = usual_indent
|
||||
indent_switch_labels = true
|
||||
indent_type_constraints = true
|
||||
stick_comment = false
|
||||
alignment_tab_fill_style = use_spaces
|
||||
align_multiline_parameter = true
|
||||
align_multiline_extends_list = true
|
||||
align_linq_query = true
|
||||
align_multiline_binary_expressions_chain = true
|
||||
outdent_binary_ops = true
|
||||
align_multiline_calls_chain = true
|
||||
outdent_dots = true
|
||||
align_multiline_array_and_object_initializer = false
|
||||
indent_anonymous_method_block = false
|
||||
align_first_arg_by_paren = true
|
||||
align_multiline_argument = true
|
||||
align_tuple_components = true
|
||||
align_multiline_expression = true
|
||||
align_multiline_for_stmt = true
|
||||
align_multiple_declaration = true
|
||||
align_multline_type_parameter_list = true
|
||||
align_multline_type_parameter_constrains = true
|
||||
int_align_fields = true
|
||||
int_align_properties = true
|
||||
int_align_methods = true
|
||||
int_align_parameters = false
|
||||
int_align_variables = true
|
||||
int_align_assignments = true
|
||||
int_align_nested_ternary = true
|
||||
int_align_invocations = false
|
||||
int_align_binary_expressions = true
|
||||
int_align_comments = true
|
||||
int_align_switch_sections = true
|
||||
keep_user_linebreaks = false
|
||||
keep_existing_arrangement = false
|
||||
keep_existing_linebreaks = false
|
||||
max_line_length = 120
|
||||
wrap_before_comma = false
|
||||
special_else_if_treatment = true
|
||||
place_type_attribute_on_same_line = never
|
||||
place_method_attribute_on_same_line = never
|
||||
place_accessorholder_attribute_on_same_line = never
|
||||
place_attribute_on_same_line = never
|
||||
place_accessor_attribute_on_same_line = never
|
||||
place_attribute_on_same_line = never
|
||||
place_field_attribute_on_same_line = never
|
||||
place_attribute_on_same_line = never
|
||||
wrap_parameters_style = wrap_if_long
|
||||
keep_existing_declaration_parens_arrangement = false
|
||||
wrap_before_declaration_lpar = false
|
||||
wrap_after_declaration_lpar = false
|
||||
wrap_before_declaration_rpar = false
|
||||
place_constructor_initializer_on_same_line = true
|
||||
keep_existing_expr_member_arrangement = false
|
||||
place_expr_method_on_single_line = true
|
||||
place_expr_property_on_single_line = true
|
||||
place_expr_accessor_on_single_line = true
|
||||
wrap_before_arrow_with_expressions = false
|
||||
place_type_constraints_on_same_line = true
|
||||
wrap_before_first_type_parameter_constraint = true
|
||||
wrap_multiple_type_parameter_constraints_style = wrap_if_long
|
||||
wrap_before_type_parameter_langle = true
|
||||
wrap_before_extends_colon = false
|
||||
wrap_extends_list_style = wrap_if_long
|
||||
keep_existing_declaration_block_arrangement = false
|
||||
place_abstract_accessorholder_on_single_line = true
|
||||
place_simple_accessorholder_on_single_line = false
|
||||
place_accessor_with_attrs_holder_on_single_line = false
|
||||
place_simple_accessor_on_single_line = true
|
||||
place_simple_method_on_single_line = false
|
||||
keep_existing_enum_arrangement = false
|
||||
place_simple_enum_on_single_line = false
|
||||
wrap_enum_declaration = wrap_if_long
|
||||
new_line_before_else = true
|
||||
new_line_before_while = false
|
||||
wrap_for_stmt_header_style = wrap_if_long
|
||||
wrap_multiple_declaration_style = wrap_if_long
|
||||
keep_existing_embedded_arrangement = false
|
||||
place_simple_embedded_statement_on_same_line = false
|
||||
place_simple_case_statement_on_same_line = true
|
||||
keep_existing_embedded_block_arrangement = false
|
||||
place_simple_embedded_block_on_same_line = false
|
||||
place_simple_anonymousmethod_on_single_line = false
|
||||
keep_existing_initializer_arrangement = false
|
||||
place_simple_initializer_on_single_line = false
|
||||
wrap_object_and_collection_initializer_style = chop_always
|
||||
wrap_array_initializer_style = wrap_if_long
|
||||
wrap_arguments_style = wrap_if_long
|
||||
keep_existing_invocation_parens_arrangement = false
|
||||
wrap_after_invocation_lpar = false
|
||||
wrap_before_invocation_rpar = false
|
||||
wrap_after_dot_in_method_calls = true
|
||||
wrap_chained_method_calls = wrap_if_long
|
||||
wrap_before_binary_opsign = false
|
||||
wrap_chained_binary_expressions = wrap_if_long
|
||||
force_chop_compound_if_expression = true
|
||||
force_chop_compound_while_expression = true
|
||||
force_chop_compound_do_expression = true
|
||||
wrap_before_ternary_opsigns = true
|
||||
wrap_ternary_expr_style = wrap_if_long
|
||||
nested_ternary_style = expanded
|
||||
wrap_linq_expressions = wrap_if_long
|
||||
wrap_before_linq_expression = false
|
||||
place_linq_into_on_new_line = false
|
||||
wrap_verbatim_interpolated_strings = wrap_if_long
|
||||
extra_spaces = remove_all
|
||||
space_after_keywords_in_control_flow_statements = false
|
||||
space_between_method_call_name_and_opening_parenthesis = false
|
||||
space_between_method_declaration_name_and_open_parenthesis = false
|
||||
space_before_typeof_parentheses = false
|
||||
space_before_checked_parentheses = false
|
||||
space_before_sizeof_parentheses = false
|
||||
space_before_nameof_parentheses = false
|
||||
space_between_keyword_and_expression = true
|
||||
space_between_keyword_and_type = true
|
||||
space_around_assignment_op = true
|
||||
space_around_logical_op = true
|
||||
space_around_binary_operator = true
|
||||
space_around_equality_op = true
|
||||
space_around_relational_op = true
|
||||
space_around_bitwise_op = true
|
||||
space_around_additive_op = true
|
||||
space_around_multiplicative_op = true
|
||||
space_around_shift_op = true
|
||||
space_around_nullcoalescing_op = true
|
||||
space_around_arrow_op = false
|
||||
space_after_logical_not_op = false
|
||||
space_after_unary_operator = false
|
||||
space_after_cast = false
|
||||
space_around_dot = false
|
||||
space_around_lambda_arrow = true
|
||||
space_before_pointer_asterik_declaration = false
|
||||
space_before_nullable_mark = false
|
||||
blank_lines_around_class_definition = 1
|
||||
namespace_indentation = all
|
||||
space_within_template_argument = false
|
||||
align_union_type_usage = true
|
||||
space_in_singleline_method = true
|
||||
space_in_singleline_anonymous_method = true
|
||||
space_within_single_line_array_initializer_braces = true
|
||||
space_around_arrow_op = false
|
||||
|
||||
# These are for markup languages (HTML, XML, etc)
|
||||
spaces_around_eq_in_pi_attribute = false
|
||||
space_after_last_pi_attribute = true
|
||||
pi_attributes_indent = align_by_first_attribute
|
||||
blank_line_after_pi = true
|
||||
spaces_around_eq_in_attribute = false
|
||||
space_after_last_attribute = false
|
||||
space_before_self_closing = true
|
||||
attribute_style = on_single_line
|
||||
attribute_indent = align_by_first_attribute
|
||||
sort_attributes = true
|
||||
sort_class_selectors = true
|
||||
max_blank_lines_between_tags = 0
|
||||
linebreak_before_all_elements = true
|
||||
linebreak_before_multiline_elements = true
|
||||
quote_style = doublequoted
|
||||
delete_quotes_from_solid_values = false
|
||||
normalize_tag_names = true
|
||||
|
||||
|
||||
[{.babelrc,.stylelintrc,jest.config,.eslintrc,.prettierrc,*.json,*.jsb3,*.jsb2,*.bowerrc}]
|
||||
indent_size = 2
|
||||
|
||||
[*.js.map]
|
||||
indent_size = 2
|
||||
|
||||
[*.{css,scss}]
|
||||
indent_size = 2
|
||||
declarations_style = separate_lines_for_nonsingle
|
||||
media_query_style = separate_lines
|
||||
selector_style = same_line
|
||||
properties_style = separate_lines_for_nonsingle
|
||||
brace_style = next_line
|
||||
|
||||
[{.analysis_options,*.yml,*.yaml}]
|
||||
indent_size = 2
|
||||
|
||||
# Xml project files
|
||||
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
|
||||
indent_size = 2
|
||||
|
||||
# Xml files
|
||||
[*.{xml,stylecop,resx,ruleset}]
|
||||
indent_size = 2
|
||||
|
||||
# Xml config files
|
||||
[*.{props,targets,config,nuspec}]
|
||||
indent_size = 2
|
||||
|
||||
# .net files
|
||||
[*.{cs,vb}]
|
||||
# These set the this. / Me.
|
||||
dotnet_style_qualification_for_field = false:warning
|
||||
dotnet_style_qualification_for_property = false:warning
|
||||
dotnet_style_qualification_for_method = false:warning
|
||||
dotnet_style_qualification_for_event = false:warning
|
||||
|
||||
# These make it suggest Int32 instead of int, etc.
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
|
||||
dotnet_style_predefined_type_for_member_access = true:suggestion
|
||||
|
||||
# This controls implicit access modifiers
|
||||
dotnet_style_require_accessibility_modifiers = never:suggestion
|
||||
|
||||
# Prefer non modified fields to be marked readonly
|
||||
dotnet_style_readonly_field = true:warning
|
||||
|
||||
# Parenthesis settings
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_other_operators = always_for_clarity:warning
|
||||
|
||||
dotnet_style_object_initializer = true:suggestion
|
||||
dotnet_style_collection_initializer = true:suggestion
|
||||
dotnet_style_explicit_tuple_names = true:error
|
||||
dotnet_style_prefer_inferred_tuple_names = true:warning
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
|
||||
dotnet_style_prefer_conditional_expression_over_return = true:warning
|
||||
dotnet_style_coalesce_expression = true:warning
|
||||
dotnet_style_null_propagation = true:error
|
||||
|
||||
dotnet_sort_system_directives_first = true
|
||||
|
||||
# Constants in C style, all-caps
|
||||
dotnet_naming_rule.constant_fields_caps.symbols = constant_fields
|
||||
dotnet_naming_rule.constant_fields_caps.severity = warning
|
||||
dotnet_naming_rule.constant_fields_caps.style = caps_style
|
||||
dotnet_naming_symbols.constant_fields.applicable_kinds = field
|
||||
dotnet_naming_symbols.constant_fields.required_modifiers = const
|
||||
dotnet_naming_style.caps_style.capitalization = all_upper
|
||||
|
||||
# interfaces should be prefixed with I
|
||||
dotnet_naming_rule.pascal_case_for_interface.severity = error
|
||||
dotnet_naming_rule.pascal_case_for_interface.symbols = interfaces_fields
|
||||
dotnet_naming_rule.pascal_case_for_interface.style = pascal_case_interface_style
|
||||
dotnet_naming_symbols.interfaces_fields.applicable_kinds = interface
|
||||
dotnet_naming_style.pascal_case_interface_style.required_prefix = I
|
||||
dotnet_naming_style.pascal_case_interface_style.capitalization = pascal_case
|
||||
|
||||
## internal and private fields should be _camelCase
|
||||
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = warning
|
||||
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
|
||||
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
|
||||
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
|
||||
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
|
||||
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
|
||||
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
|
||||
|
||||
# 2018-12-07 NP: This is not yet working in VS2017
|
||||
# local variables should be camelCase
|
||||
#dotnet_naming_rule.camel_case_for_locals.severity = suggestion
|
||||
#dotnet_naming_rule.camel_case_for_locals.symbols = local_fields
|
||||
#dotnet_naming_rule.camel_case_for_locals.style = camel_case_style
|
||||
#dotnet_naming_symbols.local_fields.applicable_kinds = local
|
||||
#dotnet_naming_style.camel_case_style.capitalization = camel_case
|
||||
|
||||
[*.cs]
|
||||
# var var var
|
||||
csharp_style_var_for_built_in_types = false:warning
|
||||
csharp_style_var_when_type_is_apparent = true:suggestion
|
||||
csharp_style_var_elsewhere = false:warning
|
||||
|
||||
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_constructors = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_operators = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_properties = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_indexers = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_accessors = when_on_single_line:suggestion
|
||||
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
|
||||
csharp_style_pattern_matching_over_as_with_null_check = when_on_single_line:warning
|
||||
|
||||
csharp_style_inlined_variable_declaration = true:warning
|
||||
|
||||
csharp_prefer_simple_default_expression = true:warning
|
||||
csharp_style_deconstructed_variable_declaration = false:warning
|
||||
|
||||
csharp_style_throw_expression = true:warning
|
||||
csharp_style_conditional_delegate_call = true:warning
|
||||
|
||||
csharp_prefer_braces = false
|
||||
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_indent_labels = flush_left
|
||||
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = none
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
|
||||
csharp_preserve_single_line_statements = false
|
||||
csharp_preserve_single_line_blocks = true
|
||||
|
||||
csharp_blank_lines_around_region = 0
|
||||
csharp_blank_lines_inside_region = 0
|
||||
csharp_blank_lines_before_single_line_comment = 1
|
||||
csharp_keep_blank_lines_in_declarations = 1
|
||||
csharp_remove_blank_lines_near_braces_in_declarations = true
|
||||
csharp_blank_lines_after_start_comment = false
|
||||
csharp_blank_lines_between_using_groups = 0
|
||||
csharp_blank_lines_after_using_list = 1
|
||||
csharp_blank_lines_around_namespace = 1
|
||||
csharp_blank_lines_inside_namespace = 0
|
||||
csharp_blank_lines_around_type = 1
|
||||
csharp_blank_lines_inside_type = 0
|
||||
csharp_blank_lines_around_field = 0
|
||||
csharp_blank_lines_around_single_line_field = 0
|
||||
csharp_blank_lines_around_property = 1
|
||||
csharp_blank_lines_around_single_line_property = 0
|
||||
csharp_blank_lines_around_auto_property = 0
|
||||
csharp_blank_lines_around_single_line_auto_property = 0
|
||||
csharp_blank_lines_around_invocable = 1
|
||||
csharp_blank_lines_around_single_line_invocable = 1
|
||||
csharp_keep_blank_lines_in_code = 1
|
||||
csharp_remove_blank_lines_near_braces_in_code = true
|
||||
csharp_blank_lines_around_local_method = 1
|
||||
csharp_blank_lines_around_single_line_local_method = 1
|
||||
csharp_blank_lines_before_control_transfer_statements = 1
|
||||
csharp_blank_lines_after_control_transfer_statements = 1
|
||||
csharp_blank_lines_before_block_statements = 1
|
||||
csharp_blank_lines_after_block_statements = 1
|
||||
csharp_blank_lines_before_multiline_statements = 1
|
||||
csharp_blank_lines_after_multiline_statements = 1
|
||||
|
||||
csharp_type_declaration_braces = next_line
|
||||
csharp_brace_style = next_line
|
||||
csharp_indent_inside_namespace = true
|
||||
csharp_invocable_declaration_braces = next_line
|
||||
csharp_anonymous_method_declaration_braces = next_line
|
||||
csharp_accessor_owner_declaration_braces = next_line
|
||||
csharp_accessor_declaration_braces = next_line
|
||||
csharp_case_block_braces = next_line
|
||||
csharp_initializer_braces = next_line
|
||||
csharp_other_braces = next_line
|
||||
csharp_allow_comment_after_lbrace = false
|
||||
csharp_empty_block_style = together_same_line
|
||||
|
||||
csharp_for_built_in_types = use_explicit_type
|
||||
csharp_for_simple_types = use_var_when_evident
|
||||
csharp_for_other_types = use_explicit_type
|
||||
csharp_prefer_separate_deconstructed_variables_declaration = true
|
||||
csharp_prefer_explicit_discard_declaration = false
|
||||
|
||||
csharp_instance_members_qualify_members = none
|
||||
csharp_builtin_type_reference_style = use_keyword
|
||||
csharp_prefer_qualified_reference = false
|
||||
csharp_add_imports_to_deepest_scope = false
|
||||
csharp_allow_alias = true
|
||||
csharp_default_private_modifier = implicit
|
||||
csharp_default_internal_modifier = explicit
|
||||
csharp_arguments_literal = positional
|
||||
csharp_arguments_string_literal = positional
|
||||
csharp_arguments_named = positional
|
||||
csharp_arguments_anonymous_function = positional
|
||||
csharp_arguments_other = positional
|
||||
csharp_braces_for_ifelse = not_required
|
||||
csharp_braces_for_for = not_required
|
||||
csharp_braces_for_foreach = not_required
|
||||
csharp_braces_for_while = not_required
|
||||
csharp_braces_for_dowhile = not_required
|
||||
csharp_braces_for_using = not_required
|
||||
csharp_braces_for_lock = not_required
|
||||
csharp_braces_for_fixed = not_required
|
||||
csharp_method_or_operator_body = expression_body
|
||||
csharp_local_function_body = expression_body
|
||||
csharp_constructor_or_destructor_body = expression_body
|
||||
csharp_accessor_owner_body = expression_body
|
||||
csharp_force_attribute_style = join
|
||||
csharp_indent_nested_usings_stmt = true
|
||||
|
||||
csharp_builtin_type_reference_for_member_access_style = use_keyword
|
||||
csharp_indent_nested_fixed_stmt = true
|
||||
csharp_indent_nested_lock_stmt = true
|
||||
csharp_indent_nested_for_stmt = true
|
||||
csharp_indent_nested_foreach_stmt = true
|
||||
csharp_indent_nested_while_stmt = true
|
||||
csharp_use_continuous_indent_inside_parens = true
|
||||
csharp_indent_method_decl_pars = inside
|
||||
csharp_indent_invocation_pars = inside
|
||||
csharp_indent_statement_pars = inside
|
||||
csharp_indent_typeparam_angles = inside
|
||||
csharp_indent_typearg_angles = inside
|
||||
csharp_indent_pars = inside
|
||||
csharp_indent_preprocessor_if = outdent
|
||||
csharp_indent_preprocessor_region = usual_indent
|
||||
csharp_indent_preprocessor_other = usual_indent
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_indent_type_constraints = true
|
||||
csharp_stick_comment = false
|
||||
csharp_alignment_tab_fill_style = use_spaces
|
||||
csharp_align_multiline_parameter = true
|
||||
csharp_align_multiline_extends_list = true
|
||||
csharp_align_linq_query = true
|
||||
csharp_align_multiline_binary_expressions_chain = true
|
||||
csharp_outdent_binary_ops = true
|
||||
csharp_align_multiline_calls_chain = true
|
||||
csharp_outdent_dots = true
|
||||
csharp_align_multiline_array_and_object_initializer = false
|
||||
csharp_indent_anonymous_method_block = false
|
||||
csharp_align_first_arg_by_paren = true
|
||||
csharp_align_multiline_argument = true
|
||||
csharp_align_tuple_components = true
|
||||
csharp_align_multiline_expression = true
|
||||
csharp_align_multiline_for_stmt = true
|
||||
csharp_align_multiple_declaration = true
|
||||
csharp_align_multline_type_parameter_list = true
|
||||
csharp_align_multline_type_parameter_constrains = true
|
||||
csharp_int_align_fields = true
|
||||
csharp_int_align_properties = true
|
||||
csharp_int_align_methods = true
|
||||
csharp_int_align_parameters = false
|
||||
csharp_int_align_variables = true
|
||||
csharp_int_align_assignments = true
|
||||
csharp_int_align_nested_ternary = true
|
||||
csharp_int_align_invocations = false
|
||||
csharp_int_align_binary_expressions = true
|
||||
csharp_int_align_comments = true
|
||||
csharp_int_align_switch_sections = true
|
||||
csharp_int_align = true
|
||||
csharp_keep_user_linebreaks = false
|
||||
csharp_keep_existing_arrangement = false
|
||||
csharp_keep_existing_linebreaks = false
|
||||
csharp_max_line_length = 120
|
||||
csharp_wrap_before_comma = false
|
||||
csharp_special_else_if_treatment = true
|
||||
csharp_insert_final_newline = false
|
||||
csharp_place_type_attribute_on_same_line = never
|
||||
csharp_place_method_attribute_on_same_line = never
|
||||
csharp_place_accessorholder_attribute_on_same_line = never
|
||||
csharp_place_attribute_on_same_line = never
|
||||
csharp_place_accessor_attribute_on_same_line = never
|
||||
csharp_place_attribute_on_same_line = never
|
||||
csharp_place_field_attribute_on_same_line = never
|
||||
csharp_place_attribute_on_same_line = never
|
||||
csharp_wrap_parameters_style = wrap_if_long
|
||||
csharp_keep_existing_declaration_parens_arrangement = false
|
||||
csharp_wrap_before_declaration_lpar = false
|
||||
csharp_wrap_after_declaration_lpar = false
|
||||
csharp_wrap_before_declaration_rpar = false
|
||||
csharp_place_constructor_initializer_on_same_line = true
|
||||
csharp_keep_existing_expr_member_arrangement = false
|
||||
csharp_place_expr_method_on_single_line = true
|
||||
csharp_place_expr_property_on_single_line = true
|
||||
csharp_place_expr_accessor_on_single_line = true
|
||||
csharp_wrap_before_arrow_with_expressions = false
|
||||
csharp_place_type_constraints_on_same_line = true
|
||||
csharp_wrap_before_first_type_parameter_constraint = true
|
||||
csharp_wrap_multiple_type_parameter_constraints_style = wrap_if_long
|
||||
csharp_wrap_before_type_parameter_langle = true
|
||||
csharp_wrap_before_extends_colon = false
|
||||
csharp_wrap_extends_list_style = wrap_if_long
|
||||
csharp_keep_existing_declaration_block_arrangement = false
|
||||
csharp_place_abstract_accessorholder_on_single_line = true
|
||||
csharp_place_simple_accessorholder_on_single_line = false
|
||||
csharp_place_accessor_with_attrs_holder_on_single_line = false
|
||||
csharp_place_simple_accessor_on_single_line = true
|
||||
csharp_place_simple_method_on_single_line = false
|
||||
csharp_keep_existing_enum_arrangement = false
|
||||
csharp_place_simple_enum_on_single_line = false
|
||||
csharp_wrap_enum_declaration = wrap_if_long
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_while = false
|
||||
csharp_wrap_for_stmt_header_style = wrap_if_long
|
||||
csharp_wrap_multiple_declaration_style = wrap_if_long
|
||||
csharp_keep_existing_embedded_arrangement = false
|
||||
csharp_place_simple_embedded_statement_on_same_line = false
|
||||
csharp_place_simple_case_statement_on_same_line = true
|
||||
csharp_keep_existing_embedded_block_arrangement = false
|
||||
csharp_place_simple_embedded_block_on_same_line = false
|
||||
csharp_place_simple_anonymousmethod_on_single_line = false
|
||||
csharp_keep_existing_initializer_arrangement = false
|
||||
csharp_place_simple_initializer_on_single_line = false
|
||||
csharp_wrap_object_and_collection_initializer_style = chop_always
|
||||
csharp_wrap_array_initializer_style = wrap_if_long
|
||||
csharp_wrap_arguments_style = wrap_if_long
|
||||
csharp_keep_existing_invocation_parens_arrangement = false
|
||||
csharp_wrap_after_invocation_lpar = false
|
||||
csharp_wrap_before_invocation_rpar = false
|
||||
csharp_wrap_after_dot_in_method_calls = true
|
||||
csharp_wrap_chained_method_calls = wrap_if_long
|
||||
csharp_wrap_before_binary_opsign = false
|
||||
csharp_wrap_chained_binary_expressions = wrap_if_long
|
||||
csharp_force_chop_compound_if_expression = true
|
||||
csharp_force_chop_compound_while_expression = true
|
||||
csharp_force_chop_compound_do_expression = true
|
||||
csharp_wrap_before_ternary_opsigns = true
|
||||
csharp_wrap_ternary_expr_style = wrap_if_long
|
||||
csharp_nested_ternary_style = expanded
|
||||
csharp_wrap_linq_expressions = wrap_if_long
|
||||
csharp_wrap_before_linq_expression = false
|
||||
csharp_place_linq_into_on_new_line = false
|
||||
csharp_wrap_verbatim_interpolated_strings = wrap_if_long
|
||||
csharp_extra_spaces = remove_all
|
||||
csharp_space_after_keywords_in_control_flow_statements = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||
csharp_space_before_typeof_parentheses = false
|
||||
csharp_space_before_checked_parentheses = false
|
||||
csharp_space_before_sizeof_parentheses = false
|
||||
csharp_space_before_nameof_parentheses = false
|
||||
csharp_space_between_keyword_and_expression = true
|
||||
csharp_space_between_keyword_and_type = true
|
||||
csharp_space_around_assignment_op = true
|
||||
csharp_space_around_logical_op = true
|
||||
csharp_space_around_binary_operator = true
|
||||
csharp_space_around_equality_op = true
|
||||
csharp_space_around_relational_op = true
|
||||
csharp_space_around_bitwise_op = true
|
||||
csharp_space_around_additive_op = true
|
||||
csharp_space_around_multiplicative_op = true
|
||||
csharp_space_around_shift_op = true
|
||||
csharp_space_around_nullcoalescing_op = true
|
||||
csharp_space_around_arrow_op = false
|
||||
csharp_space_after_logical_not_op = false
|
||||
csharp_space_after_unary_operator = false
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_around_dot = false
|
||||
csharp_space_around_lambda_arrow = true
|
||||
csharp_space_before_pointer_asterik_declaration = false
|
||||
csharp_space_before_nullable_mark = false
|
||||
|
||||
[*.cshtml]
|
||||
linebreaks_around_razor_statements = true
|
||||
blank_lines_around_razor_functions = true
|
||||
blank_lines_around_razor_helpers = true
|
||||
blank_lines_around_razor_sections = true
|
||||
|
||||
# C++
|
||||
[*.{cc,cpp,cxx,h,hpp,hxx}]
|
||||
cpp_indent_access_specifiers_from_class = true
|
||||
cpp_indent_wrapped_function_names = false
|
||||
cpp_align_multiline_type_argument = true
|
||||
|
||||
# C, C++ and ObjectiveC
|
||||
[*.{c,h,cc,cpp,cxx,m,hpp,hxx}]
|
||||
indent_preprocessor_directives = normal
|
||||
indent_type_constraints = true
|
||||
|
||||
# Javascript and Typescript
|
||||
[*.{js,js.map,ts}]
|
||||
quote_style = doublequoted
|
||||
termination_style = ensure_semicolon
|
||||
595
Aaru.Console/.gitignore
vendored
595
Aaru.Console/.gitignore
vendored
@@ -1,595 +0,0 @@
|
||||
### VisualStudio template
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
### Linux template
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
### Xcode template
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
## User settings
|
||||
xcuserdata/
|
||||
|
||||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
|
||||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
|
||||
build/
|
||||
DerivedData/
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
### VisualStudioCode template
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
### C++ template
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
### MonoDevelop template
|
||||
#User Specific
|
||||
*.usertasks
|
||||
|
||||
#Mono Project Files
|
||||
*.resources
|
||||
test-results/
|
||||
### GPG template
|
||||
secring.*
|
||||
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
### CMake template
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
### C template
|
||||
# Object files
|
||||
*.ko
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
*.so.*
|
||||
|
||||
# Executables
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
### Windows template
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# NuGet Packages Directory
|
||||
packages/
|
||||
## TODO: If the tool you use requires repositories.config uncomment the next line
|
||||
#!packages/repositories.config
|
||||
|
||||
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
|
||||
# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
|
||||
!packages/build/
|
||||
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
|
||||
# Visual Studio 2017
|
||||
.vs
|
||||
|
||||
workspace.xml
|
||||
cmake-build-debug
|
||||
### macOS template
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
pkg/**/pkg
|
||||
pkg/**/src
|
||||
pkg/**/*.asc
|
||||
pkg/**/*.sig
|
||||
pkg/**/*.tar.xz
|
||||
pkg/**/*.zip
|
||||
pkg/**/aaru
|
||||
|
||||
.sonarqube
|
||||
@@ -1,236 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : AaruConsole.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Console.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Handlers for normal, verbose and debug consoles.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, followed by the current line terminator, to
|
||||
/// the standard output console using the specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public delegate void WriteLineHandler(string format, params object[] arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, followed by the current line terminator, to
|
||||
/// the error output console using the specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public delegate void ErrorWriteLineHandler(string format, params object[] arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, followed by the current line terminator, to
|
||||
/// the verbose output console using the specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public delegate void VerboseWriteLineHandler(string format, params object[] arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, followed by the current line terminator, to
|
||||
/// the debug output console using the specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public delegate void DebugWriteLineHandler(string format, params object[] arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, to the standard output console using the
|
||||
/// specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public delegate void WriteHandler(string format, params object[] arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, to the error output console using the
|
||||
/// specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public delegate void ErrorWriteHandler(string format, params object[] arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, to the verbose output console using the
|
||||
/// specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public delegate void VerboseWriteHandler(string format, params object[] arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, to the debug output console using the
|
||||
/// specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public delegate void DebugWriteHandler(string format, params object[] arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, followed by the current line terminator, to
|
||||
/// the debug output console using the specified format information.
|
||||
/// </summary>
|
||||
/// <param name="module">Description of the module writing to the debug console</param>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public delegate void DebugWithModuleWriteLineHandler(string module, string format, params object[] arg);
|
||||
|
||||
/// <summary>
|
||||
/// Implements a console abstraction that defines four level of messages that can be routed to different consoles:
|
||||
/// standard, error, verbose and debug.
|
||||
/// </summary>
|
||||
public static class AaruConsole
|
||||
{
|
||||
/// <summary>Event to receive writings to the standard output console that should be followed by a line termination.</summary>
|
||||
public static event WriteLineHandler WriteLineEvent;
|
||||
/// <summary>Event to receive writings to the error output console that should be followed by a line termination.</summary>
|
||||
public static event ErrorWriteLineHandler ErrorWriteLineEvent;
|
||||
/// <summary>Event to receive writings to the verbose output console that should be followed by a line termination.</summary>
|
||||
public static event VerboseWriteLineHandler VerboseWriteLineEvent;
|
||||
/// <summary>Event to receive line terminations to the debug output console.</summary>
|
||||
public static event DebugWriteLineHandler DebugWriteLineEvent;
|
||||
/// <summary>Event to receive writings to the debug output console that should be followed by a line termination.</summary>
|
||||
public static event DebugWithModuleWriteLineHandler DebugWithModuleWriteLineEvent;
|
||||
/// <summary>Event to receive writings to the standard output console.</summary>
|
||||
public static event WriteHandler WriteEvent;
|
||||
/// <summary>Event to receive writings to the error output console.</summary>
|
||||
public static event ErrorWriteHandler ErrorWriteEvent;
|
||||
/// <summary>Event to receive writings to the verbose output console.</summary>
|
||||
public static event VerboseWriteHandler VerboseWriteEvent;
|
||||
/// <summary>Event to receive writings to the debug output console.</summary>
|
||||
public static event DebugWriteHandler DebugWriteEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, followed by the current line terminator, to
|
||||
/// the standard output console using the specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public static void WriteLine(string format, params object[] arg) => WriteLineEvent?.Invoke(format, arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, followed by the current line terminator, to
|
||||
/// the error output console using the specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public static void ErrorWriteLine(string format, params object[] arg) =>
|
||||
ErrorWriteLineEvent?.Invoke(format, arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, followed by the current line terminator, to
|
||||
/// the verbose output console using the specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public static void VerboseWriteLine(string format, params object[] arg) =>
|
||||
VerboseWriteLineEvent?.Invoke(format, arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects, followed by the current line terminator, to
|
||||
/// the debug output console using the specified format information.
|
||||
/// </summary>
|
||||
/// <param name="module">Description of the module writing to the debug console</param>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public static void DebugWriteLine(string module, string format, params object[] arg)
|
||||
{
|
||||
DebugWriteLineEvent?.Invoke("DEBUG (" + module + "): " + format, arg);
|
||||
DebugWithModuleWriteLineEvent?.Invoke(module, format, arg);
|
||||
}
|
||||
|
||||
/// <summary>Writes the current line terminator to the standard output console.</summary>
|
||||
public static void WriteLine() => WriteLineEvent?.Invoke("", null);
|
||||
|
||||
/// <summary>Writes the current line terminator to the error output console.</summary>
|
||||
public static void ErrorWriteLine() => ErrorWriteLineEvent?.Invoke("", null);
|
||||
|
||||
/// <summary>Writes the current line terminator to the verbose output console.</summary>
|
||||
public static void VerboseWriteLine() => VerboseWriteLineEvent?.Invoke("", null);
|
||||
|
||||
/// <summary>Writes the current line terminator to the debug output console.</summary>
|
||||
public static void DebugWriteLine() => DebugWriteLineEvent?.Invoke("", null);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects to the standard output console using the
|
||||
/// specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public static void Write(string format, params object[] arg) => WriteEvent?.Invoke(format, arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects to the error output console using the
|
||||
/// specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public static void ErrorWrite(string format, params object[] arg) => ErrorWriteEvent?.Invoke(format, arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects to the verbose output console using the
|
||||
/// specified format information.
|
||||
/// </summary>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public static void VerboseWrite(string format, params object[] arg) => VerboseWriteEvent?.Invoke(format, arg);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text representation of the specified array of objects to the debug output console using the
|
||||
/// specified format information.
|
||||
/// </summary>
|
||||
/// <param name="module">Description of the module writing to the debug console</param>
|
||||
/// <param name="format">A composite format string.</param>
|
||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||
public static void DebugWrite(string module, string format, params object[] arg) =>
|
||||
DebugWriteEvent?.Invoke("DEBUG (" + module + "): " + format, arg);
|
||||
|
||||
/// <summary>Writes the specified string value, followed by the current line terminator, to the standard output console.</summary>
|
||||
/// <param name="value">The value to write.</param>
|
||||
public static void WriteLine(string value) => WriteLineEvent?.Invoke("{0}", value);
|
||||
|
||||
/// <summary>Writes the specified string value, followed by the current line terminator, to the error output console.</summary>
|
||||
/// <param name="value">The value to write.</param>
|
||||
public static void ErrorWriteLine(string value) => ErrorWriteLineEvent?.Invoke("{0}", value);
|
||||
|
||||
/// <summary>Writes the specified string value, followed by the current line terminator, to the verbose output console.</summary>
|
||||
/// <param name="value">The value to write.</param>
|
||||
public static void VerboseWriteLine(string value) => VerboseWriteLineEvent?.Invoke("{0}", value);
|
||||
|
||||
/// <summary>Writes the specified string value, followed by the current line terminator, to the debug output console.</summary>
|
||||
/// <param name="module">Description of the module writing to the debug console</param>
|
||||
/// <param name="value">The value to write.</param>
|
||||
public static void DebugWriteLine(string module, string value) =>
|
||||
DebugWriteLineEvent?.Invoke("{0}", "DEBUG (" + module + "): " + value);
|
||||
}
|
||||
}
|
||||
@@ -1,632 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
next_line = crlf
|
||||
insert_final_newline = false
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
# Generic non-language specific ones for Resharper and friends
|
||||
brace_style = next_line
|
||||
int_align = true
|
||||
keep_existing_arrangement = false
|
||||
place_simple_blocks_on_single_line = true
|
||||
place_simple_declaration_blocks_on_single_line = true
|
||||
place_attribute_on_same_line = false
|
||||
space_after_unary_operator = false
|
||||
space_after_comma = true
|
||||
space_around_ternary_operator = true
|
||||
space_around_binary_operator = true
|
||||
space_around_member_access_operator = false
|
||||
space_before_open_square_brackets = false
|
||||
space_after_keywords_in_control_flow_statements = true
|
||||
space_before_comma = false
|
||||
space_between_method_call_name_and_opening_parenthesis = false
|
||||
space_between_method_declaration_name_and_open_parenthesis = false
|
||||
space_between_square_brackets = false
|
||||
space_between_parentheses_of_control_flow_statements = false
|
||||
accessor_owner_declaration_braces = next_line
|
||||
accessor_declaration_braces = next_line
|
||||
case_block_braces = next_line
|
||||
initializer_braces = next_line
|
||||
other_braces = next_line
|
||||
allow_comment_after_lbrace = false
|
||||
empty_block_style = together_same_line
|
||||
braces_for_ifelse = not_required
|
||||
braces_for_for = not_required
|
||||
braces_for_foreach = not_required
|
||||
braces_for_while = not_required
|
||||
braces_for_dowhile = not_required
|
||||
braces_for_using = not_required
|
||||
braces_for_lock = not_required
|
||||
braces_for_fixed = not_required
|
||||
method_or_operator_body = expression_body
|
||||
local_function_body = expression_body
|
||||
constructor_or_destructor_body = expression_body
|
||||
accessor_owner_body = expression_body
|
||||
force_attribute_style = join
|
||||
function_braces = next_line
|
||||
force_control_statements_braces = always_remove
|
||||
space_in_singleline_accessorholder = true
|
||||
type_declaration_braces = next_line
|
||||
invocable_declaration_braces = next_line
|
||||
anonymous_method_declaration_braces = next_line
|
||||
space_between_accessors_in_singleline_property = true
|
||||
indent_nested_usings_stmt = true
|
||||
space_within_empty_braces = false
|
||||
indent_nested_fixed_stmt = true
|
||||
indent_nested_lock_stmt = true
|
||||
indent_nested_for_stmt = true
|
||||
indent_nested_foreach_stmt = true
|
||||
indent_nested_while_stmt = true
|
||||
use_continuous_indent_inside_parens = true
|
||||
indent_method_decl_pars = inside
|
||||
indent_invocation_pars = inside
|
||||
indent_statement_pars = inside
|
||||
indent_typeparam_angles = inside
|
||||
indent_typearg_angles = inside
|
||||
indent_pars = inside
|
||||
indent_preprocessor_if = outdent
|
||||
indent_preprocessor_region = usual_indent
|
||||
indent_preprocessor_other = usual_indent
|
||||
indent_switch_labels = true
|
||||
indent_type_constraints = true
|
||||
stick_comment = false
|
||||
alignment_tab_fill_style = use_spaces
|
||||
align_multiline_parameter = true
|
||||
align_multiline_extends_list = true
|
||||
align_linq_query = true
|
||||
align_multiline_binary_expressions_chain = true
|
||||
outdent_binary_ops = true
|
||||
align_multiline_calls_chain = true
|
||||
outdent_dots = true
|
||||
align_multiline_array_and_object_initializer = false
|
||||
indent_anonymous_method_block = false
|
||||
align_first_arg_by_paren = true
|
||||
align_multiline_argument = true
|
||||
align_tuple_components = true
|
||||
align_multiline_expression = true
|
||||
align_multiline_for_stmt = true
|
||||
align_multiple_declaration = true
|
||||
align_multline_type_parameter_list = true
|
||||
align_multline_type_parameter_constrains = true
|
||||
int_align_fields = true
|
||||
int_align_properties = true
|
||||
int_align_methods = true
|
||||
int_align_parameters = false
|
||||
int_align_variables = true
|
||||
int_align_assignments = true
|
||||
int_align_nested_ternary = true
|
||||
int_align_invocations = false
|
||||
int_align_binary_expressions = true
|
||||
int_align_comments = true
|
||||
int_align_switch_sections = true
|
||||
keep_user_linebreaks = false
|
||||
keep_existing_arrangement = false
|
||||
keep_existing_linebreaks = false
|
||||
max_line_length = 120
|
||||
wrap_before_comma = false
|
||||
special_else_if_treatment = true
|
||||
place_type_attribute_on_same_line = never
|
||||
place_method_attribute_on_same_line = never
|
||||
place_accessorholder_attribute_on_same_line = never
|
||||
place_attribute_on_same_line = never
|
||||
place_accessor_attribute_on_same_line = never
|
||||
place_attribute_on_same_line = never
|
||||
place_field_attribute_on_same_line = never
|
||||
place_attribute_on_same_line = never
|
||||
wrap_parameters_style = wrap_if_long
|
||||
keep_existing_declaration_parens_arrangement = false
|
||||
wrap_before_declaration_lpar = false
|
||||
wrap_after_declaration_lpar = false
|
||||
wrap_before_declaration_rpar = false
|
||||
place_constructor_initializer_on_same_line = true
|
||||
keep_existing_expr_member_arrangement = false
|
||||
place_expr_method_on_single_line = true
|
||||
place_expr_property_on_single_line = true
|
||||
place_expr_accessor_on_single_line = true
|
||||
wrap_before_arrow_with_expressions = false
|
||||
place_type_constraints_on_same_line = true
|
||||
wrap_before_first_type_parameter_constraint = true
|
||||
wrap_multiple_type_parameter_constraints_style = wrap_if_long
|
||||
wrap_before_type_parameter_langle = true
|
||||
wrap_before_extends_colon = false
|
||||
wrap_extends_list_style = wrap_if_long
|
||||
keep_existing_declaration_block_arrangement = false
|
||||
place_abstract_accessorholder_on_single_line = true
|
||||
place_simple_accessorholder_on_single_line = false
|
||||
place_accessor_with_attrs_holder_on_single_line = false
|
||||
place_simple_accessor_on_single_line = true
|
||||
place_simple_method_on_single_line = false
|
||||
keep_existing_enum_arrangement = false
|
||||
place_simple_enum_on_single_line = false
|
||||
wrap_enum_declaration = wrap_if_long
|
||||
new_line_before_else = true
|
||||
new_line_before_while = false
|
||||
wrap_for_stmt_header_style = wrap_if_long
|
||||
wrap_multiple_declaration_style = wrap_if_long
|
||||
keep_existing_embedded_arrangement = false
|
||||
place_simple_embedded_statement_on_same_line = false
|
||||
place_simple_case_statement_on_same_line = true
|
||||
keep_existing_embedded_block_arrangement = false
|
||||
place_simple_embedded_block_on_same_line = false
|
||||
place_simple_anonymousmethod_on_single_line = false
|
||||
keep_existing_initializer_arrangement = false
|
||||
place_simple_initializer_on_single_line = false
|
||||
wrap_object_and_collection_initializer_style = chop_always
|
||||
wrap_array_initializer_style = wrap_if_long
|
||||
wrap_arguments_style = wrap_if_long
|
||||
keep_existing_invocation_parens_arrangement = false
|
||||
wrap_after_invocation_lpar = false
|
||||
wrap_before_invocation_rpar = false
|
||||
wrap_after_dot_in_method_calls = true
|
||||
wrap_chained_method_calls = wrap_if_long
|
||||
wrap_before_binary_opsign = false
|
||||
wrap_chained_binary_expressions = wrap_if_long
|
||||
force_chop_compound_if_expression = true
|
||||
force_chop_compound_while_expression = true
|
||||
force_chop_compound_do_expression = true
|
||||
wrap_before_ternary_opsigns = true
|
||||
wrap_ternary_expr_style = wrap_if_long
|
||||
nested_ternary_style = expanded
|
||||
wrap_linq_expressions = wrap_if_long
|
||||
wrap_before_linq_expression = false
|
||||
place_linq_into_on_new_line = false
|
||||
wrap_verbatim_interpolated_strings = wrap_if_long
|
||||
extra_spaces = remove_all
|
||||
space_after_keywords_in_control_flow_statements = false
|
||||
space_between_method_call_name_and_opening_parenthesis = false
|
||||
space_between_method_declaration_name_and_open_parenthesis = false
|
||||
space_before_typeof_parentheses = false
|
||||
space_before_checked_parentheses = false
|
||||
space_before_sizeof_parentheses = false
|
||||
space_before_nameof_parentheses = false
|
||||
space_between_keyword_and_expression = true
|
||||
space_between_keyword_and_type = true
|
||||
space_around_assignment_op = true
|
||||
space_around_logical_op = true
|
||||
space_around_binary_operator = true
|
||||
space_around_equality_op = true
|
||||
space_around_relational_op = true
|
||||
space_around_bitwise_op = true
|
||||
space_around_additive_op = true
|
||||
space_around_multiplicative_op = true
|
||||
space_around_shift_op = true
|
||||
space_around_nullcoalescing_op = true
|
||||
space_around_arrow_op = false
|
||||
space_after_logical_not_op = false
|
||||
space_after_unary_operator = false
|
||||
space_after_cast = false
|
||||
space_around_dot = false
|
||||
space_around_lambda_arrow = true
|
||||
space_before_pointer_asterik_declaration = false
|
||||
space_before_nullable_mark = false
|
||||
blank_lines_around_class_definition = 1
|
||||
namespace_indentation = all
|
||||
space_within_template_argument = false
|
||||
align_union_type_usage = true
|
||||
space_in_singleline_method = true
|
||||
space_in_singleline_anonymous_method = true
|
||||
space_within_single_line_array_initializer_braces = true
|
||||
space_around_arrow_op = false
|
||||
|
||||
# These are for markup languages (HTML, XML, etc)
|
||||
spaces_around_eq_in_pi_attribute = false
|
||||
space_after_last_pi_attribute = true
|
||||
pi_attributes_indent = align_by_first_attribute
|
||||
blank_line_after_pi = true
|
||||
spaces_around_eq_in_attribute = false
|
||||
space_after_last_attribute = false
|
||||
space_before_self_closing = true
|
||||
attribute_style = on_single_line
|
||||
attribute_indent = align_by_first_attribute
|
||||
sort_attributes = true
|
||||
sort_class_selectors = true
|
||||
max_blank_lines_between_tags = 0
|
||||
linebreak_before_all_elements = true
|
||||
linebreak_before_multiline_elements = true
|
||||
quote_style = doublequoted
|
||||
delete_quotes_from_solid_values = false
|
||||
normalize_tag_names = true
|
||||
|
||||
|
||||
[{.babelrc,.stylelintrc,jest.config,.eslintrc,.prettierrc,*.json,*.jsb3,*.jsb2,*.bowerrc}]
|
||||
indent_size = 2
|
||||
|
||||
[*.js.map]
|
||||
indent_size = 2
|
||||
|
||||
[*.{css,scss}]
|
||||
indent_size = 2
|
||||
declarations_style = separate_lines_for_nonsingle
|
||||
media_query_style = separate_lines
|
||||
selector_style = same_line
|
||||
properties_style = separate_lines_for_nonsingle
|
||||
brace_style = next_line
|
||||
|
||||
[{.analysis_options,*.yml,*.yaml}]
|
||||
indent_size = 2
|
||||
|
||||
# Xml project files
|
||||
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
|
||||
indent_size = 2
|
||||
|
||||
# Xml files
|
||||
[*.{xml,stylecop,resx,ruleset}]
|
||||
indent_size = 2
|
||||
|
||||
# Xml config files
|
||||
[*.{props,targets,config,nuspec}]
|
||||
indent_size = 2
|
||||
|
||||
# .net files
|
||||
[*.{cs,vb}]
|
||||
# These set the this. / Me.
|
||||
dotnet_style_qualification_for_field = false:warning
|
||||
dotnet_style_qualification_for_property = false:warning
|
||||
dotnet_style_qualification_for_method = false:warning
|
||||
dotnet_style_qualification_for_event = false:warning
|
||||
|
||||
# These make it suggest Int32 instead of int, etc.
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
|
||||
dotnet_style_predefined_type_for_member_access = true:suggestion
|
||||
|
||||
# This controls implicit access modifiers
|
||||
dotnet_style_require_accessibility_modifiers = never:suggestion
|
||||
|
||||
# Prefer non modified fields to be marked readonly
|
||||
dotnet_style_readonly_field = true:warning
|
||||
|
||||
# Parenthesis settings
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_other_operators = always_for_clarity:warning
|
||||
|
||||
dotnet_style_object_initializer = true:suggestion
|
||||
dotnet_style_collection_initializer = true:suggestion
|
||||
dotnet_style_explicit_tuple_names = true:error
|
||||
dotnet_style_prefer_inferred_tuple_names = true:warning
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
|
||||
dotnet_style_prefer_conditional_expression_over_return = true:warning
|
||||
dotnet_style_coalesce_expression = true:warning
|
||||
dotnet_style_null_propagation = true:error
|
||||
|
||||
dotnet_sort_system_directives_first = true
|
||||
|
||||
# Constants in C style, all-caps
|
||||
dotnet_naming_rule.constant_fields_caps.symbols = constant_fields
|
||||
dotnet_naming_rule.constant_fields_caps.severity = warning
|
||||
dotnet_naming_rule.constant_fields_caps.style = caps_style
|
||||
dotnet_naming_symbols.constant_fields.applicable_kinds = field
|
||||
dotnet_naming_symbols.constant_fields.required_modifiers = const
|
||||
dotnet_naming_style.caps_style.capitalization = all_upper
|
||||
|
||||
# interfaces should be prefixed with I
|
||||
dotnet_naming_rule.pascal_case_for_interface.severity = error
|
||||
dotnet_naming_rule.pascal_case_for_interface.symbols = interfaces_fields
|
||||
dotnet_naming_rule.pascal_case_for_interface.style = pascal_case_interface_style
|
||||
dotnet_naming_symbols.interfaces_fields.applicable_kinds = interface
|
||||
dotnet_naming_style.pascal_case_interface_style.required_prefix = I
|
||||
dotnet_naming_style.pascal_case_interface_style.capitalization = pascal_case
|
||||
|
||||
## internal and private fields should be _camelCase
|
||||
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = warning
|
||||
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
|
||||
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
|
||||
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
|
||||
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
|
||||
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
|
||||
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
|
||||
|
||||
# 2018-12-07 NP: This is not yet working in VS2017
|
||||
# local variables should be camelCase
|
||||
#dotnet_naming_rule.camel_case_for_locals.severity = suggestion
|
||||
#dotnet_naming_rule.camel_case_for_locals.symbols = local_fields
|
||||
#dotnet_naming_rule.camel_case_for_locals.style = camel_case_style
|
||||
#dotnet_naming_symbols.local_fields.applicable_kinds = local
|
||||
#dotnet_naming_style.camel_case_style.capitalization = camel_case
|
||||
|
||||
[*.cs]
|
||||
# var var var
|
||||
csharp_style_var_for_built_in_types = false:warning
|
||||
csharp_style_var_when_type_is_apparent = true:suggestion
|
||||
csharp_style_var_elsewhere = false:warning
|
||||
|
||||
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_constructors = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_operators = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_properties = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_indexers = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_accessors = when_on_single_line:suggestion
|
||||
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
|
||||
csharp_style_pattern_matching_over_as_with_null_check = when_on_single_line:warning
|
||||
|
||||
csharp_style_inlined_variable_declaration = true:warning
|
||||
|
||||
csharp_prefer_simple_default_expression = true:warning
|
||||
csharp_style_deconstructed_variable_declaration = false:warning
|
||||
|
||||
csharp_style_throw_expression = true:warning
|
||||
csharp_style_conditional_delegate_call = true:warning
|
||||
|
||||
csharp_prefer_braces = false
|
||||
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_indent_labels = flush_left
|
||||
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = none
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
|
||||
csharp_preserve_single_line_statements = false
|
||||
csharp_preserve_single_line_blocks = true
|
||||
|
||||
csharp_blank_lines_around_region = 0
|
||||
csharp_blank_lines_inside_region = 0
|
||||
csharp_blank_lines_before_single_line_comment = 1
|
||||
csharp_keep_blank_lines_in_declarations = 1
|
||||
csharp_remove_blank_lines_near_braces_in_declarations = true
|
||||
csharp_blank_lines_after_start_comment = false
|
||||
csharp_blank_lines_between_using_groups = 0
|
||||
csharp_blank_lines_after_using_list = 1
|
||||
csharp_blank_lines_around_namespace = 1
|
||||
csharp_blank_lines_inside_namespace = 0
|
||||
csharp_blank_lines_around_type = 1
|
||||
csharp_blank_lines_inside_type = 0
|
||||
csharp_blank_lines_around_field = 0
|
||||
csharp_blank_lines_around_single_line_field = 0
|
||||
csharp_blank_lines_around_property = 1
|
||||
csharp_blank_lines_around_single_line_property = 0
|
||||
csharp_blank_lines_around_auto_property = 0
|
||||
csharp_blank_lines_around_single_line_auto_property = 0
|
||||
csharp_blank_lines_around_invocable = 1
|
||||
csharp_blank_lines_around_single_line_invocable = 1
|
||||
csharp_keep_blank_lines_in_code = 1
|
||||
csharp_remove_blank_lines_near_braces_in_code = true
|
||||
csharp_blank_lines_around_local_method = 1
|
||||
csharp_blank_lines_around_single_line_local_method = 1
|
||||
csharp_blank_lines_before_control_transfer_statements = 1
|
||||
csharp_blank_lines_after_control_transfer_statements = 1
|
||||
csharp_blank_lines_before_block_statements = 1
|
||||
csharp_blank_lines_after_block_statements = 1
|
||||
csharp_blank_lines_before_multiline_statements = 1
|
||||
csharp_blank_lines_after_multiline_statements = 1
|
||||
|
||||
csharp_type_declaration_braces = next_line
|
||||
csharp_brace_style = next_line
|
||||
csharp_indent_inside_namespace = true
|
||||
csharp_invocable_declaration_braces = next_line
|
||||
csharp_anonymous_method_declaration_braces = next_line
|
||||
csharp_accessor_owner_declaration_braces = next_line
|
||||
csharp_accessor_declaration_braces = next_line
|
||||
csharp_case_block_braces = next_line
|
||||
csharp_initializer_braces = next_line
|
||||
csharp_other_braces = next_line
|
||||
csharp_allow_comment_after_lbrace = false
|
||||
csharp_empty_block_style = together_same_line
|
||||
|
||||
csharp_for_built_in_types = use_explicit_type
|
||||
csharp_for_simple_types = use_var_when_evident
|
||||
csharp_for_other_types = use_explicit_type
|
||||
csharp_prefer_separate_deconstructed_variables_declaration = true
|
||||
csharp_prefer_explicit_discard_declaration = false
|
||||
|
||||
csharp_instance_members_qualify_members = none
|
||||
csharp_builtin_type_reference_style = use_keyword
|
||||
csharp_prefer_qualified_reference = false
|
||||
csharp_add_imports_to_deepest_scope = false
|
||||
csharp_allow_alias = true
|
||||
csharp_default_private_modifier = implicit
|
||||
csharp_default_internal_modifier = explicit
|
||||
csharp_arguments_literal = positional
|
||||
csharp_arguments_string_literal = positional
|
||||
csharp_arguments_named = positional
|
||||
csharp_arguments_anonymous_function = positional
|
||||
csharp_arguments_other = positional
|
||||
csharp_braces_for_ifelse = not_required
|
||||
csharp_braces_for_for = not_required
|
||||
csharp_braces_for_foreach = not_required
|
||||
csharp_braces_for_while = not_required
|
||||
csharp_braces_for_dowhile = not_required
|
||||
csharp_braces_for_using = not_required
|
||||
csharp_braces_for_lock = not_required
|
||||
csharp_braces_for_fixed = not_required
|
||||
csharp_method_or_operator_body = expression_body
|
||||
csharp_local_function_body = expression_body
|
||||
csharp_constructor_or_destructor_body = expression_body
|
||||
csharp_accessor_owner_body = expression_body
|
||||
csharp_force_attribute_style = join
|
||||
csharp_indent_nested_usings_stmt = true
|
||||
|
||||
csharp_builtin_type_reference_for_member_access_style = use_keyword
|
||||
csharp_indent_nested_fixed_stmt = true
|
||||
csharp_indent_nested_lock_stmt = true
|
||||
csharp_indent_nested_for_stmt = true
|
||||
csharp_indent_nested_foreach_stmt = true
|
||||
csharp_indent_nested_while_stmt = true
|
||||
csharp_use_continuous_indent_inside_parens = true
|
||||
csharp_indent_method_decl_pars = inside
|
||||
csharp_indent_invocation_pars = inside
|
||||
csharp_indent_statement_pars = inside
|
||||
csharp_indent_typeparam_angles = inside
|
||||
csharp_indent_typearg_angles = inside
|
||||
csharp_indent_pars = inside
|
||||
csharp_indent_preprocessor_if = outdent
|
||||
csharp_indent_preprocessor_region = usual_indent
|
||||
csharp_indent_preprocessor_other = usual_indent
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_indent_type_constraints = true
|
||||
csharp_stick_comment = false
|
||||
csharp_alignment_tab_fill_style = use_spaces
|
||||
csharp_align_multiline_parameter = true
|
||||
csharp_align_multiline_extends_list = true
|
||||
csharp_align_linq_query = true
|
||||
csharp_align_multiline_binary_expressions_chain = true
|
||||
csharp_outdent_binary_ops = true
|
||||
csharp_align_multiline_calls_chain = true
|
||||
csharp_outdent_dots = true
|
||||
csharp_align_multiline_array_and_object_initializer = false
|
||||
csharp_indent_anonymous_method_block = false
|
||||
csharp_align_first_arg_by_paren = true
|
||||
csharp_align_multiline_argument = true
|
||||
csharp_align_tuple_components = true
|
||||
csharp_align_multiline_expression = true
|
||||
csharp_align_multiline_for_stmt = true
|
||||
csharp_align_multiple_declaration = true
|
||||
csharp_align_multline_type_parameter_list = true
|
||||
csharp_align_multline_type_parameter_constrains = true
|
||||
csharp_int_align_fields = true
|
||||
csharp_int_align_properties = true
|
||||
csharp_int_align_methods = true
|
||||
csharp_int_align_parameters = false
|
||||
csharp_int_align_variables = true
|
||||
csharp_int_align_assignments = true
|
||||
csharp_int_align_nested_ternary = true
|
||||
csharp_int_align_invocations = false
|
||||
csharp_int_align_binary_expressions = true
|
||||
csharp_int_align_comments = true
|
||||
csharp_int_align_switch_sections = true
|
||||
csharp_int_align = true
|
||||
csharp_keep_user_linebreaks = false
|
||||
csharp_keep_existing_arrangement = false
|
||||
csharp_keep_existing_linebreaks = false
|
||||
csharp_max_line_length = 120
|
||||
csharp_wrap_before_comma = false
|
||||
csharp_special_else_if_treatment = true
|
||||
csharp_insert_final_newline = false
|
||||
csharp_place_type_attribute_on_same_line = never
|
||||
csharp_place_method_attribute_on_same_line = never
|
||||
csharp_place_accessorholder_attribute_on_same_line = never
|
||||
csharp_place_attribute_on_same_line = never
|
||||
csharp_place_accessor_attribute_on_same_line = never
|
||||
csharp_place_attribute_on_same_line = never
|
||||
csharp_place_field_attribute_on_same_line = never
|
||||
csharp_place_attribute_on_same_line = never
|
||||
csharp_wrap_parameters_style = wrap_if_long
|
||||
csharp_keep_existing_declaration_parens_arrangement = false
|
||||
csharp_wrap_before_declaration_lpar = false
|
||||
csharp_wrap_after_declaration_lpar = false
|
||||
csharp_wrap_before_declaration_rpar = false
|
||||
csharp_place_constructor_initializer_on_same_line = true
|
||||
csharp_keep_existing_expr_member_arrangement = false
|
||||
csharp_place_expr_method_on_single_line = true
|
||||
csharp_place_expr_property_on_single_line = true
|
||||
csharp_place_expr_accessor_on_single_line = true
|
||||
csharp_wrap_before_arrow_with_expressions = false
|
||||
csharp_place_type_constraints_on_same_line = true
|
||||
csharp_wrap_before_first_type_parameter_constraint = true
|
||||
csharp_wrap_multiple_type_parameter_constraints_style = wrap_if_long
|
||||
csharp_wrap_before_type_parameter_langle = true
|
||||
csharp_wrap_before_extends_colon = false
|
||||
csharp_wrap_extends_list_style = wrap_if_long
|
||||
csharp_keep_existing_declaration_block_arrangement = false
|
||||
csharp_place_abstract_accessorholder_on_single_line = true
|
||||
csharp_place_simple_accessorholder_on_single_line = false
|
||||
csharp_place_accessor_with_attrs_holder_on_single_line = false
|
||||
csharp_place_simple_accessor_on_single_line = true
|
||||
csharp_place_simple_method_on_single_line = false
|
||||
csharp_keep_existing_enum_arrangement = false
|
||||
csharp_place_simple_enum_on_single_line = false
|
||||
csharp_wrap_enum_declaration = wrap_if_long
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_while = false
|
||||
csharp_wrap_for_stmt_header_style = wrap_if_long
|
||||
csharp_wrap_multiple_declaration_style = wrap_if_long
|
||||
csharp_keep_existing_embedded_arrangement = false
|
||||
csharp_place_simple_embedded_statement_on_same_line = false
|
||||
csharp_place_simple_case_statement_on_same_line = true
|
||||
csharp_keep_existing_embedded_block_arrangement = false
|
||||
csharp_place_simple_embedded_block_on_same_line = false
|
||||
csharp_place_simple_anonymousmethod_on_single_line = false
|
||||
csharp_keep_existing_initializer_arrangement = false
|
||||
csharp_place_simple_initializer_on_single_line = false
|
||||
csharp_wrap_object_and_collection_initializer_style = chop_always
|
||||
csharp_wrap_array_initializer_style = wrap_if_long
|
||||
csharp_wrap_arguments_style = wrap_if_long
|
||||
csharp_keep_existing_invocation_parens_arrangement = false
|
||||
csharp_wrap_after_invocation_lpar = false
|
||||
csharp_wrap_before_invocation_rpar = false
|
||||
csharp_wrap_after_dot_in_method_calls = true
|
||||
csharp_wrap_chained_method_calls = wrap_if_long
|
||||
csharp_wrap_before_binary_opsign = false
|
||||
csharp_wrap_chained_binary_expressions = wrap_if_long
|
||||
csharp_force_chop_compound_if_expression = true
|
||||
csharp_force_chop_compound_while_expression = true
|
||||
csharp_force_chop_compound_do_expression = true
|
||||
csharp_wrap_before_ternary_opsigns = true
|
||||
csharp_wrap_ternary_expr_style = wrap_if_long
|
||||
csharp_nested_ternary_style = expanded
|
||||
csharp_wrap_linq_expressions = wrap_if_long
|
||||
csharp_wrap_before_linq_expression = false
|
||||
csharp_place_linq_into_on_new_line = false
|
||||
csharp_wrap_verbatim_interpolated_strings = wrap_if_long
|
||||
csharp_extra_spaces = remove_all
|
||||
csharp_space_after_keywords_in_control_flow_statements = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||
csharp_space_before_typeof_parentheses = false
|
||||
csharp_space_before_checked_parentheses = false
|
||||
csharp_space_before_sizeof_parentheses = false
|
||||
csharp_space_before_nameof_parentheses = false
|
||||
csharp_space_between_keyword_and_expression = true
|
||||
csharp_space_between_keyword_and_type = true
|
||||
csharp_space_around_assignment_op = true
|
||||
csharp_space_around_logical_op = true
|
||||
csharp_space_around_binary_operator = true
|
||||
csharp_space_around_equality_op = true
|
||||
csharp_space_around_relational_op = true
|
||||
csharp_space_around_bitwise_op = true
|
||||
csharp_space_around_additive_op = true
|
||||
csharp_space_around_multiplicative_op = true
|
||||
csharp_space_around_shift_op = true
|
||||
csharp_space_around_nullcoalescing_op = true
|
||||
csharp_space_around_arrow_op = false
|
||||
csharp_space_after_logical_not_op = false
|
||||
csharp_space_after_unary_operator = false
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_around_dot = false
|
||||
csharp_space_around_lambda_arrow = true
|
||||
csharp_space_before_pointer_asterik_declaration = false
|
||||
csharp_space_before_nullable_mark = false
|
||||
|
||||
[*.cshtml]
|
||||
linebreaks_around_razor_statements = true
|
||||
blank_lines_around_razor_functions = true
|
||||
blank_lines_around_razor_helpers = true
|
||||
blank_lines_around_razor_sections = true
|
||||
|
||||
# C++
|
||||
[*.{cc,cpp,cxx,h,hpp,hxx}]
|
||||
cpp_indent_access_specifiers_from_class = true
|
||||
cpp_indent_wrapped_function_names = false
|
||||
cpp_align_multiline_type_argument = true
|
||||
|
||||
# C, C++ and ObjectiveC
|
||||
[*.{c,h,cc,cpp,cxx,m,hpp,hxx}]
|
||||
indent_preprocessor_directives = normal
|
||||
indent_type_constraints = true
|
||||
|
||||
# Javascript and Typescript
|
||||
[*.{js,js.map,ts}]
|
||||
quote_style = doublequoted
|
||||
termination_style = ensure_semicolon
|
||||
595
Aaru.Helpers/.gitignore
vendored
595
Aaru.Helpers/.gitignore
vendored
@@ -1,595 +0,0 @@
|
||||
### VisualStudio template
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
### Linux template
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
### Xcode template
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
## User settings
|
||||
xcuserdata/
|
||||
|
||||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
|
||||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
|
||||
build/
|
||||
DerivedData/
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
### VisualStudioCode template
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
### C++ template
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
### MonoDevelop template
|
||||
#User Specific
|
||||
*.usertasks
|
||||
|
||||
#Mono Project Files
|
||||
*.resources
|
||||
test-results/
|
||||
### GPG template
|
||||
secring.*
|
||||
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
### CMake template
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
### C template
|
||||
# Object files
|
||||
*.ko
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
*.so.*
|
||||
|
||||
# Executables
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
### Windows template
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# NuGet Packages Directory
|
||||
packages/
|
||||
## TODO: If the tool you use requires repositories.config uncomment the next line
|
||||
#!packages/repositories.config
|
||||
|
||||
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
|
||||
# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
|
||||
!packages/build/
|
||||
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
|
||||
# Visual Studio 2017
|
||||
.vs
|
||||
|
||||
workspace.xml
|
||||
cmake-build-debug
|
||||
### macOS template
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
pkg/**/pkg
|
||||
pkg/**/src
|
||||
pkg/**/*.asc
|
||||
pkg/**/*.sig
|
||||
pkg/**/*.tar.xz
|
||||
pkg/**/*.zip
|
||||
pkg/**/aaru
|
||||
|
||||
.sonarqube
|
||||
@@ -1,122 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F8BDF57B-1571-4CD0-84B3-B422088D359A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Aaru.Helpers</RootNamespace>
|
||||
<AssemblyName>Aaru.Helpers</AssemblyName>
|
||||
<ReleaseVersion>$(Version)</ReleaseVersion>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>6.0.0-alpha6</Version>
|
||||
<Company>Claunia.com</Company>
|
||||
<Copyright>Copyright © 2011-2021 Natalia Portillo</Copyright>
|
||||
<Product>Aaru Data Preservation Suite</Product>
|
||||
<Title>Aaru.Helpers</Title>
|
||||
<ApplicationVersion>$(Version)</ApplicationVersion>
|
||||
<TargetFramework>net6</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<Description>Contains helpers used by the Aaru Data Preservation Suite.</Description>
|
||||
<PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl>
|
||||
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
|
||||
<RepositoryUrl>https://github.com/aaru-dps/Aaru.Helpers</RepositoryUrl>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<Authors>Natalia Portillo <claunia@claunia.com></Authors>
|
||||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
|
||||
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
|
||||
<NrtShowRevision>true</NrtShowRevision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ArrayFill.cs" />
|
||||
<Compile Include="BigEndianBitConverter.cs" />
|
||||
<Compile Include="BitEndian.cs" />
|
||||
<Compile Include="DateHandlers.cs" />
|
||||
<Compile Include="Marshal.cs" />
|
||||
<Compile Include="MarshallingPropertiesAttribute.cs" />
|
||||
<Compile Include="PrintHex.cs" />
|
||||
<Compile Include="StringHandlers.cs" />
|
||||
<Compile Include="Swapping.cs" />
|
||||
<Compile Include="ArrayIsEmpty.cs" />
|
||||
<Compile Include="CompareBytes.cs" />
|
||||
<Compile Include="CountBits.cs" />
|
||||
<Compile Include="CHS.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj">
|
||||
<Project>{CCAA7AFE-C094-4D82-A66D-630DE8A3F545}</Project>
|
||||
<Name>Aaru.Console</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\LICENSE.LGPL">
|
||||
<Link>LICENSE.LGPL</Link>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Memory" Version="4.5.4" />
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.1" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************
Aaru Data Preservation Suite
----------------------------------------------------------------------------
 
Filename : ${FileName}
Author(s) : ${AuthorName} <${AuthorEmail}>

Component : Component
 
--[ Description ] ----------------------------------------------------------
 
 Description
 
--[ 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-${Year} ${CopyrightHolder}
****************************************************************************/" />
|
||||
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp" />
|
||||
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4')) and '$(OS)' == 'Unix'">
|
||||
<!-- When compiling .NET SDK 2.0 projects targeting .NET 4.x on Mono using 'dotnet build' you -->
|
||||
<!-- have to teach MSBuild where the Mono copy of the reference asssemblies is -->
|
||||
<!-- Look in the standard install locations -->
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/Library/Frameworks/Mono.framework/Versions/Current/lib/mono')">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<!-- If we found Mono reference assemblies, then use them -->
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net40'">$(BaseFrameworkPathOverrideForMono)/4.0-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net45'">$(BaseFrameworkPathOverrideForMono)/4.5-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net451'">$(BaseFrameworkPathOverrideForMono)/4.5.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net452'">$(BaseFrameworkPathOverrideForMono)/4.5.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net46'">$(BaseFrameworkPathOverrideForMono)/4.6-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net461'">$(BaseFrameworkPathOverrideForMono)/4.6.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net462'">$(BaseFrameworkPathOverrideForMono)/4.6.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net471'">$(BaseFrameworkPathOverrideForMono)/4.7.1-api</FrameworkPathOverride>
|
||||
<EnableFrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">true</EnableFrameworkPathOverride>
|
||||
<!-- Add the Facades directory. Not sure how else to do this. Necessary at least for .NET 4.5 -->
|
||||
<AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,81 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ArrayFill.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Fills an array with a specified value.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// No license specified by creator.
|
||||
//
|
||||
// Published on https://github.com/mykohsu/Extensions/blob/master/ArrayExtensions.cs
|
||||
//
|
||||
// Assuming open source.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// Copyright(C) 2014 mykohsu
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
public static partial class ArrayHelpers
|
||||
{
|
||||
/// <summary>Fills an array with the specified value</summary>
|
||||
/// <param name="destinationArray">Array</param>
|
||||
/// <param name="value">Value</param>
|
||||
/// <typeparam name="T">Array type</typeparam>
|
||||
public static void ArrayFill<T>(T[] destinationArray, T value) => ArrayFill(destinationArray, new[]
|
||||
{
|
||||
value
|
||||
});
|
||||
|
||||
/// <summary>Fills an array with the contents of the specified array</summary>
|
||||
/// <param name="destinationArray">Array</param>
|
||||
/// <param name="value">Value</param>
|
||||
/// <typeparam name="T">Array type</typeparam>
|
||||
public static void ArrayFill<T>(T[] destinationArray, T[] value)
|
||||
{
|
||||
if(destinationArray == null)
|
||||
throw new ArgumentNullException(nameof(destinationArray));
|
||||
|
||||
if(value.Length > destinationArray.Length)
|
||||
throw new ArgumentException("Length of value array must not be more than length of destination");
|
||||
|
||||
// set the initial array value
|
||||
Array.Copy(value, destinationArray, value.Length);
|
||||
|
||||
int arrayToFillHalfLength = destinationArray.Length / 2;
|
||||
int copyLength;
|
||||
|
||||
for(copyLength = value.Length; copyLength < arrayToFillHalfLength; copyLength <<= 1)
|
||||
Array.Copy(destinationArray, 0, destinationArray, copyLength, copyLength);
|
||||
|
||||
Array.Copy(destinationArray, 0, destinationArray, copyLength, destinationArray.Length - copyLength);
|
||||
}
|
||||
|
||||
/// <summary>Converts a byte array to its hexadecimal representation</summary>
|
||||
/// <param name="array">Byte array</param>
|
||||
/// <param name="upper"><c>true</c> to use uppercase</param>
|
||||
/// <returns></returns>
|
||||
public static string ByteArrayToHex(byte[] array, bool upper = false)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
for(long i = 0; i < array.LongLength; i++)
|
||||
sb.AppendFormat("{0:x2}", array[i]);
|
||||
|
||||
return upper ? sb.ToString().ToUpper() : sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ArrayIsEmpty.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Methods for detecting an empty array.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>Helper operations to work with arrays</summary>
|
||||
public static partial class ArrayHelpers
|
||||
{
|
||||
/// <summary>Checks if an array is null, filled with the NULL byte (0x00) or ASCII whitespace (0x20)</summary>
|
||||
/// <param name="array">Array</param>
|
||||
/// <returns>True if null or whitespace</returns>
|
||||
public static bool ArrayIsNullOrWhiteSpace(byte[] array) => array?.All(b => b == 0x00 || b == 0x20) != false;
|
||||
|
||||
/// <summary>Checks if an array is null or filled with the NULL byte (0x00)</summary>
|
||||
/// <param name="array">Array</param>
|
||||
/// <returns>True if null</returns>
|
||||
public static bool ArrayIsNullOrEmpty(byte[] array) => array?.All(b => b == 0x00) != false;
|
||||
}
|
||||
}
|
||||
@@ -1,324 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : BigEndianBitConverter.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Override of System.BitConverter that knows how to handle big-endian.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts base data types to an array of bytes, and an array of bytes to base data types. All info taken from
|
||||
/// the meta data of System.BitConverter. This implementation allows for Endianness consideration.
|
||||
/// </summary>
|
||||
public static class BigEndianBitConverter
|
||||
{
|
||||
/// <summary>Converts the specified double-precision floating point number to a 64-bit signed integer.</summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>A 64-bit signed integer whose value is equivalent to value.</returns>
|
||||
/// <exception cref="NotImplementedException">It is not currently implemented</exception>
|
||||
public static long DoubleToInt64Bits(double value) => throw new NotImplementedException();
|
||||
|
||||
/// <summary>Returns the specified Boolean value as an array of bytes.</summary>
|
||||
/// <param name="value">A Boolean value.</param>
|
||||
/// <returns>An array of bytes with length 1.</returns>
|
||||
public static byte[] GetBytes(bool value) => BitConverter.GetBytes(value).Reverse().ToArray();
|
||||
|
||||
/// <summary>Returns the specified Unicode character value as an array of bytes.</summary>
|
||||
/// <param name="value">A character to convert.</param>
|
||||
/// <returns>An array of bytes with length 2.</returns>
|
||||
public static byte[] GetBytes(char value) => BitConverter.GetBytes(value).Reverse().ToArray();
|
||||
|
||||
/// <summary>Returns the specified double-precision floating point value as an array of bytes.</summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>An array of bytes with length 8.</returns>
|
||||
public static byte[] GetBytes(double value) => BitConverter.GetBytes(value).Reverse().ToArray();
|
||||
|
||||
/// <summary>Returns the specified single-precision floating point value as an array of bytes.</summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>An array of bytes with length 4.</returns>
|
||||
public static byte[] GetBytes(float value) => BitConverter.GetBytes(value).Reverse().ToArray();
|
||||
|
||||
/// <summary>Returns the specified 32-bit signed integer value as an array of bytes.</summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>An array of bytes with length 4.</returns>
|
||||
public static byte[] GetBytes(int value) => BitConverter.GetBytes(value).Reverse().ToArray();
|
||||
|
||||
/// <summary>Returns the specified 64-bit signed integer value as an array of bytes.</summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>An array of bytes with length 8.</returns>
|
||||
public static byte[] GetBytes(long value) => BitConverter.GetBytes(value).Reverse().ToArray();
|
||||
|
||||
/// <summary>Returns the specified 16-bit signed integer value as an array of bytes.</summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>An array of bytes with length 2.</returns>
|
||||
public static byte[] GetBytes(short value) => BitConverter.GetBytes(value).Reverse().ToArray();
|
||||
|
||||
/// <summary>Returns the specified 32-bit unsigned integer value as an array of bytes.</summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>An array of bytes with length 4.</returns>
|
||||
public static byte[] GetBytes(uint value) => BitConverter.GetBytes(value).Reverse().ToArray();
|
||||
|
||||
/// <summary>Returns the specified 64-bit unsigned integer value as an array of bytes.</summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>An array of bytes with length 8.</returns>
|
||||
public static byte[] GetBytes(ulong value) => BitConverter.GetBytes(value).Reverse().ToArray();
|
||||
|
||||
/// <summary>Returns the specified 16-bit unsigned integer value as an array of bytes.</summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>An array of bytes with length 2.</returns>
|
||||
public static byte[] GetBytes(ushort value) => BitConverter.GetBytes(value).Reverse().ToArray();
|
||||
|
||||
/// <summary>Converts the specified 64-bit signed integer to a double-precision floating point number.</summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>A double-precision floating point number whose value is equivalent to value.</returns>
|
||||
public static double Int64BitsToDouble(long value) => throw new NotImplementedException();
|
||||
|
||||
/// <summary>Returns a Boolean value converted from one byte at a specified position in a byte array.</summary>
|
||||
/// <param name="value">An array of bytes.</param>
|
||||
/// <param name="startIndex">The starting position within value.</param>
|
||||
/// <returns>true if the byte at <see cref="startIndex" /> in value is nonzero; otherwise, false.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// <see cref="startIndex" /> is less than zero or greater than the
|
||||
/// length of value minus 1.
|
||||
/// </exception>
|
||||
public static bool ToBoolean(byte[] value, int startIndex) => throw new NotImplementedException();
|
||||
|
||||
/// <summary>Returns a Unicode character converted from two bytes at a specified position in a byte array.</summary>
|
||||
/// <param name="value">An array.</param>
|
||||
/// <param name="startIndex">The starting position within value.</param>
|
||||
/// <returns>A character formed by two bytes beginning at <see cref="startIndex" />.</returns>
|
||||
/// <exception cref="System.ArgumentException"><see cref="startIndex" /> equals the length of value minus 1.</exception>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// <see cref="startIndex" /> is less than zero or greater than the
|
||||
/// length of value minus 1.
|
||||
/// </exception>
|
||||
public static char ToChar(byte[] value, int startIndex) => throw new NotImplementedException();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a double-precision floating point number converted from eight bytes at a specified position in a byte
|
||||
/// array.
|
||||
/// </summary>
|
||||
/// <param name="value">An array of bytes.</param>
|
||||
/// <param name="startIndex">The starting position within value.</param>
|
||||
/// <returns>A double precision floating point number formed by eight bytes beginning at <see cref="startIndex" />.</returns>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// <see cref="startIndex" /> is greater than or equal to the length of value
|
||||
/// minus 7, and is less than or equal to the length of value minus 1.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// <see cref="startIndex" /> is less than zero or greater than the
|
||||
/// length of value minus 1.
|
||||
/// </exception>
|
||||
public static double ToDouble(byte[] value, int startIndex) => throw new NotImplementedException();
|
||||
|
||||
/// <summary>Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array.</summary>
|
||||
/// <param name="value">An array of bytes.</param>
|
||||
/// <param name="startIndex">The starting position within value.</param>
|
||||
/// <returns>A 16-bit signed integer formed by two bytes beginning at <see cref="startIndex" />.</returns>
|
||||
/// <exception cref="System.ArgumentException"><see cref="startIndex" /> equals the length of value minus 1.</exception>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// startIndex is less than zero or greater than the length of value
|
||||
/// minus 1.
|
||||
/// </exception>
|
||||
public static short ToInt16(byte[] value, int startIndex) =>
|
||||
BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(short) - startIndex);
|
||||
|
||||
/// <summary>Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array.</summary>
|
||||
/// <param name="value">An array of bytes.</param>
|
||||
/// <param name="startIndex">The starting position within value.</param>
|
||||
/// <returns>A 32-bit signed integer formed by four bytes beginning at <see cref="startIndex" />.</returns>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// <see cref="startIndex" /> is greater than or equal to the length of value
|
||||
/// minus 3, and is less than or equal to the length of value minus 1.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// startIndex is less than zero or greater than the length of value
|
||||
/// minus 1.
|
||||
/// </exception>
|
||||
public static int ToInt32(byte[] value, int startIndex) =>
|
||||
BitConverter.ToInt32(value.Reverse().ToArray(), value.Length - sizeof(int) - startIndex);
|
||||
|
||||
/// <summary>Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array.</summary>
|
||||
/// <param name="value">An array of bytes.</param>
|
||||
/// <param name="startIndex">The starting position within value.</param>
|
||||
/// <returns>A 64-bit signed integer formed by eight bytes beginning at <see cref="startIndex" />.</returns>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// <see cref="startIndex" /> is greater than or equal to the length of value
|
||||
/// minus 7, and is less than or equal to the length of value minus 1.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// <see cref="startIndex" /> is less than zero or greater than the
|
||||
/// length of value minus 1.
|
||||
/// </exception>
|
||||
public static long ToInt64(byte[] value, int startIndex) =>
|
||||
BitConverter.ToInt64(value.Reverse().ToArray(), value.Length - sizeof(long) - startIndex);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a single-precision floating point number converted from four bytes at a specified position in a byte
|
||||
/// array.
|
||||
/// </summary>
|
||||
/// <param name="value">An array of bytes.</param>
|
||||
/// <param name="startIndex">The starting position within value.</param>
|
||||
/// <returns>A single-precision floating point number formed by four bytes beginning at <see cref="startIndex" />.</returns>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// <see cref="startIndex" /> is greater than or equal to the length of value
|
||||
/// minus 3, and is less than or equal to the length of value minus 1.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// <see cref="startIndex" /> is less than zero or greater than the
|
||||
/// length of value minus 1.
|
||||
/// </exception>
|
||||
public static float ToSingle(byte[] value, int startIndex) =>
|
||||
BitConverter.ToSingle(value.Reverse().ToArray(), value.Length - sizeof(float) - startIndex);
|
||||
|
||||
/// <summary>
|
||||
/// Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string
|
||||
/// representation.
|
||||
/// </summary>
|
||||
/// <param name="value">An array of bytes.</param>
|
||||
/// <returns>
|
||||
/// A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding
|
||||
/// element in value; for example, "7F-2C-4A".
|
||||
/// </returns>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
public static string ToString(byte[] value) => BitConverter.ToString(value.Reverse().ToArray());
|
||||
|
||||
/// <summary>
|
||||
/// Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal
|
||||
/// string representation.
|
||||
/// </summary>
|
||||
/// <param name="value">An array of bytes.</param>
|
||||
/// <param name="startIndex">The starting position within value.</param>
|
||||
/// <returns>
|
||||
/// A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding
|
||||
/// element in a subarray of value; for example, "7F-2C-4A".
|
||||
/// </returns>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// startIndex is less than zero or greater than the length of value
|
||||
/// minus 1.
|
||||
/// </exception>
|
||||
public static string ToString(byte[] value, int startIndex) =>
|
||||
BitConverter.ToString(value.Reverse().ToArray(), startIndex);
|
||||
|
||||
/// <summary>
|
||||
/// Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal
|
||||
/// string representation.
|
||||
/// </summary>
|
||||
/// <param name="value">An array of bytes.</param>
|
||||
/// <param name="startIndex">The starting position within value.</param>
|
||||
/// <param name="length">The number of array elements in value to convert.</param>
|
||||
/// <returns>
|
||||
/// A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding
|
||||
/// element in a subarray of value; for example, "7F-2C-4A".
|
||||
/// </returns>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// startIndex or length is less than zero. -or- startIndex is greater
|
||||
/// than zero and is greater than or equal to the length of value.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// The combination of startIndex and length does not specify a position within
|
||||
/// value; that is, the startIndex parameter is greater than the length of value minus the length parameter.
|
||||
/// </exception>
|
||||
public static string ToString(byte[] value, int startIndex, int length) =>
|
||||
BitConverter.ToString(value.Reverse().ToArray(), startIndex, length);
|
||||
|
||||
/// <summary>Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array.</summary>
|
||||
/// <param name="value">The array of bytes.</param>
|
||||
/// <param name="startIndex">The starting position within value.</param>
|
||||
/// <returns>A 16-bit unsigned integer formed by two bytes beginning at startIndex.</returns>
|
||||
/// <exception cref="System.ArgumentException">startIndex equals the length of value minus 1.</exception>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// startIndex is less than zero or greater than the length of value
|
||||
/// minus 1.
|
||||
/// </exception>
|
||||
public static ushort ToUInt16(byte[] value, int startIndex) =>
|
||||
BitConverter.ToUInt16(value.Reverse().ToArray(), value.Length - sizeof(ushort) - startIndex);
|
||||
|
||||
/// <summary>Returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array.</summary>
|
||||
/// <param name="value">An array of bytes.</param>
|
||||
/// <param name="startIndex">The starting position within value.</param>
|
||||
/// <returns>A 32-bit unsigned integer formed by four bytes beginning at startIndex.</returns>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// startIndex is greater than or equal to the length of value minus 3, and is
|
||||
/// less than or equal to the length of value minus 1.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// startIndex is less than zero or greater than the length of value
|
||||
/// minus 1.
|
||||
/// </exception>
|
||||
public static uint ToUInt32(byte[] value, int startIndex) =>
|
||||
BitConverter.ToUInt32(value.Reverse().ToArray(), value.Length - sizeof(uint) - startIndex);
|
||||
|
||||
/// <summary>Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array.</summary>
|
||||
/// <param name="value">An array of bytes.</param>
|
||||
/// <param name="startIndex">The starting position within value.</param>
|
||||
/// <returns>A 64-bit unsigned integer formed by the eight bytes beginning at startIndex.</returns>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// startIndex is greater than or equal to the length of value minus 7, and is
|
||||
/// less than or equal to the length of value minus 1.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentNullException">value is null.</exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// startIndex is less than zero or greater than the length of value
|
||||
/// minus 1.
|
||||
/// </exception>
|
||||
public static ulong ToUInt64(byte[] value, int startIndex) =>
|
||||
BitConverter.ToUInt64(value.Reverse().ToArray(), value.Length - sizeof(ulong) - startIndex);
|
||||
|
||||
/// <summary>Converts a big endian byte array representation of a GUID into the .NET Guid structure</summary>
|
||||
/// <param name="value">Byte array containing a GUID in big endian</param>
|
||||
/// <param name="startIndex">Start of the byte array to process</param>
|
||||
/// <returns>Processed Guid</returns>
|
||||
public static Guid ToGuid(byte[] value, int startIndex) => new Guid(ToUInt32(value, 0 + startIndex),
|
||||
ToUInt16(value, 4 + startIndex),
|
||||
ToUInt16(value, 6 + startIndex),
|
||||
value[8 + startIndex + 0],
|
||||
value[8 + startIndex + 1],
|
||||
value[8 + startIndex + 2],
|
||||
value[8 + startIndex + 3],
|
||||
value[8 + startIndex + 5],
|
||||
value[8 + startIndex + 5],
|
||||
value[8 + startIndex + 6],
|
||||
value[8 + startIndex + 7]);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : BitEndian.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common types.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines enumerations of bit endianness.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>Describes the endianness of bits on a data structure</summary>
|
||||
public enum BitEndian
|
||||
{
|
||||
/// <summary>Little-endian, or least significant bit</summary>
|
||||
Little,
|
||||
/// <summary>Big-endian, or most significant bit</summary>
|
||||
Big,
|
||||
/// <summary>PDP-11 endian, little endian except for 32-bit integers where the 16 halves are swapped between them</summary>
|
||||
Pdp
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : CHS.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Helpers for CHS<->LBA conversions
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>Helper operations to work with CHS values</summary>
|
||||
public static class CHS
|
||||
{
|
||||
/// <summary>Converts a CHS position to a LBA one</summary>
|
||||
/// <param name="cyl">Cylinder</param>
|
||||
/// <param name="head">Head</param>
|
||||
/// <param name="sector">Sector</param>
|
||||
/// <param name="maxHead">Number of heads</param>
|
||||
/// <param name="maxSector">Number of sectors per track</param>
|
||||
/// <returns></returns>
|
||||
public static uint ToLBA(uint cyl, uint head, uint sector, uint maxHead, uint maxSector) =>
|
||||
maxHead == 0 || maxSector == 0 ? (((cyl * 16) + head) * 63) + sector - 1
|
||||
: (((cyl * maxHead) + head) * maxSector) + sector - 1;
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : CompareBytes.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Compares two byte arrays.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
public static partial class ArrayHelpers
|
||||
{
|
||||
/// <summary>Compares two byte arrays</summary>
|
||||
/// <param name="different"><c>true</c> if they are different in any way</param>
|
||||
/// <param name="sameSize"><c>true</c> if they have the same size</param>
|
||||
/// <param name="compareArray1">Left array</param>
|
||||
/// <param name="compareArray2">Right array</param>
|
||||
public static void CompareBytes(out bool different, out bool sameSize, byte[] compareArray1,
|
||||
byte[] compareArray2)
|
||||
{
|
||||
different = false;
|
||||
sameSize = true;
|
||||
|
||||
long leastBytes;
|
||||
|
||||
if(compareArray1.LongLength < compareArray2.LongLength)
|
||||
{
|
||||
sameSize = false;
|
||||
leastBytes = compareArray1.LongLength;
|
||||
}
|
||||
else if(compareArray1.LongLength > compareArray2.LongLength)
|
||||
{
|
||||
sameSize = false;
|
||||
leastBytes = compareArray2.LongLength;
|
||||
}
|
||||
else
|
||||
leastBytes = compareArray1.LongLength;
|
||||
|
||||
for(long i = 0; i < leastBytes; i++)
|
||||
if(compareArray1[i] != compareArray2[i])
|
||||
{
|
||||
different = true;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : CountBits.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Counts bits in a number.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>Helper operations to count bits</summary>
|
||||
public static class CountBits
|
||||
{
|
||||
/// <summary>Counts the number of bits set to <c>true</c> in a number</summary>
|
||||
/// <param name="number">Number</param>
|
||||
/// <returns>Bits set to <c>true</c></returns>
|
||||
public static int Count(uint number)
|
||||
{
|
||||
number -= (number >> 1) & 0x55555555;
|
||||
number = (number & 0x33333333) + ((number >> 2) & 0x33333333);
|
||||
|
||||
return (int)((((number + (number >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,389 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : DateHandlers.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Convert several timestamp formats to C# DateTime.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>Helper operations for timestamp management (date and time)</summary>
|
||||
public static class DateHandlers
|
||||
{
|
||||
static readonly DateTime _lisaEpoch = new DateTime(1901, 1, 1, 0, 0, 0);
|
||||
static readonly DateTime _macEpoch = new DateTime(1904, 1, 1, 0, 0, 0);
|
||||
static readonly DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0);
|
||||
/// <summary>Day 0 of Julian Date system</summary>
|
||||
static readonly DateTime _julianEpoch = new DateTime(1858, 11, 17, 0, 0, 0);
|
||||
static readonly DateTime _amigaEpoch = new DateTime(1978, 1, 1, 0, 0, 0);
|
||||
|
||||
/// <summary>Converts a Macintosh timestamp to a .NET DateTime</summary>
|
||||
/// <param name="macTimeStamp">Macintosh timestamp (seconds since 1st Jan. 1904)</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime MacToDateTime(ulong macTimeStamp) => _macEpoch.AddTicks((long)(macTimeStamp * 10000000));
|
||||
|
||||
/// <summary>Converts a Lisa timestamp to a .NET DateTime</summary>
|
||||
/// <param name="lisaTimeStamp">Lisa timestamp (seconds since 1st Jan. 1901)</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime LisaToDateTime(uint lisaTimeStamp) => _lisaEpoch.AddSeconds(lisaTimeStamp);
|
||||
|
||||
/// <summary>Converts a UNIX timestamp to a .NET DateTime</summary>
|
||||
/// <param name="unixTimeStamp">UNIX timestamp (seconds since 1st Jan. 1970)</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime UnixToDateTime(int unixTimeStamp) => _unixEpoch.AddSeconds(unixTimeStamp);
|
||||
|
||||
/// <summary>Converts a UNIX timestamp to a .NET DateTime</summary>
|
||||
/// <param name="unixTimeStamp">UNIX timestamp (seconds since 1st Jan. 1970)</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime UnixToDateTime(long unixTimeStamp) => _unixEpoch.AddSeconds(unixTimeStamp);
|
||||
|
||||
/// <summary>Converts a UNIX timestamp to a .NET DateTime</summary>
|
||||
/// <param name="unixTimeStamp">UNIX timestamp (seconds since 1st Jan. 1970)</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime UnixUnsignedToDateTime(uint unixTimeStamp) => _unixEpoch.AddSeconds(unixTimeStamp);
|
||||
|
||||
/// <summary>Converts a UNIX timestamp to a .NET DateTime</summary>
|
||||
/// <param name="seconds">Seconds since 1st Jan. 1970)</param>
|
||||
/// <param name="nanoseconds">Nanoseconds</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime UnixUnsignedToDateTime(uint seconds, uint nanoseconds) =>
|
||||
_unixEpoch.AddSeconds(seconds).AddTicks((long)nanoseconds / 100);
|
||||
|
||||
/// <summary>Converts a UNIX timestamp to a .NET DateTime</summary>
|
||||
/// <param name="unixTimeStamp">UNIX timestamp (seconds since 1st Jan. 1970)</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime UnixUnsignedToDateTime(ulong unixTimeStamp) => _unixEpoch.AddSeconds(unixTimeStamp);
|
||||
|
||||
/// <summary>Converts a High Sierra Format timestamp to a .NET DateTime</summary>
|
||||
/// <param name="vdDateTime">High Sierra Format timestamp</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime HighSierraToDateTime(byte[] vdDateTime)
|
||||
{
|
||||
byte[] isoTime = new byte[17];
|
||||
Array.Copy(vdDateTime, 0, isoTime, 0, 16);
|
||||
|
||||
return Iso9660ToDateTime(isoTime);
|
||||
}
|
||||
|
||||
// TODO: Timezone
|
||||
/// <summary>Converts an ISO9660 timestamp to a .NET DateTime</summary>
|
||||
/// <param name="vdDateTime">ISO9660 timestamp</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime Iso9660ToDateTime(byte[] vdDateTime)
|
||||
{
|
||||
byte[] twoCharValue = new byte[2];
|
||||
byte[] fourCharValue = new byte[4];
|
||||
|
||||
fourCharValue[0] = vdDateTime[0];
|
||||
fourCharValue[1] = vdDateTime[1];
|
||||
fourCharValue[2] = vdDateTime[2];
|
||||
fourCharValue[3] = vdDateTime[3];
|
||||
|
||||
AaruConsole.DebugWriteLine("ISO9600ToDateTime handler", "year = \"{0}\"",
|
||||
StringHandlers.CToString(fourCharValue, Encoding.ASCII));
|
||||
|
||||
if(!int.TryParse(StringHandlers.CToString(fourCharValue, Encoding.ASCII), out int year))
|
||||
year = 0;
|
||||
|
||||
twoCharValue[0] = vdDateTime[4];
|
||||
twoCharValue[1] = vdDateTime[5];
|
||||
|
||||
AaruConsole.DebugWriteLine("ISO9600ToDateTime handler", "month = \"{0}\"",
|
||||
StringHandlers.CToString(twoCharValue, Encoding.ASCII));
|
||||
|
||||
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int month))
|
||||
month = 0;
|
||||
|
||||
twoCharValue[0] = vdDateTime[6];
|
||||
twoCharValue[1] = vdDateTime[7];
|
||||
|
||||
AaruConsole.DebugWriteLine("ISO9600ToDateTime handler", "day = \"{0}\"",
|
||||
StringHandlers.CToString(twoCharValue, Encoding.ASCII));
|
||||
|
||||
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int day))
|
||||
day = 0;
|
||||
|
||||
twoCharValue[0] = vdDateTime[8];
|
||||
twoCharValue[1] = vdDateTime[9];
|
||||
|
||||
AaruConsole.DebugWriteLine("ISO9600ToDateTime handler", "hour = \"{0}\"",
|
||||
StringHandlers.CToString(twoCharValue, Encoding.ASCII));
|
||||
|
||||
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int hour))
|
||||
hour = 0;
|
||||
|
||||
twoCharValue[0] = vdDateTime[10];
|
||||
twoCharValue[1] = vdDateTime[11];
|
||||
|
||||
AaruConsole.DebugWriteLine("ISO9600ToDateTime handler", "minute = \"{0}\"",
|
||||
StringHandlers.CToString(twoCharValue, Encoding.ASCII));
|
||||
|
||||
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int minute))
|
||||
minute = 0;
|
||||
|
||||
twoCharValue[0] = vdDateTime[12];
|
||||
twoCharValue[1] = vdDateTime[13];
|
||||
|
||||
AaruConsole.DebugWriteLine("ISO9600ToDateTime handler", "second = \"{0}\"",
|
||||
StringHandlers.CToString(twoCharValue, Encoding.ASCII));
|
||||
|
||||
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int second))
|
||||
second = 0;
|
||||
|
||||
twoCharValue[0] = vdDateTime[14];
|
||||
twoCharValue[1] = vdDateTime[15];
|
||||
|
||||
AaruConsole.DebugWriteLine("ISO9600ToDateTime handler", "hundredths = \"{0}\"",
|
||||
StringHandlers.CToString(twoCharValue, Encoding.ASCII));
|
||||
|
||||
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int hundredths))
|
||||
hundredths = 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ISO9600ToDateTime handler",
|
||||
"decodedDT = new DateTime({0}, {1}, {2}, {3}, {4}, {5}, {6}, DateTimeKind.Unspecified);",
|
||||
year, month, day, hour, minute, second, hundredths * 10);
|
||||
|
||||
sbyte difference = (sbyte)vdDateTime[16];
|
||||
|
||||
var decodedDt = new DateTime(year, month, day, hour, minute, second, hundredths * 10, DateTimeKind.Utc);
|
||||
|
||||
return decodedDt.AddMinutes(difference * -15);
|
||||
}
|
||||
|
||||
/// <summary>Converts a VMS timestamp to a .NET DateTime</summary>
|
||||
/// <param name="vmsDate">VMS timestamp (tenths of microseconds since day 0 of the Julian Date)</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
/// <remarks>C# works in UTC, VMS on Julian Date, some displacement may occur on disks created outside UTC</remarks>
|
||||
public static DateTime VmsToDateTime(ulong vmsDate)
|
||||
{
|
||||
double delta = vmsDate * 0.0001; // Tenths of microseconds to milliseconds, will lose some detail
|
||||
|
||||
return _julianEpoch.AddMilliseconds(delta);
|
||||
}
|
||||
|
||||
/// <summary>Converts an Amiga timestamp to a .NET DateTime</summary>
|
||||
/// <param name="days">Days since the 1st Jan. 1978</param>
|
||||
/// <param name="minutes">Minutes since o'clock</param>
|
||||
/// <param name="ticks">Ticks</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime AmigaToDateTime(uint days, uint minutes, uint ticks)
|
||||
{
|
||||
DateTime temp = _amigaEpoch.AddDays(days);
|
||||
temp = temp.AddMinutes(minutes);
|
||||
|
||||
return temp.AddMilliseconds(ticks * 20);
|
||||
}
|
||||
|
||||
/// <summary>Converts an UCSD Pascal timestamp to a .NET DateTime</summary>
|
||||
/// <param name="dateRecord">UCSD Pascal timestamp</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime UcsdPascalToDateTime(short dateRecord)
|
||||
{
|
||||
int year = ((dateRecord & 0xFE00) >> 9) + 1900;
|
||||
int day = (dateRecord & 0x01F0) >> 4;
|
||||
int month = dateRecord & 0x000F;
|
||||
|
||||
AaruConsole.DebugWriteLine("UCSDPascalToDateTime handler",
|
||||
"dateRecord = 0x{0:X4}, year = {1}, month = {2}, day = {3}", dateRecord, year,
|
||||
month, day);
|
||||
|
||||
return new DateTime(year, month, day);
|
||||
}
|
||||
|
||||
/// <summary>Converts a DOS timestamp to a .NET DateTime</summary>
|
||||
/// <param name="date">Date</param>
|
||||
/// <param name="time">Time</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime DosToDateTime(ushort date, ushort time)
|
||||
{
|
||||
int year = ((date & 0xFE00) >> 9) + 1980;
|
||||
int month = (date & 0x1E0) >> 5;
|
||||
int day = date & 0x1F;
|
||||
int hour = (time & 0xF800) >> 11;
|
||||
int minute = (time & 0x7E0) >> 5;
|
||||
int second = (time & 0x1F) * 2;
|
||||
|
||||
AaruConsole.DebugWriteLine("DOSToDateTime handler", "date = 0x{0:X4}, year = {1}, month = {2}, day = {3}",
|
||||
date, year, month, day);
|
||||
|
||||
AaruConsole.DebugWriteLine("DOSToDateTime handler",
|
||||
"time = 0x{0:X4}, hour = {1}, minute = {2}, second = {3}", time, hour, minute,
|
||||
second);
|
||||
|
||||
DateTime dosDate;
|
||||
|
||||
try
|
||||
{
|
||||
dosDate = new DateTime(year, month, day, hour, minute, second);
|
||||
}
|
||||
catch(ArgumentOutOfRangeException)
|
||||
{
|
||||
dosDate = new DateTime(1980, 1, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
return dosDate;
|
||||
}
|
||||
|
||||
/// <summary>Converts a CP/M timestamp to .NET DateTime</summary>
|
||||
/// <param name="timestamp">CP/M timestamp</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime CpmToDateTime(byte[] timestamp)
|
||||
{
|
||||
ushort days = BitConverter.ToUInt16(timestamp, 0);
|
||||
int hours = timestamp[2];
|
||||
int minutes = timestamp[3];
|
||||
|
||||
DateTime temp = _amigaEpoch.AddDays(days);
|
||||
temp = temp.AddHours(hours);
|
||||
temp = temp.AddMinutes(minutes);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
/// <summary>Converts an ECMA timestamp to a .NET DateTime</summary>
|
||||
/// <param name="typeAndTimeZone">Timezone</param>
|
||||
/// <param name="year">Year</param>
|
||||
/// <param name="month">Month</param>
|
||||
/// <param name="day">Day</param>
|
||||
/// <param name="hour">Hour</param>
|
||||
/// <param name="minute">Minute</param>
|
||||
/// <param name="second">Second</param>
|
||||
/// <param name="centiseconds">Centiseconds</param>
|
||||
/// <param name="hundredsOfMicroseconds">Hundreds of microseconds</param>
|
||||
/// <param name="microseconds">Microseconds</param>
|
||||
/// <returns></returns>
|
||||
public static DateTime EcmaToDateTime(ushort typeAndTimeZone, short year, byte month, byte day, byte hour,
|
||||
byte minute, byte second, byte centiseconds, byte hundredsOfMicroseconds,
|
||||
byte microseconds)
|
||||
{
|
||||
byte specification = (byte)((typeAndTimeZone & 0xF000) >> 12);
|
||||
|
||||
long ticks = ((long)centiseconds * 100000) + ((long)hundredsOfMicroseconds * 1000) +
|
||||
((long)microseconds * 10);
|
||||
|
||||
if(specification == 0)
|
||||
return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc).AddTicks(ticks);
|
||||
|
||||
ushort preOffset = (ushort)(typeAndTimeZone & 0xFFF);
|
||||
short offset;
|
||||
|
||||
if((preOffset & 0x800) == 0x800)
|
||||
offset = (short)(preOffset | 0xF000);
|
||||
else
|
||||
offset = (short)(preOffset & 0x7FF);
|
||||
|
||||
if(offset == -2047)
|
||||
return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Unspecified).AddTicks(ticks);
|
||||
|
||||
if(offset < -1440 ||
|
||||
offset > 1440)
|
||||
offset = 0;
|
||||
|
||||
return new DateTimeOffset(year, month, day, hour, minute, second, new TimeSpan(0, offset, 0)).
|
||||
AddTicks(ticks).DateTime;
|
||||
}
|
||||
|
||||
/// <summary>Converts a Solaris high resolution timestamp to .NET DateTime</summary>
|
||||
/// <param name="hrTimeStamp">Solaris high resolution timestamp</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime UnixHrTimeToDateTime(ulong hrTimeStamp) =>
|
||||
_unixEpoch.AddTicks((long)(hrTimeStamp / 100));
|
||||
|
||||
/// <summary>Converts an OS-9 timestamp to .NET DateTime</summary>
|
||||
/// <param name="date">OS-9 timestamp</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime Os9ToDateTime(byte[] date)
|
||||
{
|
||||
if(date == null ||
|
||||
(date.Length != 3 && date.Length != 5))
|
||||
return DateTime.MinValue;
|
||||
|
||||
DateTime os9Date;
|
||||
|
||||
try
|
||||
{
|
||||
os9Date = date.Length == 5 ? new DateTime(1900 + date[0], date[1], date[2], date[3], date[4], 0)
|
||||
: new DateTime(1900 + date[0], date[1], date[2], 0, 0, 0);
|
||||
}
|
||||
catch(ArgumentOutOfRangeException)
|
||||
{
|
||||
os9Date = new DateTime(1900, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
return os9Date;
|
||||
}
|
||||
|
||||
/// <summary>Converts a LIF timestamp to .NET DateTime</summary>
|
||||
/// <param name="date">LIF timestamp</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime LifToDateTime(byte[] date)
|
||||
{
|
||||
if(date == null ||
|
||||
date.Length != 6)
|
||||
return new DateTime(1970, 1, 1, 0, 0, 0);
|
||||
|
||||
return LifToDateTime(date[0], date[1], date[2], date[3], date[4], date[5]);
|
||||
}
|
||||
|
||||
/// <summary>Converts a LIF timestamp to .NET DateTime</summary>
|
||||
/// <param name="year">Yer</param>
|
||||
/// <param name="month">Month</param>
|
||||
/// <param name="day">Day</param>
|
||||
/// <param name="hour">Hour</param>
|
||||
/// <param name="minute">Minute</param>
|
||||
/// <param name="second">Second</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime LifToDateTime(byte year, byte month, byte day, byte hour, byte minute, byte second)
|
||||
{
|
||||
try
|
||||
{
|
||||
int iyear = ((year >> 4) * 10) + (year & 0xF);
|
||||
int imonth = ((month >> 4) * 10) + (month & 0xF);
|
||||
int iday = ((day >> 4) * 10) + (day & 0xF);
|
||||
int iminute = ((minute >> 4) * 10) + (minute & 0xF);
|
||||
int ihour = ((hour >> 4) * 10) + (hour & 0xF);
|
||||
int isecond = ((second >> 4) * 10) + (second & 0xF);
|
||||
|
||||
if(iyear >= 70)
|
||||
iyear += 1900;
|
||||
else
|
||||
iyear += 2000;
|
||||
|
||||
return new DateTime(iyear, imonth, iday, ihour, iminute, isecond);
|
||||
}
|
||||
catch(ArgumentOutOfRangeException)
|
||||
{
|
||||
return new DateTime(1970, 1, 1, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,498 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Marshal.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides marshalling for binary data.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>Provides methods to marshal binary data into C# structs</summary>
|
||||
public static class Marshal
|
||||
{
|
||||
/// <summary>Returns the size of an unmanaged type in bytes.</summary>
|
||||
/// <typeparam name="T">The type whose size is to be returned.</typeparam>
|
||||
/// <returns>The size, in bytes, of the type that is specified by the <see cref="T" /> generic type parameter.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int SizeOf<T>() => System.Runtime.InteropServices.Marshal.SizeOf<T>();
|
||||
|
||||
/// <summary>Marshal little-endian binary data to a structure</summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T ByteArrayToStructureLittleEndian<T>(byte[] bytes) where T : struct
|
||||
{
|
||||
var ptr = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
|
||||
var str = (T)System.Runtime.InteropServices.Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(T));
|
||||
|
||||
ptr.Free();
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>Marshal little-endian binary data to a structure</summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <param name="start">Start on the array where the structure begins</param>
|
||||
/// <param name="length">Length of the structure in bytes</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T ByteArrayToStructureLittleEndian<T>(byte[] bytes, int start, int length) where T : struct
|
||||
{
|
||||
Span<byte> span = bytes;
|
||||
|
||||
return ByteArrayToStructureLittleEndian<T>(span.Slice(start, length).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>Marshal big-endian binary data to a structure</summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T ByteArrayToStructureBigEndian<T>(byte[] bytes) where T : struct
|
||||
{
|
||||
var ptr = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
|
||||
object str = (T)System.Runtime.InteropServices.Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(T));
|
||||
|
||||
ptr.Free();
|
||||
|
||||
return (T)SwapStructureMembersEndian(str);
|
||||
}
|
||||
|
||||
/// <summary>Marshal big-endian binary data to a structure</summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <param name="start">Start on the array where the structure begins</param>
|
||||
/// <param name="length">Length of the structure in bytes</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T ByteArrayToStructureBigEndian<T>(byte[] bytes, int start, int length) where T : struct
|
||||
{
|
||||
Span<byte> span = bytes;
|
||||
|
||||
return ByteArrayToStructureBigEndian<T>(span.Slice(start, length).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>Marshal PDP-11 binary data to a structure</summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T ByteArrayToStructurePdpEndian<T>(byte[] bytes) where T : struct
|
||||
{
|
||||
{
|
||||
var ptr = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
|
||||
object str =
|
||||
(T)System.Runtime.InteropServices.Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(T));
|
||||
|
||||
ptr.Free();
|
||||
|
||||
return (T)SwapStructureMembersEndianPdp(str);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Marshal PDP-11 binary data to a structure</summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <param name="start">Start on the array where the structure begins</param>
|
||||
/// <param name="length">Length of the structure in bytes</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T ByteArrayToStructurePdpEndian<T>(byte[] bytes, int start, int length) where T : struct
|
||||
{
|
||||
Span<byte> span = bytes;
|
||||
|
||||
return ByteArrayToStructurePdpEndian<T>(span.Slice(start, length).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marshal little-endian binary data to a structure. If the structure type contains any non value type, this
|
||||
/// method will crash.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T SpanToStructureLittleEndian<T>(ReadOnlySpan<byte> bytes) where T : struct =>
|
||||
MemoryMarshal.Read<T>(bytes);
|
||||
|
||||
/// <summary>
|
||||
/// Marshal little-endian binary data to a structure. If the structure type contains any non value type, this
|
||||
/// method will crash.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte span containing the binary data</param>
|
||||
/// <param name="start">Start on the span where the structure begins</param>
|
||||
/// <param name="length">Length of the structure in bytes</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T SpanToStructureLittleEndian<T>(ReadOnlySpan<byte> bytes, int start, int length)
|
||||
where T : struct => MemoryMarshal.Read<T>(bytes.Slice(start, length));
|
||||
|
||||
/// <summary>
|
||||
/// Marshal big-endian binary data to a structure. If the structure type contains any non value type, this method
|
||||
/// will crash.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T SpanToStructureBigEndian<T>(ReadOnlySpan<byte> bytes) where T : struct
|
||||
{
|
||||
T str = SpanToStructureLittleEndian<T>(bytes);
|
||||
|
||||
return (T)SwapStructureMembersEndian(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marshal big-endian binary data to a structure. If the structure type contains any non value type, this method
|
||||
/// will crash.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte span containing the binary data</param>
|
||||
/// <param name="start">Start on the span where the structure begins</param>
|
||||
/// <param name="length">Length of the structure in bytes</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T SpanToStructureBigEndian<T>(ReadOnlySpan<byte> bytes, int start, int length) where T : struct
|
||||
{
|
||||
T str = SpanToStructureLittleEndian<T>(bytes.Slice(start, length));
|
||||
|
||||
return (T)SwapStructureMembersEndian(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marshal PDP-11 binary data to a structure. If the structure type contains any non value type, this method will
|
||||
/// crash.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T SpanToStructurePdpEndian<T>(ReadOnlySpan<byte> bytes) where T : struct
|
||||
{
|
||||
object str = SpanToStructureLittleEndian<T>(bytes);
|
||||
|
||||
return (T)SwapStructureMembersEndianPdp(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marshal PDP-11 binary data to a structure. If the structure type contains any non value type, this method will
|
||||
/// crash.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <param name="start">Start on the span where the structure begins</param>
|
||||
/// <param name="length">Length of the structure in bytes</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T SpanToStructurePdpEndian<T>(ReadOnlySpan<byte> bytes, int start, int length) where T : struct
|
||||
{
|
||||
object str = SpanToStructureLittleEndian<T>(bytes.Slice(start, length));
|
||||
|
||||
return (T)SwapStructureMembersEndianPdp(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marshal a structure depending on the decoration of <see cref="MarshallingPropertiesAttribute" />. If the
|
||||
/// decoration is not present it will marshal as a reference type containing little endian structure.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// The <see cref="MarshallingPropertiesAttribute" /> contains an unsupported
|
||||
/// endian
|
||||
/// </exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T MarshalStructure<T>(byte[] bytes) where T : struct
|
||||
{
|
||||
if(!(typeof(T).GetCustomAttribute(typeof(MarshallingPropertiesAttribute)) is MarshallingPropertiesAttribute
|
||||
properties))
|
||||
return ByteArrayToStructureLittleEndian<T>(bytes);
|
||||
|
||||
switch(properties.Endian)
|
||||
{
|
||||
case BitEndian.Little:
|
||||
return properties.HasReferences ? ByteArrayToStructureLittleEndian<T>(bytes)
|
||||
: SpanToStructureLittleEndian<T>(bytes);
|
||||
|
||||
case BitEndian.Big:
|
||||
return properties.HasReferences ? ByteArrayToStructureBigEndian<T>(bytes)
|
||||
: SpanToStructureBigEndian<T>(bytes);
|
||||
|
||||
case BitEndian.Pdp:
|
||||
return properties.HasReferences ? ByteArrayToStructurePdpEndian<T>(bytes)
|
||||
: SpanToStructurePdpEndian<T>(bytes);
|
||||
default: throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Swaps all members of a structure</summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining), SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static object SwapStructureMembersEndian(object str)
|
||||
{
|
||||
Type t = str.GetType();
|
||||
FieldInfo[] fieldInfo = t.GetFields();
|
||||
|
||||
foreach(FieldInfo fi in fieldInfo)
|
||||
if(fi.FieldType == typeof(short) ||
|
||||
(fi.FieldType.IsEnum && fi.FieldType.GetEnumUnderlyingType() == typeof(short)))
|
||||
{
|
||||
short x = (short)fi.GetValue(str);
|
||||
fi.SetValue(str, (short)((x << 8) | ((x >> 8) & 0xFF)));
|
||||
}
|
||||
else if(fi.FieldType == typeof(int) ||
|
||||
(fi.FieldType.IsEnum && fi.FieldType.GetEnumUnderlyingType() == typeof(int)))
|
||||
{
|
||||
int x = (int)fi.GetValue(str);
|
||||
x = (int)(((x << 8) & 0xFF00FF00) | (((uint)x >> 8) & 0xFF00FF));
|
||||
fi.SetValue(str, (int)(((uint)x << 16) | (((uint)x >> 16) & 0xFFFF)));
|
||||
}
|
||||
else if(fi.FieldType == typeof(long) ||
|
||||
(fi.FieldType.IsEnum && fi.FieldType.GetEnumUnderlyingType() == typeof(long)))
|
||||
{
|
||||
long x = (long)fi.GetValue(str);
|
||||
x = ((x & 0x00000000FFFFFFFF) << 32) | (long)(((ulong)x & 0xFFFFFFFF00000000) >> 32);
|
||||
x = ((x & 0x0000FFFF0000FFFF) << 16) | (long)(((ulong)x & 0xFFFF0000FFFF0000) >> 16);
|
||||
x = ((x & 0x00FF00FF00FF00FF) << 8) | (long)(((ulong)x & 0xFF00FF00FF00FF00) >> 8);
|
||||
|
||||
fi.SetValue(str, x);
|
||||
}
|
||||
else if(fi.FieldType == typeof(ushort) ||
|
||||
(fi.FieldType.IsEnum && fi.FieldType.GetEnumUnderlyingType() == typeof(ushort)))
|
||||
{
|
||||
ushort x = (ushort)fi.GetValue(str);
|
||||
fi.SetValue(str, (ushort)((x << 8) | (x >> 8)));
|
||||
}
|
||||
else if(fi.FieldType == typeof(uint) ||
|
||||
(fi.FieldType.IsEnum && fi.FieldType.GetEnumUnderlyingType() == typeof(uint)))
|
||||
{
|
||||
uint x = (uint)fi.GetValue(str);
|
||||
x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF);
|
||||
fi.SetValue(str, (x << 16) | (x >> 16));
|
||||
}
|
||||
else if(fi.FieldType == typeof(ulong) ||
|
||||
(fi.FieldType.IsEnum && fi.FieldType.GetEnumUnderlyingType() == typeof(ulong)))
|
||||
{
|
||||
ulong x = (ulong)fi.GetValue(str);
|
||||
x = ((x & 0x00000000FFFFFFFF) << 32) | ((x & 0xFFFFFFFF00000000) >> 32);
|
||||
x = ((x & 0x0000FFFF0000FFFF) << 16) | ((x & 0xFFFF0000FFFF0000) >> 16);
|
||||
x = ((x & 0x00FF00FF00FF00FF) << 8) | ((x & 0xFF00FF00FF00FF00) >> 8);
|
||||
fi.SetValue(str, x);
|
||||
}
|
||||
else if(fi.FieldType == typeof(float))
|
||||
{
|
||||
float flt = (float)fi.GetValue(str);
|
||||
byte[] flt_b = BitConverter.GetBytes(flt);
|
||||
|
||||
fi.SetValue(str, BitConverter.ToSingle(new[]
|
||||
{
|
||||
flt_b[3], flt_b[2], flt_b[1], flt_b[0]
|
||||
}, 0));
|
||||
}
|
||||
else if(fi.FieldType == typeof(double))
|
||||
{
|
||||
double dbl = (double)fi.GetValue(str);
|
||||
byte[] dbl_b = BitConverter.GetBytes(dbl);
|
||||
|
||||
fi.SetValue(str, BitConverter.ToDouble(new[]
|
||||
{
|
||||
dbl_b[7], dbl_b[6], dbl_b[5], dbl_b[4], dbl_b[3], dbl_b[2], dbl_b[1], dbl_b[0]
|
||||
}, 0));
|
||||
}
|
||||
else if(fi.FieldType == typeof(byte) ||
|
||||
fi.FieldType == typeof(sbyte))
|
||||
{
|
||||
// Do nothing, can't byteswap them!
|
||||
}
|
||||
else if(fi.FieldType == typeof(Guid))
|
||||
{
|
||||
// TODO: Swap GUID
|
||||
}
|
||||
|
||||
// TODO: Swap arrays
|
||||
else if(fi.FieldType.IsValueType &&
|
||||
!fi.FieldType.IsEnum &&
|
||||
!fi.FieldType.IsArray)
|
||||
{
|
||||
object obj = fi.GetValue(str);
|
||||
object strc = SwapStructureMembersEndian(obj);
|
||||
fi.SetValue(str, strc);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>Swaps all fields in an structure considering them to follow PDP endian conventions</summary>
|
||||
/// <param name="str">Source structure</param>
|
||||
/// <returns>Resulting structure</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static object SwapStructureMembersEndianPdp(object str)
|
||||
{
|
||||
Type t = str.GetType();
|
||||
FieldInfo[] fieldInfo = t.GetFields();
|
||||
|
||||
foreach(FieldInfo fi in fieldInfo)
|
||||
if(fi.FieldType == typeof(short) ||
|
||||
fi.FieldType == typeof(long) ||
|
||||
fi.FieldType == typeof(ushort) ||
|
||||
fi.FieldType == typeof(ulong) ||
|
||||
fi.FieldType == typeof(float) ||
|
||||
fi.FieldType == typeof(double) ||
|
||||
fi.FieldType == typeof(byte) ||
|
||||
fi.FieldType == typeof(sbyte) ||
|
||||
fi.FieldType == typeof(Guid))
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else if(fi.FieldType == typeof(int) ||
|
||||
(fi.FieldType.IsEnum && fi.FieldType.GetEnumUnderlyingType() == typeof(int)))
|
||||
{
|
||||
int x = (int)fi.GetValue(str);
|
||||
fi.SetValue(str, ((x & 0xffffu) << 16) | ((x & 0xffff0000u) >> 16));
|
||||
}
|
||||
else if(fi.FieldType == typeof(uint) ||
|
||||
(fi.FieldType.IsEnum && fi.FieldType.GetEnumUnderlyingType() == typeof(uint)))
|
||||
{
|
||||
uint x = (uint)fi.GetValue(str);
|
||||
fi.SetValue(str, ((x & 0xffffu) << 16) | ((x & 0xffff0000u) >> 16));
|
||||
}
|
||||
|
||||
// TODO: Swap arrays
|
||||
else if(fi.FieldType.IsValueType &&
|
||||
!fi.FieldType.IsEnum &&
|
||||
!fi.FieldType.IsArray)
|
||||
{
|
||||
object obj = fi.GetValue(str);
|
||||
object strc = SwapStructureMembersEndianPdp(obj);
|
||||
fi.SetValue(str, strc);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>Marshal a structure to little-endian binary data</summary>
|
||||
/// <param name="str">The structure you want to marshal to binary</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The byte array representing the given structure</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static byte[] StructureToByteArrayLittleEndian<T>(T str) where T : struct
|
||||
{
|
||||
byte[] buf = new byte[SizeOf<T>()];
|
||||
var ptr = GCHandle.Alloc(buf, GCHandleType.Pinned);
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(str, ptr.AddrOfPinnedObject(), false);
|
||||
ptr.Free();
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/// <summary>Marshal a structure to little-endian binary data</summary>
|
||||
/// <param name="str">The structure you want to marshal to binary</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The byte array representing the given structure</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static byte[] StructureToByteArrayBigEndian<T>(T str) where T : struct =>
|
||||
StructureToByteArrayLittleEndian((T)SwapStructureMembersEndian(str));
|
||||
|
||||
/// <summary>Converts a hexadecimal string into a byte array</summary>
|
||||
/// <param name="hex">Hexadecimal string</param>
|
||||
/// <param name="outBuf">Resulting byte array</param>
|
||||
/// <returns>Number of output bytes processed</returns>
|
||||
public static int ConvertFromHexAscii(string hex, out byte[] outBuf)
|
||||
{
|
||||
outBuf = null;
|
||||
|
||||
if(hex is null ||
|
||||
hex == "")
|
||||
return -1;
|
||||
|
||||
int off = 0;
|
||||
|
||||
if(hex[0] == '0' &&
|
||||
(hex[1] == 'x' || hex[1] == 'X'))
|
||||
{
|
||||
off = 2;
|
||||
}
|
||||
|
||||
outBuf = new byte[(hex.Length - off) / 2];
|
||||
int count = 0;
|
||||
|
||||
for(int i = off; i < hex.Length; i += 2)
|
||||
{
|
||||
char c = hex[i];
|
||||
|
||||
if(c < '0' ||
|
||||
(c > '9' && c < 'A') ||
|
||||
(c > 'F' && c < 'a') ||
|
||||
c > 'f')
|
||||
break;
|
||||
|
||||
c -= c >= 'a' && c <= 'f'
|
||||
? '\u0057'
|
||||
: c >= 'A' && c <= 'F'
|
||||
? '\u0037'
|
||||
: '\u0030';
|
||||
|
||||
outBuf[(i - off) / 2] = (byte)(c << 4);
|
||||
|
||||
c = hex[i + 1];
|
||||
|
||||
if(c < '0' ||
|
||||
(c > '9' && c < 'A') ||
|
||||
(c > 'F' && c < 'a') ||
|
||||
c > 'f')
|
||||
break;
|
||||
|
||||
c -= c >= 'a' && c <= 'f'
|
||||
? '\u0057'
|
||||
: c >= 'A' && c <= 'F'
|
||||
? '\u0037'
|
||||
: '\u0030';
|
||||
|
||||
outBuf[(i - off) / 2] += (byte)c;
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : MarshallingPropertiesAttribute.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common types.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Declares properties of structs for marshalling.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Defines properties to help marshalling structs from binary data</summary>
|
||||
[AttributeUsage(AttributeTargets.Struct)]
|
||||
public sealed class MarshallingPropertiesAttribute : Attribute
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>Defines properties to help marshalling structs from binary data</summary>
|
||||
/// <param name="endian">Defines properties to help marshalling structs from binary data</param>
|
||||
public MarshallingPropertiesAttribute(BitEndian endian)
|
||||
{
|
||||
Endian = endian;
|
||||
HasReferences = true;
|
||||
}
|
||||
|
||||
/// <summary>c</summary>
|
||||
public BitEndian Endian { get; }
|
||||
/// <summary>Tells if the structure, or any nested structure, has any non-value type (e.g. arrays, strings, etc).</summary>
|
||||
public bool HasReferences { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : PrintHex.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Prints a byte array as hexadecimal.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Text;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>Helper operations to get hexadecimal representations of byte arrays</summary>
|
||||
public static class PrintHex
|
||||
{
|
||||
/// <summary>Prints a byte array as hexadecimal values to the console</summary>
|
||||
/// <param name="array">Array</param>
|
||||
/// <param name="width">Width of line</param>
|
||||
public static void PrintHexArray(byte[] array, int width = 16) =>
|
||||
AaruConsole.WriteLine(ByteArrayToHexArrayString(array, width));
|
||||
|
||||
/// <summary>Prints a byte array as hexadecimal values to a string</summary>
|
||||
/// <param name="array">Array</param>
|
||||
/// <param name="width">Width of line</param>
|
||||
/// <param name="color">Use ANSI escape colors for sections</param>
|
||||
/// <returns>String containing hexadecimal values</returns>
|
||||
public static string ByteArrayToHexArrayString(byte[] array, int width = 16, bool color = false)
|
||||
{
|
||||
if(array is null)
|
||||
return null;
|
||||
|
||||
// TODO: Color list
|
||||
// TODO: Allow to change width
|
||||
string str = "Offset";
|
||||
int rows = array.Length / 16;
|
||||
int last = array.Length % 16;
|
||||
int offsetLength = $"{array.Length:X}".Length;
|
||||
var sb = new StringBuilder();
|
||||
|
||||
if(last > 0)
|
||||
rows++;
|
||||
|
||||
if(last == 0)
|
||||
last = 16;
|
||||
|
||||
if(offsetLength < str.Length)
|
||||
offsetLength = str.Length;
|
||||
|
||||
while(str.Length < offsetLength)
|
||||
str += ' ';
|
||||
|
||||
if(color)
|
||||
sb.Append("\u001b[36m");
|
||||
|
||||
sb.Append(str);
|
||||
sb.Append(" ");
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
sb.AppendFormat(" {0:X2}", i);
|
||||
}
|
||||
|
||||
if(color)
|
||||
sb.Append("\u001b[0m");
|
||||
|
||||
sb.AppendLine();
|
||||
|
||||
int b = 0;
|
||||
|
||||
string format = $"{{0:X{offsetLength}}}";
|
||||
|
||||
for(int i = 0; i < rows; i++)
|
||||
{
|
||||
if(color)
|
||||
sb.Append("\u001b[36m");
|
||||
|
||||
sb.AppendFormat(format, b);
|
||||
|
||||
if(color)
|
||||
sb.Append("\u001b[0m");
|
||||
|
||||
sb.Append(" ");
|
||||
int lastBytes = i == rows - 1 ? last : 16;
|
||||
int lastSpaces = 16 - lastBytes;
|
||||
|
||||
for(int j = 0; j < lastBytes; j++)
|
||||
{
|
||||
sb.AppendFormat(" {0:X2}", array[b]);
|
||||
b++;
|
||||
}
|
||||
|
||||
for(int j = 0; j < lastSpaces; j++)
|
||||
sb.Append(" ");
|
||||
|
||||
b -= lastBytes;
|
||||
sb.Append(" ");
|
||||
|
||||
for(int j = 0; j < lastBytes; j++)
|
||||
{
|
||||
int v = array[b];
|
||||
sb.Append((v > 31 && v < 127) || v > 159 ? (char)v : '.');
|
||||
b++;
|
||||
}
|
||||
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : StringHandlers.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Convert byte arrays to C# strings.
|
||||
//
|
||||
// --[ 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-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>Helper operations to work with strings</summary>
|
||||
public static class StringHandlers
|
||||
{
|
||||
/// <summary>Converts a null-terminated (aka C string) ASCII byte array to a C# string</summary>
|
||||
/// <returns>The corresponding C# string</returns>
|
||||
/// <param name="cString">A null-terminated (aka C string) ASCII byte array</param>
|
||||
public static string CToString(byte[] cString) => CToString(cString, Encoding.ASCII);
|
||||
|
||||
/// <summary>Converts a null-terminated (aka C string) byte array with the specified encoding to a C# string</summary>
|
||||
/// <returns>The corresponding C# string</returns>
|
||||
/// <param name="cString">A null-terminated (aka C string) byte array in the specified encoding</param>
|
||||
/// <param name="encoding">Encoding.</param>
|
||||
/// <param name="twoBytes">Set if encoding uses 16-bit characters.</param>
|
||||
/// <param name="start">Start decoding at this position</param>
|
||||
public static string CToString(byte[] cString, Encoding encoding, bool twoBytes = false, int start = 0)
|
||||
{
|
||||
if(cString == null)
|
||||
return null;
|
||||
|
||||
int len = 0;
|
||||
|
||||
for(int i = start; i < cString.Length; i++)
|
||||
{
|
||||
if(cString[i] == 0)
|
||||
if(twoBytes)
|
||||
{
|
||||
if(i + 1 < cString.Length &&
|
||||
cString[i + 1] == 0)
|
||||
{
|
||||
len++;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
len++;
|
||||
}
|
||||
|
||||
if(twoBytes && len % 2 > 0)
|
||||
len--;
|
||||
|
||||
byte[] dest = new byte[len];
|
||||
Array.Copy(cString, start, dest, 0, len);
|
||||
|
||||
return len == 0 ? "" : encoding.GetString(dest);
|
||||
}
|
||||
|
||||
/// <summary>Converts a length-prefixed (aka Pascal string) ASCII byte array to a C# string</summary>
|
||||
/// <returns>The corresponding C# string</returns>
|
||||
/// <param name="pascalString">A length-prefixed (aka Pascal string) ASCII byte array</param>
|
||||
public static string PascalToString(byte[] pascalString) => PascalToString(pascalString, Encoding.ASCII);
|
||||
|
||||
/// <summary>Converts a length-prefixed (aka Pascal string) ASCII byte array to a C# string</summary>
|
||||
/// <returns>The corresponding C# string</returns>
|
||||
/// <param name="pascalString">A length-prefixed (aka Pascal string) ASCII byte array</param>
|
||||
/// <param name="encoding">Encoding.</param>
|
||||
/// <param name="start">Start decoding at this position</param>
|
||||
public static string PascalToString(byte[] pascalString, Encoding encoding, int start = 0)
|
||||
{
|
||||
if(pascalString == null)
|
||||
return null;
|
||||
|
||||
byte length = pascalString[start];
|
||||
int len = 0;
|
||||
|
||||
for(int i = start + 1; i < length + 1 && i < pascalString.Length; i++)
|
||||
{
|
||||
if(pascalString[i] == 0)
|
||||
break;
|
||||
|
||||
len++;
|
||||
}
|
||||
|
||||
byte[] dest = new byte[len];
|
||||
Array.Copy(pascalString, start + 1, dest, 0, len);
|
||||
|
||||
return len == 0 ? "" : encoding.GetString(dest);
|
||||
}
|
||||
|
||||
/// <summary>Converts a space (' ', 0x20, ASCII SPACE) padded ASCII byte array to a C# string</summary>
|
||||
/// <returns>The corresponding C# string</returns>
|
||||
/// <param name="spacePaddedString">A space (' ', 0x20, ASCII SPACE) padded ASCII byte array</param>
|
||||
public static string SpacePaddedToString(byte[] spacePaddedString) =>
|
||||
SpacePaddedToString(spacePaddedString, Encoding.ASCII);
|
||||
|
||||
/// <summary>Converts a space (' ', 0x20, ASCII SPACE) padded ASCII byte array to a C# string</summary>
|
||||
/// <returns>The corresponding C# string</returns>
|
||||
/// <param name="spacePaddedString">A space (' ', 0x20, ASCII SPACE) padded ASCII byte array</param>
|
||||
/// <param name="encoding">Encoding.</param>
|
||||
/// <param name="start">Start decoding at this position</param>
|
||||
public static string SpacePaddedToString(byte[] spacePaddedString, Encoding encoding, int start = 0)
|
||||
{
|
||||
if(spacePaddedString == null)
|
||||
return null;
|
||||
|
||||
int len = start;
|
||||
|
||||
for(int i = spacePaddedString.Length; i >= start; i--)
|
||||
{
|
||||
if(i == start)
|
||||
return "";
|
||||
|
||||
if(spacePaddedString[i - 1] == 0x20)
|
||||
continue;
|
||||
|
||||
len = i;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return len == 0 ? "" : encoding.GetString(spacePaddedString, start, len);
|
||||
}
|
||||
|
||||
/// <summary>Converts an OSTA compressed unicode byte array to a C# string</summary>
|
||||
/// <returns>The C# string.</returns>
|
||||
/// <param name="dstring">OSTA compressed unicode byte array.</param>
|
||||
public static string DecompressUnicode(byte[] dstring)
|
||||
{
|
||||
ushort unicode;
|
||||
byte compId = dstring[0];
|
||||
string temp = "";
|
||||
|
||||
if(compId != 8 &&
|
||||
compId != 16)
|
||||
return null;
|
||||
|
||||
for(int byteIndex = 1; byteIndex < dstring.Length;)
|
||||
{
|
||||
if(compId == 16)
|
||||
unicode = (ushort)(dstring[byteIndex++] << 8);
|
||||
else
|
||||
unicode = 0;
|
||||
|
||||
if(byteIndex < dstring.Length)
|
||||
unicode |= dstring[byteIndex++];
|
||||
|
||||
if(unicode == 0)
|
||||
break;
|
||||
|
||||
temp += Encoding.Unicode.GetString(BitConverter.GetBytes(unicode));
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user