Fix everything

This commit is contained in:
Matt Nadareski
2026-03-24 19:17:25 -04:00
parent e11a08b587
commit 8f49e190d8
206 changed files with 1202 additions and 1647 deletions

View File

@@ -2,7 +2,7 @@ using System.IO;
using System.Text;
using SabreTools.Data.Models.AttractMode;
using SabreTools.IO.Extensions;
using SabreTools.IO.Writers;
using SabreTools.Text.SeparatedValue;
#pragma warning disable CA1822 // Mark members as static
namespace SabreTools.Serialization.Writers
@@ -101,7 +101,7 @@ namespace SabreTools.Serialization.Writers
return false;
using var fs = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None);
stream.CopyTo(fs);
stream.BlockCopy(fs);
fs.Flush();
return true;
@@ -124,7 +124,7 @@ namespace SabreTools.Serialization.Writers
// Setup the writer and output
var stream = new MemoryStream();
var writer = new SeparatedValueWriter(stream, Encoding.UTF8)
var writer = new Writer(stream, Encoding.UTF8)
{
Separator = ';',
Quotes = false,
@@ -146,9 +146,9 @@ namespace SabreTools.Serialization.Writers
/// Write rows information to the current writer
/// </summary>
/// <param name="rows">Array of Row objects representing the rows information</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
/// <param name="writer">Writer representing the output</param>
/// <param name="longHeader">True if the long variant of the row should be written, false otherwise</param>
private static void WriteRows(Row[]? rows, SeparatedValueWriter writer, bool longHeader)
private static void WriteRows(Row[]? rows, Writer writer, bool longHeader)
{
// If the games information is missing, we can't do anything
if (rows is null || rows.Length == 0)

View File

@@ -1,4 +1,5 @@
using System.IO;
using SabreTools.IO.Extensions;
namespace SabreTools.Serialization.Writers
{
@@ -47,7 +48,7 @@ namespace SabreTools.Serialization.Writers
return false;
using var fs = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None);
stream.CopyTo(fs);
stream.BlockCopy(fs);
fs.Flush();
return true;

View File

@@ -2,7 +2,7 @@ using System.IO;
using System.Text;
using SabreTools.Data.Models.ClrMamePro;
using SabreTools.IO.Extensions;
using SabreTools.IO.Writers;
using SabreTools.Text.ClrMamePro;
#pragma warning disable CA1822 // Mark members as static
namespace SabreTools.Serialization.Writers
@@ -46,7 +46,7 @@ namespace SabreTools.Serialization.Writers
return false;
using var fs = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None);
stream.CopyTo(fs);
stream.BlockCopy(fs);
fs.Flush();
return true;
@@ -69,7 +69,7 @@ namespace SabreTools.Serialization.Writers
// Setup the writer and output
var stream = new MemoryStream();
var writer = new ClrMameProWriter(stream, Encoding.UTF8) { Quotes = quotes };
var writer = new Writer(stream, Encoding.UTF8) { Quotes = quotes };
// Write the header, if it exists
WriteHeader(obj.ClrMamePro, writer);
@@ -89,8 +89,8 @@ namespace SabreTools.Serialization.Writers
/// Write header information to the current writer
/// </summary>
/// <param name="header">ClrMamePro representing the header information</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteHeader(Data.Models.ClrMamePro.ClrMamePro? header, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteHeader(Data.Models.ClrMamePro.ClrMamePro? header, Writer writer)
{
// If the header information is missing, we can't do anything
if (header is null)
@@ -122,8 +122,8 @@ namespace SabreTools.Serialization.Writers
/// Write games information to the current writer
/// </summary>
/// <param name="games">Array of GameBase objects representing the games information</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteGames(GameBase[]? games, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteGames(GameBase[]? games, Writer writer)
{
// If the games information is missing, we can't do anything
if (games is null || games.Length == 0)
@@ -144,8 +144,8 @@ namespace SabreTools.Serialization.Writers
/// Write game information to the current writer
/// </summary>
/// <param name="game">GameBase object representing the game information</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteGame(GameBase game, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteGame(GameBase game, Writer writer)
{
// If the game information is missing, we can't do anything
if (game is null)
@@ -203,8 +203,8 @@ namespace SabreTools.Serialization.Writers
/// Write releases information to the current writer
/// </summary>
/// <param name="releases">Array of Release objects to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteReleases(Release[]? releases, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteReleases(Release[]? releases, Writer writer)
{
// If the array is missing, we can't do anything
if (releases is null)
@@ -226,8 +226,8 @@ namespace SabreTools.Serialization.Writers
/// Write biossets information to the current writer
/// </summary>
/// <param name="biossets">Array of BiosSet objects to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteBiosSets(BiosSet[]? biossets, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteBiosSets(BiosSet[]? biossets, Writer writer)
{
// If the array is missing, we can't do anything
if (biossets is null)
@@ -247,8 +247,8 @@ namespace SabreTools.Serialization.Writers
/// Write roms information to the current writer
/// </summary>
/// <param name="roms">Array of Rom objects to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteRoms(Rom[]? roms, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteRoms(Rom[]? roms, Writer writer)
{
// If the array is missing, we can't do anything
if (roms is null)
@@ -292,8 +292,8 @@ namespace SabreTools.Serialization.Writers
/// Write disks information to the current writer
/// </summary>
/// <param name="disks">Array of Disk objects to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteDisks(Disk[]? disks, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteDisks(Disk[]? disks, Writer writer)
{
// If the array is missing, we can't do anything
if (disks is null)
@@ -316,8 +316,8 @@ namespace SabreTools.Serialization.Writers
/// Write medias information to the current writer
/// </summary>
/// <param name="medias">Array of Media objects to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteMedia(Media[]? medias, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteMedia(Media[]? medias, Writer writer)
{
// If the array is missing, we can't do anything
if (medias is null)
@@ -339,8 +339,8 @@ namespace SabreTools.Serialization.Writers
/// Write samples information to the current writer
/// </summary>
/// <param name="samples">Array of Sample objects to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteSamples(Sample[]? samples, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteSamples(Sample[]? samples, Writer writer)
{
// If the array is missing, we can't do anything
if (samples is null)
@@ -358,8 +358,8 @@ namespace SabreTools.Serialization.Writers
/// Write archives information to the current writer
/// </summary>
/// <param name="archives">Array of Archive objects to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteArchives(Archive[]? archives, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteArchives(Archive[]? archives, Writer writer)
{
// If the array is missing, we can't do anything
if (archives is null)
@@ -377,8 +377,8 @@ namespace SabreTools.Serialization.Writers
/// Write chips information to the current writer
/// </summary>
/// <param name="chips">Array of Chip objects to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteChips(Chip[]? chips, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteChips(Chip[]? chips, Writer writer)
{
// If the array is missing, we can't do anything
if (chips is null)
@@ -399,8 +399,8 @@ namespace SabreTools.Serialization.Writers
/// Write video information to the current writer
/// </summary>
/// <param name="videos">Array of Video objects to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteVideos(Video[]? videos, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteVideos(Video[]? videos, Writer writer)
{
// If the item is missing, we can't do anything
if (videos is null)
@@ -424,8 +424,8 @@ namespace SabreTools.Serialization.Writers
/// Write sound information to the current writer
/// </summary>
/// <param name="sound">Sound object to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteSound(Sound? sound, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteSound(Sound? sound, Writer writer)
{
// If the item is missing, we can't do anything
if (sound is null)
@@ -440,8 +440,8 @@ namespace SabreTools.Serialization.Writers
/// Write input information to the current writer
/// </summary>
/// <param name="input">Input object to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteInput(Input? input, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteInput(Input? input, Writer writer)
{
// If the item is missing, we can't do anything
if (input is null)
@@ -461,8 +461,8 @@ namespace SabreTools.Serialization.Writers
/// Write dipswitches information to the current writer
/// </summary>
/// <param name="dipswitches">Array of DipSwitch objects to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteDipSwitches(DipSwitch[]? dipswitches, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteDipSwitches(DipSwitch[]? dipswitches, Writer writer)
{
// If the array is missing, we can't do anything
if (dipswitches is null)
@@ -486,8 +486,8 @@ namespace SabreTools.Serialization.Writers
/// Write driver information to the current writer
/// </summary>
/// <param name="driver">Driver object to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteDriver(Driver? driver, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteDriver(Driver? driver, Writer writer)
{
// If the item is missing, we can't do anything
if (driver is null)
@@ -506,8 +506,8 @@ namespace SabreTools.Serialization.Writers
/// Write info information to the current writer
/// </summary>
/// <param name="info">ClrMamePro representing the info information</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteInfo(Info? info, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteInfo(Info? info, Writer writer)
{
// If the info information is missing, we can't do anything
if (info?.Source is null)

View File

@@ -2,7 +2,7 @@ using System.IO;
using System.Text;
using SabreTools.Data.Models.DosCenter;
using SabreTools.IO.Extensions;
using SabreTools.IO.Writers;
using SabreTools.Text.ClrMamePro;
namespace SabreTools.Serialization.Writers
{
@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Writers
// Setup the writer and output
var stream = new MemoryStream();
var writer = new ClrMameProWriter(stream, Encoding.UTF8)
var writer = new Writer(stream, Encoding.UTF8)
{
Quotes = false,
};
@@ -37,8 +37,8 @@ namespace SabreTools.Serialization.Writers
/// Write header information to the current writer
/// </summary>
/// <param name="header">DosCenter representing the header information</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteHeader(Data.Models.DosCenter.DosCenter? header, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteHeader(Data.Models.DosCenter.DosCenter? header, Writer writer)
{
// If the header information is missing, we can't do anything
if (header is null)
@@ -62,8 +62,8 @@ namespace SabreTools.Serialization.Writers
/// Write games information to the current writer
/// </summary>
/// <param name="games">Array of Game objects representing the games information</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteGames(Game[]? games, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteGames(Game[]? games, Writer writer)
{
// If the games information is missing, we can't do anything
if (games is null || games.Length == 0)
@@ -81,8 +81,8 @@ namespace SabreTools.Serialization.Writers
/// Write game information to the current writer
/// </summary>
/// <param name="game">Game object representing the game information</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteGame(Game game, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteGame(Game game, Writer writer)
{
// If the game information is missing, we can't do anything
if (game is null)
@@ -103,8 +103,8 @@ namespace SabreTools.Serialization.Writers
/// Write files information to the current writer
/// </summary>
/// <param name="files">Array of File objects to write</param>
/// <param name="writer">ClrMameProWriter representing the output</param>
private static void WriteFiles(Data.Models.DosCenter.File[]? files, ClrMameProWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteFiles(Data.Models.DosCenter.File[]? files, Writer writer)
{
// If the array is missing, we can't do anything
if (files is null)

View File

@@ -3,7 +3,7 @@ using System.IO;
using System.Text;
using SabreTools.Data.Models.EverdriveSMDB;
using SabreTools.IO.Extensions;
using SabreTools.IO.Writers;
using SabreTools.Text.SeparatedValue;
namespace SabreTools.Serialization.Writers
{
@@ -18,7 +18,7 @@ namespace SabreTools.Serialization.Writers
// Setup the writer and output
var stream = new MemoryStream();
var writer = new SeparatedValueWriter(stream, Encoding.UTF8) { Separator = '\t', Quotes = false };
var writer = new Writer(stream, Encoding.UTF8) { Separator = '\t', Quotes = false };
// Write out the rows, if they exist
WriteRows(obj.Row, writer);
@@ -32,8 +32,8 @@ namespace SabreTools.Serialization.Writers
/// Write rows information to the current writer
/// </summary>
/// <param name="rows">Array of Row objects representing the rows information</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
private static void WriteRows(Row[]? rows, SeparatedValueWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteRows(Row[]? rows, Writer writer)
{
// If the games information is missing, we can't do anything
if (rows is null || rows.Length == 0)

View File

@@ -4,7 +4,7 @@ using System.Text;
using SabreTools.Data.Models.Hashfile;
using SabreTools.Hashing;
using SabreTools.IO.Extensions;
using SabreTools.IO.Writers;
using SabreTools.Text.SeparatedValue;
#pragma warning disable CA1822 // Mark members as static
namespace SabreTools.Serialization.Writers
@@ -48,7 +48,7 @@ namespace SabreTools.Serialization.Writers
return false;
using var fs = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None);
stream.CopyTo(fs);
stream.BlockCopy(fs);
fs.Flush();
return true;
@@ -71,7 +71,7 @@ namespace SabreTools.Serialization.Writers
// Setup the writer and output
var stream = new MemoryStream();
var writer = new SeparatedValueWriter(stream, Encoding.UTF8)
var writer = new Writer(stream, Encoding.UTF8)
{
Separator = ' ',
Quotes = false,
@@ -79,46 +79,30 @@ namespace SabreTools.Serialization.Writers
};
// Write out the items, if they exist
#pragma warning disable IDE0010
switch (hash)
{
case HashType.CRC32:
WriteSFV(obj.SFV, writer);
break;
case HashType.MD2:
WriteMD2(obj.MD2, writer);
break;
case HashType.MD4:
WriteMD4(obj.MD4, writer);
break;
case HashType.MD5:
WriteMD5(obj.MD5, writer);
break;
case HashType.RIPEMD128:
WriteRIPEMD128(obj.RIPEMD128, writer);
break;
case HashType.RIPEMD160:
WriteRIPEMD160(obj.RIPEMD160, writer);
break;
case HashType.SHA1:
WriteSHA1(obj.SHA1, writer);
break;
case HashType.SHA256:
WriteSHA256(obj.SHA256, writer);
break;
case HashType.SHA384:
WriteSHA384(obj.SHA384, writer);
break;
case HashType.SHA512:
WriteSHA512(obj.SHA512, writer);
break;
case HashType.SpamSum:
WriteSpamSum(obj.SpamSum, writer);
break;
default:
throw new ArgumentOutOfRangeException(nameof(hash));
}
#pragma warning restore IDE0010
if (hash == HashType.CRC32)
WriteSFV(obj.SFV, writer);
else if (hash == HashType.MD2)
WriteMD2(obj.MD2, writer);
else if (hash == HashType.MD4)
WriteMD4(obj.MD4, writer);
else if (hash == HashType.MD5)
WriteMD5(obj.MD5, writer);
else if (hash == HashType.RIPEMD128)
WriteRIPEMD128(obj.RIPEMD128, writer);
else if (hash == HashType.RIPEMD160)
WriteRIPEMD160(obj.RIPEMD160, writer);
else if (hash == HashType.SHA1)
WriteSHA1(obj.SHA1, writer);
else if (hash == HashType.SHA256)
WriteSHA256(obj.SHA256, writer);
else if (hash == HashType.SHA384)
WriteSHA384(obj.SHA384, writer);
else if (hash == HashType.SHA512)
WriteSHA512(obj.SHA512, writer);
else if (hash == HashType.SpamSum)
WriteSpamSum(obj.SpamSum, writer);
else
throw new ArgumentOutOfRangeException(nameof(hash));
// Return the stream
stream.SeekIfPossible(0, SeekOrigin.Begin);
@@ -129,8 +113,8 @@ namespace SabreTools.Serialization.Writers
/// Write SFV information to the current writer
/// </summary>
/// <param name="sfvs">Array of SFV objects representing the files</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
private static void WriteSFV(SFV[]? sfvs, SeparatedValueWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteSFV(SFV[]? sfvs, Writer writer)
{
// If the item information is missing, we can't do anything
if (sfvs is null || sfvs.Length == 0)
@@ -151,8 +135,8 @@ namespace SabreTools.Serialization.Writers
/// Write MD2 information to the current writer
/// </summary>
/// <param name="md2s">Array of MD2 objects representing the files</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
private static void WriteMD2(MD2[]? md2s, SeparatedValueWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteMD2(MD2[]? md2s, Writer writer)
{
// If the item information is missing, we can't do anything
if (md2s is null || md2s.Length == 0)
@@ -173,8 +157,8 @@ namespace SabreTools.Serialization.Writers
/// Write MD4 information to the current writer
/// </summary>
/// <param name="md4s">Array of MD4 objects representing the files</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
private static void WriteMD4(MD4[]? md4s, SeparatedValueWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteMD4(MD4[]? md4s, Writer writer)
{
// If the item information is missing, we can't do anything
if (md4s is null || md4s.Length == 0)
@@ -195,8 +179,8 @@ namespace SabreTools.Serialization.Writers
/// Write MD5 information to the current writer
/// </summary>
/// <param name="md5s">Array of MD5 objects representing the files</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
private static void WriteMD5(MD5[]? md5s, SeparatedValueWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteMD5(MD5[]? md5s, Writer writer)
{
// If the item information is missing, we can't do anything
if (md5s is null || md5s.Length == 0)
@@ -217,8 +201,8 @@ namespace SabreTools.Serialization.Writers
/// Write RIPEMD128 information to the current writer
/// </summary>
/// <param name="ripemd128s">Array of RIPEMD128 objects representing the files</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
private static void WriteRIPEMD128(RIPEMD128[]? ripemd128s, SeparatedValueWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteRIPEMD128(RIPEMD128[]? ripemd128s, Writer writer)
{
// If the item information is missing, we can't do anything
if (ripemd128s is null || ripemd128s.Length == 0)
@@ -239,8 +223,8 @@ namespace SabreTools.Serialization.Writers
/// Write RIPEMD160 information to the current writer
/// </summary>
/// <param name="ripemd160s">Array of RIPEMD160 objects representing the files</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
private static void WriteRIPEMD160(RIPEMD160[]? ripemd160s, SeparatedValueWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteRIPEMD160(RIPEMD160[]? ripemd160s, Writer writer)
{
// If the item information is missing, we can't do anything
if (ripemd160s is null || ripemd160s.Length == 0)
@@ -261,8 +245,8 @@ namespace SabreTools.Serialization.Writers
/// Write SHA1 information to the current writer
/// </summary>
/// <param name="sha1s">Array of SHA1 objects representing the files</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
private static void WriteSHA1(SHA1[]? sha1s, SeparatedValueWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteSHA1(SHA1[]? sha1s, Writer writer)
{
// If the item information is missing, we can't do anything
if (sha1s is null || sha1s.Length == 0)
@@ -283,8 +267,8 @@ namespace SabreTools.Serialization.Writers
/// Write SHA256 information to the current writer
/// </summary>
/// <param name="sha256s">Array of SHA256 objects representing the files</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
private static void WriteSHA256(SHA256[]? sha256s, SeparatedValueWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteSHA256(SHA256[]? sha256s, Writer writer)
{
// If the item information is missing, we can't do anything
if (sha256s is null || sha256s.Length == 0)
@@ -305,8 +289,8 @@ namespace SabreTools.Serialization.Writers
/// Write SHA384 information to the current writer
/// </summary>
/// <param name="sha384s">Array of SHA384 objects representing the files</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
private static void WriteSHA384(SHA384[]? sha384s, SeparatedValueWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteSHA384(SHA384[]? sha384s, Writer writer)
{
// If the item information is missing, we can't do anything
if (sha384s is null || sha384s.Length == 0)
@@ -327,8 +311,8 @@ namespace SabreTools.Serialization.Writers
/// Write SHA512 information to the current writer
/// </summary>
/// <param name="sha512s">Array of SHA512 objects representing the files</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
private static void WriteSHA512(SHA512[]? sha512s, SeparatedValueWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteSHA512(SHA512[]? sha512s, Writer writer)
{
// If the item information is missing, we can't do anything
if (sha512s is null || sha512s.Length == 0)
@@ -349,8 +333,8 @@ namespace SabreTools.Serialization.Writers
/// Write SpamSum information to the current writer
/// </summary>
/// <param name="spamsums">Array of SpamSum objects representing the files</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
private static void WriteSpamSum(SpamSum[]? spamsums, SeparatedValueWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteSpamSum(SpamSum[]? spamsums, Writer writer)
{
// If the item information is missing, we can't do anything
if (spamsums is null || spamsums.Length == 0)

View File

@@ -61,7 +61,7 @@ namespace SabreTools.Serialization.Writers
return false;
using var fs = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None);
stream.CopyTo(fs);
stream.BlockCopy(fs);
fs.Flush();
return true;

View File

@@ -1,50 +0,0 @@
#if NET20 || NET35
using System;
using System.IO;
namespace SabreTools.Serialization.Writers
{
/// <summary>
/// Derived from the mscorlib code from .NET Framework 4.0
/// </summary>
internal static class OldDotNet
{
public static void CopyTo(this Stream source, Stream destination)
{
if (destination is null)
{
throw new ArgumentNullException("destination");
}
if (!source.CanRead && !source.CanWrite)
{
throw new ObjectDisposedException(null);
}
if (!destination.CanRead && !destination.CanWrite)
{
throw new ObjectDisposedException("destination");
}
if (!source.CanRead)
{
throw new NotSupportedException();
}
if (!destination.CanWrite)
{
throw new NotSupportedException();
}
byte[] array = new byte[81920];
int count;
while ((count = source.Read(array, 0, array.Length)) != 0)
{
destination.Write(array, 0, count);
}
}
}
}
#endif

View File

@@ -2,7 +2,7 @@ using System.IO;
using System.Text;
using SabreTools.Data.Models.RomCenter;
using SabreTools.IO.Extensions;
using SabreTools.IO.Writers;
using SabreTools.Text.INI;
namespace SabreTools.Serialization.Writers
{
@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Writers
// Setup the writer and output
var stream = new MemoryStream();
var writer = new IniWriter(stream, Encoding.UTF8);
var writer = new Writer(stream, Encoding.UTF8);
// Write out the credits section
WriteCredits(obj.Credits, writer);
@@ -40,8 +40,8 @@ namespace SabreTools.Serialization.Writers
/// Write credits information to the current writer
/// </summary>
/// <param name="credits">Credits object representing the credits information</param>
/// <param name="writer">IniWriter representing the output</param>
private static void WriteCredits(Credits? credits, IniWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteCredits(Credits? credits, Writer writer)
{
// If the credits information is missing, we can't do anything
if (credits is null)
@@ -72,8 +72,8 @@ namespace SabreTools.Serialization.Writers
/// Write dat information to the current writer
/// </summary>
/// <param name="dat">Dat object representing the dat information</param>
/// <param name="writer">IniWriter representing the output</param>
private static void WriteDat(Dat? dat, IniWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteDat(Dat? dat, Writer writer)
{
// If the dat information is missing, we can't do anything
if (dat is null)
@@ -98,8 +98,8 @@ namespace SabreTools.Serialization.Writers
/// Write emulator information to the current writer
/// </summary>
/// <param name="emulator">Emulator object representing the emulator information</param>
/// <param name="writer">IniWriter representing the output</param>
private static void WriteEmulator(Emulator? emulator, IniWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteEmulator(Emulator? emulator, Writer writer)
{
// If the emulator information is missing, we can't do anything
if (emulator is null)
@@ -120,8 +120,8 @@ namespace SabreTools.Serialization.Writers
/// Write games information to the current writer
/// </summary>
/// <param name="games">Games object representing the games information</param>
/// <param name="writer">IniWriter representing the output</param>
private static void WriteGames(Games? games, IniWriter writer)
/// <param name="writer">Writer representing the output</param>
private static void WriteGames(Games? games, Writer writer)
{
// If the games information is missing, we can't do anything
if (games?.Rom is null || games.Rom.Length == 0)

View File

@@ -37,7 +37,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SabreTools.Data.Models\SabreTools.Data.Models.csproj" />
<ProjectReference Include="..\SabreTools.Data.Models\SabreTools.Data.Models.csproj" />
</ItemGroup>
</Project>

View File

@@ -2,7 +2,7 @@ using System.IO;
using System.Text;
using SabreTools.Data.Models.SeparatedValue;
using SabreTools.IO.Extensions;
using SabreTools.IO.Writers;
using SabreTools.Text.SeparatedValue;
#pragma warning disable CA1822 // Mark members as static
namespace SabreTools.Serialization.Writers
@@ -89,7 +89,7 @@ namespace SabreTools.Serialization.Writers
return false;
using var fs = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None);
stream.CopyTo(fs);
stream.BlockCopy(fs);
fs.Flush();
return true;
@@ -112,7 +112,7 @@ namespace SabreTools.Serialization.Writers
// Setup the writer and output
var stream = new MemoryStream();
var writer = new SeparatedValueWriter(stream, Encoding.UTF8)
var writer = new Writer(stream, Encoding.UTF8)
{
Separator = delim,
Quotes = true
@@ -132,9 +132,9 @@ namespace SabreTools.Serialization.Writers
/// <summary>
/// Write header information to the current writer
/// </summary>
/// <param name="writer">SeparatedValueWriter representing the output</param>
/// <param name="writer">Writer representing the output</param>
/// <param name="longHeader">True if the long variant of the row should be written, false otherwise</param>
private static void WriteHeader(SeparatedValueWriter writer, bool longHeader)
private static void WriteHeader(Writer writer, bool longHeader)
{
string[] headerArray = longHeader ? HeaderArrayExtended : HeaderArrayStandard;
writer.WriteHeader(headerArray);
@@ -145,9 +145,9 @@ namespace SabreTools.Serialization.Writers
/// Write rows information to the current writer
/// </summary>
/// <param name="rows">Array of Row objects representing the rows information</param>
/// <param name="writer">SeparatedValueWriter representing the output</param>
/// <param name="writer">Writer representing the output</param>
/// <param name="longHeader">True if the long variant of the row should be written, false otherwise</param>
private static void WriteRows(Row[]? rows, SeparatedValueWriter writer, bool longHeader)
private static void WriteRows(Row[]? rows, Writer writer, bool longHeader)
{
// If the games information is missing, we can't do anything
if (rows is null || rows.Length == 0)

View File

@@ -66,7 +66,7 @@ namespace SabreTools.Serialization.Writers
return false;
using var fs = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None);
stream.CopyTo(fs);
stream.BlockCopy(fs);
fs.Flush();
return true;