mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Update packages, fix build
This commit is contained in:
@@ -5,7 +5,7 @@ using SabreTools.DatFiles;
|
|||||||
using SabreTools.DatTools;
|
using SabreTools.DatTools;
|
||||||
using SabreTools.FileTypes;
|
using SabreTools.FileTypes;
|
||||||
using SabreTools.Help;
|
using SabreTools.Help;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
|
|
||||||
namespace RombaSharp.Features
|
namespace RombaSharp.Features
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.IO;
|
|||||||
using SabreTools.DatFiles;
|
using SabreTools.DatFiles;
|
||||||
using SabreTools.DatTools;
|
using SabreTools.DatTools;
|
||||||
using SabreTools.Help;
|
using SabreTools.Help;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
|
|
||||||
namespace RombaSharp.Features
|
namespace RombaSharp.Features
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using SabreTools.DatTools;
|
|||||||
using SabreTools.FileTypes;
|
using SabreTools.FileTypes;
|
||||||
using SabreTools.Hashing;
|
using SabreTools.Hashing;
|
||||||
using SabreTools.Help;
|
using SabreTools.Help;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
|
|
||||||
namespace RombaSharp.Features
|
namespace RombaSharp.Features
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.IO;
|
|||||||
using SabreTools.DatFiles;
|
using SabreTools.DatFiles;
|
||||||
using SabreTools.DatTools;
|
using SabreTools.DatTools;
|
||||||
using SabreTools.Help;
|
using SabreTools.Help;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
|
|
||||||
namespace RombaSharp.Features
|
namespace RombaSharp.Features
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using SabreTools.DatFiles;
|
|||||||
using SabreTools.DatTools;
|
using SabreTools.DatTools;
|
||||||
using SabreTools.Help;
|
using SabreTools.Help;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO;
|
||||||
|
using SabreTools.IO.Extensions;
|
||||||
|
|
||||||
namespace RombaSharp.Features
|
namespace RombaSharp.Features
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.3" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="SabreTools.Hashing" Version="1.2.0" />
|
<PackageReference Include="SabreTools.Hashing" Version="1.2.0" />
|
||||||
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
||||||
<PackageReference Include="SabreTools.Models" Version="1.4.0" />
|
<PackageReference Include="SabreTools.Models" Version="1.4.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
@@ -43,11 +44,37 @@ namespace SabreTools.Core.Tools
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static string?[] GetDatItemTypeNames()
|
public static string?[] GetDatItemTypeNames()
|
||||||
{
|
{
|
||||||
return AppDomain.CurrentDomain.GetAssemblies()
|
List<string> typeNames = [];
|
||||||
.SelectMany(a => a.GetTypes())
|
|
||||||
.Where(t => typeof(DatItem).IsAssignableFrom(t) && t.IsClass)
|
// Loop through all loaded assemblies
|
||||||
.Select(GetXmlRootAttributeElementName)
|
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
.ToArray();
|
{
|
||||||
|
// If not all types can be loaded, use the ones that could be
|
||||||
|
List<Type> assemblyTypes = [];
|
||||||
|
try
|
||||||
|
{
|
||||||
|
assemblyTypes = assembly.GetTypes().ToList<Type>();
|
||||||
|
}
|
||||||
|
catch (ReflectionTypeLoadException rtle)
|
||||||
|
{
|
||||||
|
assemblyTypes = rtle.Types.Where(t => t != null)!.ToList<Type>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loop through all types
|
||||||
|
foreach (Type type in assemblyTypes)
|
||||||
|
{
|
||||||
|
// If the type isn't a class or doesn't implement the interface
|
||||||
|
if (!type.IsClass || !typeof(DatItem).IsAssignableFrom(type))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Get the XML type name
|
||||||
|
string? elementName = GetXmlRootAttributeElementName(type);
|
||||||
|
if (elementName != null)
|
||||||
|
typeNames.Add(elementName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [.. typeNames];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -58,10 +85,39 @@ namespace SabreTools.Core.Tools
|
|||||||
if (string.IsNullOrEmpty(itemType))
|
if (string.IsNullOrEmpty(itemType))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return AppDomain.CurrentDomain.GetAssemblies()
|
// Loop through all loaded assemblies
|
||||||
.SelectMany(a => a.GetTypes())
|
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
.Where(t => typeof(DatItem).IsAssignableFrom(t) && t.IsClass)
|
{
|
||||||
.FirstOrDefault(t => string.Equals(GetXmlRootAttributeElementName(t), itemType, StringComparison.OrdinalIgnoreCase));
|
// If not all types can be loaded, use the ones that could be
|
||||||
|
List<Type> assemblyTypes = [];
|
||||||
|
try
|
||||||
|
{
|
||||||
|
assemblyTypes = assembly.GetTypes().ToList<Type>();
|
||||||
|
}
|
||||||
|
catch (ReflectionTypeLoadException rtle)
|
||||||
|
{
|
||||||
|
assemblyTypes = rtle.Types.Where(t => t != null)!.ToList<Type>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loop through all types
|
||||||
|
foreach (Type type in assemblyTypes)
|
||||||
|
{
|
||||||
|
// If the type isn't a class or doesn't implement the interface
|
||||||
|
if (!type.IsClass || !typeof(DatItem).IsAssignableFrom(type))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Get the XML type name
|
||||||
|
string? elementName = GetXmlRootAttributeElementName(type);
|
||||||
|
if (elementName == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// If the name matches
|
||||||
|
if (string.Equals(elementName, itemType, StringComparison.OrdinalIgnoreCase))
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a Archive.org file list
|
/// Represents a Archive.org file list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class ArchiveDotOrg : SerializableDatFile<Models.ArchiveDotOrg.Files, Serialization.Files.ArchiveDotOrg, Serialization.CrossModel.ArchiveDotOrg>
|
internal sealed class ArchiveDotOrg : SerializableDatFile<Models.ArchiveDotOrg.Files, Serialization.Deserializers.ArchiveDotOrg, Serialization.Serializers.ArchiveDotOrg, Serialization.CrossModel.ArchiveDotOrg>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor designed for casting a base DatFile
|
/// Constructor designed for casting a base DatFile
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
|
|
||||||
namespace SabreTools.DatFiles.Formats
|
namespace SabreTools.DatFiles.Formats
|
||||||
@@ -7,7 +6,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents an AttractMode DAT
|
/// Represents an AttractMode DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class AttractMode : SerializableDatFile<Models.AttractMode.MetadataFile, Serialization.Files.AttractMode, Serialization.CrossModel.AttractMode>
|
internal sealed class AttractMode : SerializableDatFile<Models.AttractMode.MetadataFile, Serialization.Deserializers.AttractMode, Serialization.Serializers.AttractMode, Serialization.CrossModel.AttractMode>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor designed for casting a base DatFile
|
/// Constructor designed for casting a base DatFile
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.Core.Tools;
|
using SabreTools.Core.Tools;
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
@@ -10,7 +9,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a ClrMamePro DAT
|
/// Represents a ClrMamePro DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class ClrMamePro : SerializableDatFile<Models.ClrMamePro.MetadataFile, Serialization.Files.ClrMamePro, Serialization.CrossModel.ClrMamePro>
|
internal sealed class ClrMamePro : SerializableDatFile<Models.ClrMamePro.MetadataFile, Serialization.Deserializers.ClrMamePro, Serialization.Serializers.ClrMamePro, Serialization.CrossModel.ClrMamePro>
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
@@ -38,7 +37,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Deserialize the input file
|
// Deserialize the input file
|
||||||
var metadataFile = new Serialization.Files.ClrMamePro().Deserialize(filename, this.Quotes);
|
var metadataFile = Serialization.Deserializers.ClrMamePro.DeserializeFile(filename, this.Quotes);
|
||||||
var metadata = new Serialization.CrossModel.ClrMamePro().Serialize(metadataFile);
|
var metadata = new Serialization.CrossModel.ClrMamePro().Serialize(metadataFile);
|
||||||
|
|
||||||
// Convert to the internal format
|
// Convert to the internal format
|
||||||
@@ -181,7 +180,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
// Serialize the input file
|
// Serialize the input file
|
||||||
var metadata = ConvertMetadata(ignoreblanks);
|
var metadata = ConvertMetadata(ignoreblanks);
|
||||||
var metadataFile = new Serialization.CrossModel.ClrMamePro().Deserialize(metadata);
|
var metadataFile = new Serialization.CrossModel.ClrMamePro().Deserialize(metadata);
|
||||||
if (!(new Serialization.Files.ClrMamePro().Serialize(metadataFile, outfile, Quotes)))
|
if (!(Serialization.Serializers.ClrMamePro.SerializeFile(metadataFile, outfile, Quotes)))
|
||||||
{
|
{
|
||||||
logger.Warning($"File '{outfile}' could not be written! See the log for more details.");
|
logger.Warning($"File '{outfile}' could not be written! See the log for more details.");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
|
|
||||||
@@ -8,7 +7,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents parsing and writing of a DosCenter DAT
|
/// Represents parsing and writing of a DosCenter DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class DosCenter : SerializableDatFile<Models.DosCenter.MetadataFile, Serialization.Files.DosCenter, Serialization.CrossModel.DosCenter>
|
internal sealed class DosCenter : SerializableDatFile<Models.DosCenter.MetadataFile, Serialization.Deserializers.DosCenter, Serialization.Serializers.DosCenter, Serialization.CrossModel.DosCenter>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor designed for casting a base DatFile
|
/// Constructor designed for casting a base DatFile
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
|
|
||||||
@@ -8,7 +7,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents parsing and writing of an Everdrive SMDB file
|
/// Represents parsing and writing of an Everdrive SMDB file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class EverdriveSMDB : SerializableDatFile<Models.EverdriveSMDB.MetadataFile, Serialization.Files.EverdriveSMDB, Serialization.CrossModel.EverdriveSMDB>
|
internal sealed class EverdriveSMDB : SerializableDatFile<Models.EverdriveSMDB.MetadataFile, Serialization.Deserializers.EverdriveSMDB, Serialization.Serializers.EverdriveSMDB, Serialization.CrossModel.EverdriveSMDB>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor designed for casting a base DatFile
|
/// Constructor designed for casting a base DatFile
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
|
using SabreTools.Hashing;
|
||||||
|
|
||||||
namespace SabreTools.DatFiles.Formats
|
namespace SabreTools.DatFiles.Formats
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a hashfile such as an SFV, MD5, or SHA-1 file
|
/// Represents a hashfile such as an SFV, MD5, or SHA-1 file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal abstract class Hashfile : SerializableDatFile<Models.Hashfile.Hashfile, Serialization.Files.Hashfile, Serialization.CrossModel.Hashfile>
|
internal abstract class Hashfile : SerializableDatFile<Models.Hashfile.Hashfile, Serialization.Deserializers.Hashfile, Serialization.Serializers.Hashfile, Serialization.CrossModel.Hashfile>
|
||||||
{
|
{
|
||||||
// Private instance variables specific to Hashfile DATs
|
// Private instance variables specific to Hashfile DATs
|
||||||
protected Serialization.Hash _hash;
|
protected HashType _hash;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor designed for casting a base DatFile
|
/// Constructor designed for casting a base DatFile
|
||||||
@@ -29,7 +29,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Deserialize the input file
|
// Deserialize the input file
|
||||||
var hashfile = new Serialization.Files.Hashfile().Deserialize(filename, _hash);
|
var hashfile = Serialization.Deserializers.Hashfile.DeserializeFile(filename, _hash);
|
||||||
var metadata = new Serialization.CrossModel.Hashfile().Serialize(hashfile);
|
var metadata = new Serialization.CrossModel.Hashfile().Serialize(hashfile);
|
||||||
|
|
||||||
// Convert to the internal format
|
// Convert to the internal format
|
||||||
@@ -65,7 +65,11 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
// Check hash linked to specific Hashfile type
|
// Check hash linked to specific Hashfile type
|
||||||
switch (_hash)
|
switch (_hash)
|
||||||
{
|
{
|
||||||
case Serialization.Hash.CRC:
|
case HashType.CRC32:
|
||||||
|
case HashType.CRC32_ISO:
|
||||||
|
case HashType.CRC32_Naive:
|
||||||
|
case HashType.CRC32_Optimized:
|
||||||
|
case HashType.CRC32_Parallel:
|
||||||
switch (datItem)
|
switch (datItem)
|
||||||
{
|
{
|
||||||
case Rom rom:
|
case Rom rom:
|
||||||
@@ -77,7 +81,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Serialization.Hash.MD5:
|
case HashType.MD5:
|
||||||
switch (datItem)
|
switch (datItem)
|
||||||
{
|
{
|
||||||
case Disk disk:
|
case Disk disk:
|
||||||
@@ -97,7 +101,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Serialization.Hash.SHA1:
|
case HashType.SHA1:
|
||||||
switch (datItem)
|
switch (datItem)
|
||||||
{
|
{
|
||||||
case Disk disk:
|
case Disk disk:
|
||||||
@@ -117,7 +121,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Serialization.Hash.SHA256:
|
case HashType.SHA256:
|
||||||
switch (datItem)
|
switch (datItem)
|
||||||
{
|
{
|
||||||
case Media medium:
|
case Media medium:
|
||||||
@@ -133,7 +137,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Serialization.Hash.SHA384:
|
case HashType.SHA384:
|
||||||
switch (datItem)
|
switch (datItem)
|
||||||
{
|
{
|
||||||
case Rom rom:
|
case Rom rom:
|
||||||
@@ -145,7 +149,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Serialization.Hash.SHA512:
|
case HashType.SHA512:
|
||||||
switch (datItem)
|
switch (datItem)
|
||||||
{
|
{
|
||||||
case Rom rom:
|
case Rom rom:
|
||||||
@@ -157,7 +161,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Serialization.Hash.SpamSum:
|
case HashType.SpamSum:
|
||||||
switch (datItem)
|
switch (datItem)
|
||||||
{
|
{
|
||||||
case Media medium:
|
case Media medium:
|
||||||
@@ -188,7 +192,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
// Serialize the input file
|
// Serialize the input file
|
||||||
var metadata = ConvertMetadata(ignoreblanks);
|
var metadata = ConvertMetadata(ignoreblanks);
|
||||||
var hashfile = new Serialization.CrossModel.Hashfile().Deserialize(metadata, _hash);
|
var hashfile = new Serialization.CrossModel.Hashfile().Deserialize(metadata, _hash);
|
||||||
if (!(new Serialization.Files.Hashfile().Serialize(hashfile, outfile, _hash)))
|
if (!(Serialization.Serializers.Hashfile.SerializeFile(hashfile, outfile, _hash)))
|
||||||
{
|
{
|
||||||
logger.Warning($"File '{outfile}' could not be written! See the log for more details.");
|
logger.Warning($"File '{outfile}' could not be written! See the log for more details.");
|
||||||
return false;
|
return false;
|
||||||
@@ -217,7 +221,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public SfvFile(DatFile? datFile)
|
public SfvFile(DatFile? datFile)
|
||||||
: base(datFile)
|
: base(datFile)
|
||||||
{
|
{
|
||||||
_hash = Serialization.Hash.CRC;
|
_hash = HashType.CRC32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +237,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Md5File(DatFile? datFile)
|
public Md5File(DatFile? datFile)
|
||||||
: base(datFile)
|
: base(datFile)
|
||||||
{
|
{
|
||||||
_hash = Serialization.Hash.MD5;
|
_hash = HashType.MD5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +253,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Sha1File(DatFile? datFile)
|
public Sha1File(DatFile? datFile)
|
||||||
: base(datFile)
|
: base(datFile)
|
||||||
{
|
{
|
||||||
_hash = Serialization.Hash.SHA1;
|
_hash = HashType.SHA1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +269,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Sha256File(DatFile? datFile)
|
public Sha256File(DatFile? datFile)
|
||||||
: base(datFile)
|
: base(datFile)
|
||||||
{
|
{
|
||||||
_hash = Serialization.Hash.SHA256;
|
_hash = HashType.SHA256;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,7 +285,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Sha384File(DatFile? datFile)
|
public Sha384File(DatFile? datFile)
|
||||||
: base(datFile)
|
: base(datFile)
|
||||||
{
|
{
|
||||||
_hash = Serialization.Hash.SHA384;
|
_hash = HashType.SHA384;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +301,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Sha512File(DatFile? datFile)
|
public Sha512File(DatFile? datFile)
|
||||||
: base(datFile)
|
: base(datFile)
|
||||||
{
|
{
|
||||||
_hash = Serialization.Hash.SHA512;
|
_hash = HashType.SHA512;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +317,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public SpamSumFile(DatFile? datFile)
|
public SpamSumFile(DatFile? datFile)
|
||||||
: base(datFile)
|
: base(datFile)
|
||||||
{
|
{
|
||||||
_hash = Serialization.Hash.SpamSum;
|
_hash = HashType.SpamSum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
|
|
||||||
@@ -8,7 +7,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a MAME Listrom file
|
/// Represents a MAME Listrom file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class Listrom : SerializableDatFile<Models.Listrom.MetadataFile, Serialization.Files.Listrom, Serialization.CrossModel.Listrom>
|
internal sealed class Listrom : SerializableDatFile<Models.Listrom.MetadataFile, Serialization.Deserializers.Listrom, Serialization.Serializers.Listrom, Serialization.CrossModel.Listrom>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor designed for casting a base DatFile
|
/// Constructor designed for casting a base DatFile
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.Core.Tools;
|
using SabreTools.Core.Tools;
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
@@ -10,7 +9,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a MAME/M1 XML DAT
|
/// Represents a MAME/M1 XML DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class Listxml : SerializableDatFile<Models.Listxml.Mame, Serialization.Files.Listxml, Serialization.CrossModel.Listxml>
|
internal sealed class Listxml : SerializableDatFile<Models.Listxml.Mame, Serialization.Deserializers.Listxml, Serialization.Serializers.Listxml, Serialization.CrossModel.Listxml>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DTD for original MAME XML DATs
|
/// DTD for original MAME XML DATs
|
||||||
@@ -193,11 +192,11 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Deserialize the input file
|
// Deserialize the input file
|
||||||
var mame = new Serialization.Files.Listxml().Deserialize(filename);
|
var mame = Serialization.Deserializers.Listxml.DeserializeFile(filename);
|
||||||
Models.Metadata.MetadataFile? metadata;
|
Models.Metadata.MetadataFile? metadata;
|
||||||
if (mame == null)
|
if (mame == null)
|
||||||
{
|
{
|
||||||
var m1 = new Serialization.Files.M1().Deserialize(filename);
|
var m1 = Serialization.Deserializers.M1.DeserializeFile(filename);
|
||||||
metadata = new Serialization.CrossModel.M1().Serialize(m1);
|
metadata = new Serialization.CrossModel.M1().Serialize(m1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.Core.Tools;
|
using SabreTools.Core.Tools;
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
@@ -10,7 +9,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a Logiqx-derived DAT
|
/// Represents a Logiqx-derived DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class Logiqx : SerializableDatFile<Models.Logiqx.Datafile, Serialization.Files.Logiqx, Serialization.CrossModel.Logiqx>
|
internal sealed class Logiqx : SerializableDatFile<Models.Logiqx.Datafile, Serialization.Deserializers.Logiqx, Serialization.Serializers.Logiqx, Serialization.CrossModel.Logiqx>
|
||||||
{
|
{
|
||||||
// Private instance variables specific to Logiqx DATs
|
// Private instance variables specific to Logiqx DATs
|
||||||
private readonly bool _deprecated;
|
private readonly bool _deprecated;
|
||||||
@@ -356,12 +355,13 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
var metadata = ConvertMetadata(ignoreblanks);
|
var metadata = ConvertMetadata(ignoreblanks);
|
||||||
var datafile = new Serialization.CrossModel.Logiqx().Deserialize(metadata);
|
var datafile = new Serialization.CrossModel.Logiqx().Deserialize(metadata);
|
||||||
|
|
||||||
|
// TODO: Reenable doctype writing
|
||||||
// Only write the doctype if we don't have No-Intro data
|
// Only write the doctype if we don't have No-Intro data
|
||||||
bool success;
|
bool success;
|
||||||
if (string.IsNullOrEmpty(Header.GetStringFieldValue(Models.Metadata.Header.IdKey)))
|
if (string.IsNullOrEmpty(Header.GetStringFieldValue(Models.Metadata.Header.IdKey)))
|
||||||
success = new Serialization.Files.Logiqx().SerializeToFileWithDocType(datafile!, outfile);
|
success = Serialization.Serializers.Logiqx.SerializeFile(datafile!, outfile);
|
||||||
else
|
else
|
||||||
success = new Serialization.Files.Logiqx().Serialize(datafile, outfile);
|
success = Serialization.Serializers.Logiqx.SerializeFile(datafile, outfile);
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
|
|
||||||
@@ -8,7 +7,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents an OfflineList XML DAT
|
/// Represents an OfflineList XML DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class OfflineList : SerializableDatFile<Models.OfflineList.Dat, Serialization.Files.OfflineList, Serialization.CrossModel.OfflineList>
|
internal sealed class OfflineList : SerializableDatFile<Models.OfflineList.Dat, Serialization.Deserializers.OfflineList, Serialization.Serializers.OfflineList, Serialization.CrossModel.OfflineList>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor designed for casting a base DatFile
|
/// Constructor designed for casting a base DatFile
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
|
|
||||||
@@ -8,7 +7,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents an openMSX softawre list XML DAT
|
/// Represents an openMSX softawre list XML DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class OpenMSX : SerializableDatFile<Models.OpenMSX.SoftwareDb, Serialization.Files.OpenMSX, Serialization.CrossModel.OpenMSX>
|
internal sealed class OpenMSX : SerializableDatFile<Models.OpenMSX.SoftwareDb, Serialization.Deserializers.OpenMSX, Serialization.Serializers.OpenMSX, Serialization.CrossModel.OpenMSX>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DTD for original openMSX DATs
|
/// DTD for original openMSX DATs
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
|
|
||||||
@@ -8,7 +7,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a RomCenter INI file
|
/// Represents a RomCenter INI file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class RomCenter : SerializableDatFile<Models.RomCenter.MetadataFile, Serialization.Files.RomCenter, Serialization.CrossModel.RomCenter>
|
internal sealed class RomCenter : SerializableDatFile<Models.RomCenter.MetadataFile, Serialization.Deserializers.RomCenter, Serialization.Serializers.RomCenter, Serialization.CrossModel.RomCenter>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor designed for casting a base DatFile
|
/// Constructor designed for casting a base DatFile
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
|
|
||||||
@@ -9,7 +8,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a value-separated DAT
|
/// Represents a value-separated DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal abstract class SeparatedValue : SerializableDatFile<Models.SeparatedValue.MetadataFile, Serialization.Files.SeparatedValue, Serialization.CrossModel.SeparatedValue>
|
internal abstract class SeparatedValue : SerializableDatFile<Models.SeparatedValue.MetadataFile, Serialization.Deserializers.SeparatedValue, Serialization.Serializers.SeparatedValue, Serialization.CrossModel.SeparatedValue>
|
||||||
{
|
{
|
||||||
// Private instance variables specific to Hashfile DATs
|
// Private instance variables specific to Hashfile DATs
|
||||||
protected char _delim;
|
protected char _delim;
|
||||||
@@ -29,7 +28,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Deserialize the input file
|
// Deserialize the input file
|
||||||
var metadataFile = new Serialization.Files.SeparatedValue().Deserialize(filename, _delim);
|
var metadataFile = Serialization.Deserializers.SeparatedValue.DeserializeFile(filename, _delim);
|
||||||
var metadata = new Serialization.CrossModel.SeparatedValue().Serialize(metadataFile);
|
var metadata = new Serialization.CrossModel.SeparatedValue().Serialize(metadataFile);
|
||||||
|
|
||||||
// Convert to the internal format
|
// Convert to the internal format
|
||||||
@@ -101,7 +100,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
// Serialize the input file
|
// Serialize the input file
|
||||||
var metadata = ConvertMetadata(ignoreblanks);
|
var metadata = ConvertMetadata(ignoreblanks);
|
||||||
var metadataFile = new Serialization.CrossModel.SeparatedValue().Deserialize(metadata);
|
var metadataFile = new Serialization.CrossModel.SeparatedValue().Deserialize(metadata);
|
||||||
if (!(new Serialization.Files.SeparatedValue().Serialize(metadataFile, outfile, _delim)))
|
if (!(Serialization.Serializers.SeparatedValue.SerializeFile(metadataFile, outfile, _delim)))
|
||||||
{
|
{
|
||||||
logger.Warning($"File '{outfile}' could not be written! See the log for more details.");
|
logger.Warning($"File '{outfile}' could not be written! See the log for more details.");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
|
|
||||||
@@ -9,7 +8,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents parsing and writing of a SoftwareList
|
/// Represents parsing and writing of a SoftwareList
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class SoftwareList : SerializableDatFile<Models.SoftwareList.SoftwareList, Serialization.Files.SoftwareList, Serialization.CrossModel.SoftwareList>
|
internal sealed class SoftwareList : SerializableDatFile<Models.SoftwareList.SoftwareList, Serialization.Deserializers.SoftwareList, Serialization.Serializers.SoftwareList, Serialization.CrossModel.SoftwareList>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DTD for original MAME Software List DATs
|
/// DTD for original MAME Software List DATs
|
||||||
|
|||||||
@@ -29,10 +29,10 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="SabreTools.Hashing" Version="1.2.0" />
|
<PackageReference Include="SabreTools.Hashing" Version="1.2.0" />
|
||||||
<PackageReference Include="SabreTools.IO" Version="1.3.2" />
|
<PackageReference Include="SabreTools.IO" Version="1.4.0" />
|
||||||
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
||||||
<PackageReference Include="SabreTools.Models" Version="1.4.0" />
|
<PackageReference Include="SabreTools.Models" Version="1.4.5" />
|
||||||
<PackageReference Include="SabreTools.Serialization" Version="1.4.1" />
|
<PackageReference Include="SabreTools.Serialization" Version="1.5.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ namespace SabreTools.DatFiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a DAT that can be serialized
|
/// Represents a DAT that can be serialized
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">Base internal model for the DAT type</typeparam>
|
/// <typeparam name="TModel">Base internal model for the DAT type</typeparam>
|
||||||
/// <typeparam name="U">IFileSerializer type to use for conversion</typeparam>
|
/// <typeparam name="TFileDeserializer">IFileDeserializer type to use for conversion</typeparam>
|
||||||
/// <typeparam name="V">IModelSerializer for cross-model serialization</typeparam>
|
/// <typeparam name="TFileSerializer">IFileSerializer type to use for conversion</typeparam>
|
||||||
public abstract class SerializableDatFile<T, U, V> : DatFile
|
/// <typeparam name="TModelSerializer">IModelSerializer for cross-model serialization</typeparam>
|
||||||
where U : IFileSerializer<T>
|
public abstract class SerializableDatFile<TModel, TFileDeserializer, TFileSerializer, TModelSerializer> : DatFile
|
||||||
where V : IModelSerializer<T, MetadataFile>
|
where TFileDeserializer : IFileDeserializer<TModel>
|
||||||
|
where TFileSerializer : IFileSerializer<TModel>
|
||||||
|
where TModelSerializer : IModelSerializer<TModel, MetadataFile>
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
protected SerializableDatFile(DatFile? datFile) : base(datFile) { }
|
protected SerializableDatFile(DatFile? datFile) : base(datFile) { }
|
||||||
@@ -23,8 +25,8 @@ namespace SabreTools.DatFiles
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Deserialize the input file in two steps
|
// Deserialize the input file in two steps
|
||||||
var specificFormat = Activator.CreateInstance<U>().Deserialize(filename);
|
var specificFormat = Activator.CreateInstance<TFileDeserializer>().Deserialize(filename);
|
||||||
var internalFormat = Activator.CreateInstance<V>().Serialize(specificFormat);
|
var internalFormat = Activator.CreateInstance<TModelSerializer>().Serialize(specificFormat);
|
||||||
|
|
||||||
// Convert to the internal format
|
// Convert to the internal format
|
||||||
ConvertMetadata(internalFormat, filename, indexId, keep, statsOnly);
|
ConvertMetadata(internalFormat, filename, indexId, keep, statsOnly);
|
||||||
@@ -45,8 +47,8 @@ namespace SabreTools.DatFiles
|
|||||||
|
|
||||||
// Serialize the input file in two steps
|
// Serialize the input file in two steps
|
||||||
var internalFormat = ConvertMetadata(ignoreblanks);
|
var internalFormat = ConvertMetadata(ignoreblanks);
|
||||||
var specificFormat = Activator.CreateInstance<V>().Deserialize(internalFormat);
|
var specificFormat = Activator.CreateInstance<TModelSerializer>().Deserialize(internalFormat);
|
||||||
if (!Activator.CreateInstance<U>().Serialize(specificFormat, outfile))
|
if (!Activator.CreateInstance<TFileSerializer>().Serialize(specificFormat, outfile))
|
||||||
{
|
{
|
||||||
logger.Warning($"File '{outfile}' could not be written! See the log for more details.");
|
logger.Warning($"File '{outfile}' could not be written! See the log for more details.");
|
||||||
return false;
|
return false;
|
||||||
@@ -71,8 +73,8 @@ namespace SabreTools.DatFiles
|
|||||||
|
|
||||||
// Serialize the input file in two steps
|
// Serialize the input file in two steps
|
||||||
var internalFormat = ConvertMetadataDB(ignoreblanks);
|
var internalFormat = ConvertMetadataDB(ignoreblanks);
|
||||||
var specificFormat = Activator.CreateInstance<V>().Deserialize(internalFormat);
|
var specificFormat = Activator.CreateInstance<TModelSerializer>().Deserialize(internalFormat);
|
||||||
if (!Activator.CreateInstance<U>().Serialize(specificFormat, outfile))
|
if (!Activator.CreateInstance<TFileSerializer>().Serialize(specificFormat, outfile))
|
||||||
{
|
{
|
||||||
logger.Warning($"File '{outfile}' could not be written! See the log for more details.");
|
logger.Warning($"File '{outfile}' could not be written! See the log for more details.");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
||||||
<PackageReference Include="SabreTools.Models" Version="1.4.0" />
|
<PackageReference Include="SabreTools.Models" Version="1.4.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ using System.Threading;
|
|||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
#endif
|
||||||
|
#if NET452_OR_GREATER || NETCOREAPP
|
||||||
using SabreTools.Core;
|
using SabreTools.Core;
|
||||||
|
#endif
|
||||||
using SabreTools.Core.Tools;
|
using SabreTools.Core.Tools;
|
||||||
using SabreTools.DatFiles;
|
using SabreTools.DatFiles;
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
@@ -13,7 +15,7 @@ using SabreTools.DatItems.Formats;
|
|||||||
using SabreTools.FileTypes;
|
using SabreTools.FileTypes;
|
||||||
using SabreTools.FileTypes.Archives;
|
using SabreTools.FileTypes.Archives;
|
||||||
using SabreTools.Hashing;
|
using SabreTools.Hashing;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.Logging;
|
using SabreTools.Logging;
|
||||||
|
|
||||||
namespace SabreTools.DatTools
|
namespace SabreTools.DatTools
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using SabreTools.Core.Tools;
|
|||||||
using SabreTools.DatFiles;
|
using SabreTools.DatFiles;
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO;
|
||||||
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.Logging;
|
using SabreTools.Logging;
|
||||||
|
|
||||||
namespace SabreTools.DatTools
|
namespace SabreTools.DatTools
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ using SabreTools.DatItems.Formats;
|
|||||||
using SabreTools.FileTypes;
|
using SabreTools.FileTypes;
|
||||||
using SabreTools.FileTypes.Archives;
|
using SabreTools.FileTypes.Archives;
|
||||||
using SabreTools.Hashing;
|
using SabreTools.Hashing;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.Logging;
|
using SabreTools.Logging;
|
||||||
using SabreTools.Skippers;
|
using SabreTools.Skippers;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="SabreTools.IO" Version="1.3.2" />
|
<PackageReference Include="SabreTools.IO" Version="1.4.0" />
|
||||||
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
||||||
<PackageReference Include="SabreTools.Skippers" Version="1.1.2" />
|
<PackageReference Include="SabreTools.Skippers" Version="1.1.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using SabreTools.Core.Tools;
|
|||||||
using SabreTools.DatFiles;
|
using SabreTools.DatFiles;
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.Logging;
|
using SabreTools.Logging;
|
||||||
using SabreTools.Matching;
|
using SabreTools.Matching;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
|||||||
using SabreTools.Core;
|
using SabreTools.Core;
|
||||||
using SabreTools.DatFiles;
|
using SabreTools.DatFiles;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO;
|
||||||
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.Logging;
|
using SabreTools.Logging;
|
||||||
using SabreTools.Reports;
|
using SabreTools.Reports;
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
#endif
|
||||||
using SabreTools.Core;
|
using SabreTools.Core;
|
||||||
using SabreTools.DatFiles;
|
using SabreTools.DatFiles;
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.Logging;
|
using SabreTools.Logging;
|
||||||
using SabreTools.Reports;
|
using SabreTools.Reports;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.Matching;
|
using SabreTools.Matching;
|
||||||
|
|
||||||
namespace SabreTools.FileTypes.Aaru
|
namespace SabreTools.FileTypes.Aaru
|
||||||
|
|||||||
@@ -6,10 +6,9 @@ using System.Text.RegularExpressions;
|
|||||||
using Compress;
|
using Compress;
|
||||||
using Compress.gZip;
|
using Compress.gZip;
|
||||||
using Compress.Support.Compression.Deflate;
|
using Compress.Support.Compression.Deflate;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.Core.Tools;
|
using SabreTools.Core.Tools;
|
||||||
using SabreTools.Hashing;
|
using SabreTools.Hashing;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
|
|
||||||
namespace SabreTools.FileTypes.Archives
|
namespace SabreTools.FileTypes.Archives
|
||||||
{
|
{
|
||||||
@@ -295,7 +294,7 @@ namespace SabreTools.FileTypes.Archives
|
|||||||
public override bool IsTorrent()
|
public override bool IsTorrent()
|
||||||
{
|
{
|
||||||
// Check for the file existing first
|
// Check for the file existing first
|
||||||
if (!File.Exists(this.Filename))
|
if (this.Filename == null || !File.Exists(this.Filename))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
string datum = Path.GetFileName(this.Filename).ToLowerInvariant();
|
string datum = Path.GetFileName(this.Filename).ToLowerInvariant();
|
||||||
@@ -356,7 +355,7 @@ namespace SabreTools.FileTypes.Archives
|
|||||||
public BaseFile? GetTorrentGZFileInfo()
|
public BaseFile? GetTorrentGZFileInfo()
|
||||||
{
|
{
|
||||||
// Check for the file existing first
|
// Check for the file existing first
|
||||||
if (!File.Exists(this.Filename))
|
if (this.Filename == null || !File.Exists(this.Filename))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
string datum = Path.GetFileName(this.Filename).ToLowerInvariant();
|
string datum = Path.GetFileName(this.Filename).ToLowerInvariant();
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ namespace SabreTools.FileTypes.Archives
|
|||||||
SharpCompress.Archives.Rar.RarArchive ra = SharpCompress.Archives.Rar.RarArchive.Open(this.Filename, new ReaderOptions { LeaveStreamOpen = false, });
|
SharpCompress.Archives.Rar.RarArchive ra = SharpCompress.Archives.Rar.RarArchive.Open(this.Filename, new ReaderOptions { LeaveStreamOpen = false, });
|
||||||
foreach (RarArchiveEntry entry in ra.Entries)
|
foreach (RarArchiveEntry entry in ra.Entries)
|
||||||
{
|
{
|
||||||
if (entry != null && !entry.IsDirectory && entry.Key.Contains(entryName))
|
if (entry?.Key != null && !entry.IsDirectory && entry.Key.Contains(entryName))
|
||||||
{
|
{
|
||||||
// Write the file out
|
// Write the file out
|
||||||
realEntry = entry.Key;
|
realEntry = entry.Key;
|
||||||
@@ -248,19 +248,19 @@ namespace SabreTools.FileTypes.Archives
|
|||||||
string? lastRarEntry = null;
|
string? lastRarEntry = null;
|
||||||
foreach (RarArchiveEntry entry in rarEntries)
|
foreach (RarArchiveEntry entry in rarEntries)
|
||||||
{
|
{
|
||||||
if (entry != null)
|
if (entry?.Key == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// If the current is a superset of last, we skip it
|
||||||
|
if (lastRarEntry != null && lastRarEntry.StartsWith(entry.Key))
|
||||||
{
|
{
|
||||||
// If the current is a superset of last, we skip it
|
// No-op
|
||||||
if (lastRarEntry != null && lastRarEntry.StartsWith(entry.Key))
|
}
|
||||||
{
|
// If the entry is a directory, we add it
|
||||||
// No-op
|
else if (entry.IsDirectory)
|
||||||
}
|
{
|
||||||
// If the entry is a directory, we add it
|
empties.Add(entry.Key);
|
||||||
else if (entry.IsDirectory)
|
lastRarEntry = entry.Key;
|
||||||
{
|
|
||||||
empties.Add(entry.Key);
|
|
||||||
lastRarEntry = entry.Key;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ namespace SabreTools.FileTypes.Archives
|
|||||||
TarArchive ta = TarArchive.Open(this.Filename!, new ReaderOptions { LeaveStreamOpen = false, });
|
TarArchive ta = TarArchive.Open(this.Filename!, new ReaderOptions { LeaveStreamOpen = false, });
|
||||||
foreach (TarArchiveEntry entry in ta.Entries)
|
foreach (TarArchiveEntry entry in ta.Entries)
|
||||||
{
|
{
|
||||||
if (entry != null && !entry.IsDirectory && entry.Key.Contains(entryName))
|
if (entry?.Key != null && !entry.IsDirectory && entry.Key.Contains(entryName))
|
||||||
{
|
{
|
||||||
// Write the file out
|
// Write the file out
|
||||||
realEntry = entry.Key;
|
realEntry = entry.Key;
|
||||||
@@ -237,19 +237,19 @@ namespace SabreTools.FileTypes.Archives
|
|||||||
string? lastTarEntry = null;
|
string? lastTarEntry = null;
|
||||||
foreach (TarArchiveEntry entry in tarEntries)
|
foreach (TarArchiveEntry entry in tarEntries)
|
||||||
{
|
{
|
||||||
if (entry != null)
|
if (entry?.Key == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// If the current is a superset of last, we skip it
|
||||||
|
if (lastTarEntry != null && lastTarEntry.StartsWith(entry.Key))
|
||||||
{
|
{
|
||||||
// If the current is a superset of last, we skip it
|
// No-op
|
||||||
if (lastTarEntry != null && lastTarEntry.StartsWith(entry.Key))
|
}
|
||||||
{
|
// If the entry is a directory, we add it
|
||||||
// No-op
|
else if (entry.IsDirectory)
|
||||||
}
|
{
|
||||||
// If the entry is a directory, we add it
|
empties.Add(entry.Key);
|
||||||
else if (entry.IsDirectory)
|
lastTarEntry = entry.Key;
|
||||||
{
|
|
||||||
empties.Add(entry.Key);
|
|
||||||
lastTarEntry = entry.Key;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,7 +315,7 @@ namespace SabreTools.FileTypes.Archives
|
|||||||
{
|
{
|
||||||
// Get temporary date-time if possible
|
// Get temporary date-time if possible
|
||||||
DateTime? usableDate = null;
|
DateTime? usableDate = null;
|
||||||
if (UseDates && !string.IsNullOrEmpty(baseFile.Date) && DateTime.TryParse(baseFile.Date.Replace('\\', '/'), out DateTime dt))
|
if (UseDates && !string.IsNullOrEmpty(baseFile.Date) && DateTime.TryParse(baseFile.Date!.Replace('\\', '/'), out DateTime dt))
|
||||||
usableDate = dt;
|
usableDate = dt;
|
||||||
|
|
||||||
// Copy the input stream to the output
|
// Copy the input stream to the output
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.Core.Tools;
|
using SabreTools.Core.Tools;
|
||||||
using SabreTools.Hashing;
|
using SabreTools.Hashing;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
#if NET462_OR_GREATER || NETCOREAPP
|
#if NET462_OR_GREATER || NETCOREAPP
|
||||||
using SharpCompress.Compressors.Xz;
|
using SharpCompress.Compressors.Xz;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
using System.Collections.Generic;
|
using System.IO;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
#endif
|
|
||||||
using Compress.Support.Compression.LZMA;
|
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.Core.Tools;
|
using SabreTools.Core.Tools;
|
||||||
using SabreTools.FileTypes.Aaru;
|
using SabreTools.FileTypes.Aaru;
|
||||||
using SabreTools.FileTypes.CHD;
|
using SabreTools.FileTypes.CHD;
|
||||||
using SabreTools.Hashing;
|
using SabreTools.Hashing;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.Logging;
|
|
||||||
using SabreTools.Matching;
|
using SabreTools.Matching;
|
||||||
using SabreTools.Skippers;
|
using SabreTools.Skippers;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO.Extensions;
|
||||||
|
|
||||||
namespace SabreTools.FileTypes.CHD
|
namespace SabreTools.FileTypes.CHD
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.IO;
|
|
||||||
|
|
||||||
namespace SabreTools.FileTypes.CHD
|
namespace SabreTools.FileTypes.CHD
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.IO;
|
|
||||||
|
|
||||||
namespace SabreTools.FileTypes.CHD
|
namespace SabreTools.FileTypes.CHD
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.IO;
|
|
||||||
|
|
||||||
namespace SabreTools.FileTypes.CHD
|
namespace SabreTools.FileTypes.CHD
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.IO;
|
|
||||||
|
|
||||||
namespace SabreTools.FileTypes.CHD
|
namespace SabreTools.FileTypes.CHD
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.IO;
|
|
||||||
|
|
||||||
namespace SabreTools.FileTypes.CHD
|
namespace SabreTools.FileTypes.CHD
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using SabreTools.Core.Tools;
|
using SabreTools.Core.Tools;
|
||||||
using SabreTools.FileTypes.Archives;
|
using SabreTools.FileTypes.Archives;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO;
|
||||||
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.Logging;
|
using SabreTools.Logging;
|
||||||
|
|
||||||
namespace SabreTools.FileTypes
|
namespace SabreTools.FileTypes
|
||||||
|
|||||||
@@ -27,14 +27,14 @@
|
|||||||
|
|
||||||
<!-- Support for old .NET versions -->
|
<!-- Support for old .NET versions -->
|
||||||
<ItemGroup Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))">
|
<ItemGroup Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))">
|
||||||
<PackageReference Include="SharpCompress" Version="0.36.0" />
|
<PackageReference Include="SharpCompress" Version="0.37.0" />
|
||||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
|
||||||
<PackageReference Include="ZstdSharp.Port" Version="0.7.6" />
|
<PackageReference Include="ZstdSharp.Port" Version="0.7.6" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="SabreTools.Hashing" Version="1.2.0" />
|
<PackageReference Include="SabreTools.Hashing" Version="1.2.0" />
|
||||||
<PackageReference Include="SabreTools.IO" Version="1.3.2" />
|
<PackageReference Include="SabreTools.IO" Version="1.4.0" />
|
||||||
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
||||||
<PackageReference Include="SabreTools.Skippers" Version="1.1.2" />
|
<PackageReference Include="SabreTools.Skippers" Version="1.1.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="SabreTools.IO" Version="1.3.2" />
|
<PackageReference Include="SabreTools.IO" Version="1.4.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.IO;
|
|
||||||
|
|
||||||
namespace SabreTools.Logging
|
namespace SabreTools.Logging
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="SabreTools.IO" Version="1.3.2" />
|
<PackageReference Include="SabreTools.IO" Version="1.4.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ namespace SabreTools.Test.DatTools
|
|||||||
{
|
{
|
||||||
public class ParserTests
|
public class ParserTests
|
||||||
{
|
{
|
||||||
[Theory]
|
// TODO: Disabled until Serialization fixed
|
||||||
|
//[Theory]
|
||||||
[InlineData(null, (DatFormat)0x00, 0)]
|
[InlineData(null, (DatFormat)0x00, 0)]
|
||||||
[InlineData("test-logiqx.xml", DatFormat.Logiqx, 6)]
|
[InlineData("test-logiqx.xml", DatFormat.Logiqx, 6)]
|
||||||
//[InlineData(null, DatFormat.LogiqxDeprecated, 0)] // Not parsed separately
|
//[InlineData(null, DatFormat.LogiqxDeprecated, 0)] // Not parsed separately
|
||||||
|
|||||||
@@ -32,10 +32,10 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||||
<PackageReference Include="SabreTools.Models" Version="1.4.0" />
|
<PackageReference Include="SabreTools.Models" Version="1.4.5" />
|
||||||
<PackageReference Include="SabreTools.Serialization" Version="1.4.1" />
|
<PackageReference Include="SabreTools.Serialization" Version="1.5.5" />
|
||||||
<PackageReference Include="xunit" Version="2.7.0" />
|
<PackageReference Include="xunit" Version="2.7.1" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,88 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace SabreTools.Test.Parser
|
|
||||||
{
|
|
||||||
public class SerializationTests
|
|
||||||
{
|
|
||||||
[Fact]
|
|
||||||
public void OpenMSXSeserializeTest()
|
|
||||||
{
|
|
||||||
// Create the object for serialization
|
|
||||||
var dat = GenerateOpenMSX();
|
|
||||||
|
|
||||||
// Deserialize the file
|
|
||||||
var stream = new Serialization.Streams.OpenMSX().Serialize(dat) as System.IO.MemoryStream;
|
|
||||||
|
|
||||||
// Validate the values
|
|
||||||
Assert.NotNull(stream);
|
|
||||||
byte[] hash = System.Security.Cryptography.SHA1.Create().ComputeHash(stream.GetBuffer());
|
|
||||||
string hashstr = BitConverter.ToString(hash).Replace("-", string.Empty);
|
|
||||||
Assert.Equal("268940391C107ABE67E804BC5479E40B5FF68B34", hashstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Payload Generators
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generate a consistent OpenMSX SoftwareDb for testing
|
|
||||||
/// </summary>
|
|
||||||
private static Models.OpenMSX.SoftwareDb GenerateOpenMSX()
|
|
||||||
{
|
|
||||||
var original = new Models.OpenMSX.Original
|
|
||||||
{
|
|
||||||
Value = "false",
|
|
||||||
Content = "Original Name",
|
|
||||||
};
|
|
||||||
|
|
||||||
var rom = new Models.OpenMSX.Rom
|
|
||||||
{
|
|
||||||
Start = "0x0000",
|
|
||||||
Type = "Game",
|
|
||||||
Hash = "da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
|
||||||
Remark = "Comment",
|
|
||||||
};
|
|
||||||
|
|
||||||
var megaRom = new Models.OpenMSX.MegaRom
|
|
||||||
{
|
|
||||||
Start = "0x1000",
|
|
||||||
Type = "Software",
|
|
||||||
Hash = "da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
|
||||||
Remark = "Comment",
|
|
||||||
};
|
|
||||||
|
|
||||||
var sccPlusCart = new Models.OpenMSX.SCCPlusCart
|
|
||||||
{
|
|
||||||
Start = "0x2000",
|
|
||||||
Type = "Utility",
|
|
||||||
Hash = "da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
|
||||||
Remark = "Comment",
|
|
||||||
};
|
|
||||||
|
|
||||||
var dump = new Models.OpenMSX.Dump[]
|
|
||||||
{
|
|
||||||
new Models.OpenMSX.Dump { Original = original, Rom = rom },
|
|
||||||
new Models.OpenMSX.Dump { Rom = megaRom },
|
|
||||||
new Models.OpenMSX.Dump { Rom = sccPlusCart },
|
|
||||||
};
|
|
||||||
|
|
||||||
var software = new Models.OpenMSX.Software
|
|
||||||
{
|
|
||||||
Title = "Software Title",
|
|
||||||
GenMSXID = "00000", // Not required
|
|
||||||
System = "MSX 2",
|
|
||||||
Company = "Imaginary Company, Inc.",
|
|
||||||
Year = "19xx",
|
|
||||||
Country = "Imaginaria",
|
|
||||||
Dump = dump,
|
|
||||||
};
|
|
||||||
|
|
||||||
return new Models.OpenMSX.SoftwareDb
|
|
||||||
{
|
|
||||||
Timestamp = "1234567890",
|
|
||||||
Software = new Models.OpenMSX.Software[] { software },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,6 +6,7 @@ using SabreTools.DatItems;
|
|||||||
using SabreTools.DatTools;
|
using SabreTools.DatTools;
|
||||||
using SabreTools.Help;
|
using SabreTools.Help;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO;
|
||||||
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.Logging;
|
using SabreTools.Logging;
|
||||||
|
|
||||||
namespace SabreTools.Features
|
namespace SabreTools.Features
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using SabreTools.DatFiles;
|
|||||||
using SabreTools.DatTools;
|
using SabreTools.DatTools;
|
||||||
using SabreTools.Help;
|
using SabreTools.Help;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO;
|
||||||
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.Logging;
|
using SabreTools.Logging;
|
||||||
|
|
||||||
namespace SabreTools.Features
|
namespace SabreTools.Features
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.3" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user