mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-08 18:06:41 +00:00
33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using System;
|
|
using System.IO;
|
|
|
|
namespace SabreTools.Wrappers
|
|
{
|
|
public partial class AtariLynxCart : IWritable
|
|
{
|
|
/// <inheritdoc/>
|
|
public bool Write(string outputPath, bool includeDebug)
|
|
{
|
|
// Ensure an output path
|
|
if (string.IsNullOrEmpty(outputPath))
|
|
{
|
|
string outputFilename = Filename is null
|
|
? (Guid.NewGuid().ToString() + ".lnx")
|
|
: (Filename + ".new");
|
|
outputPath = Path.GetFullPath(outputFilename);
|
|
}
|
|
|
|
// Check for invalid data
|
|
if (Header is null || Model.Data is null || Model.Data.Length == 0)
|
|
{
|
|
if (includeDebug) Console.WriteLine("Model was invalid, cannot write!");
|
|
return false;
|
|
}
|
|
|
|
// Create and use the writer
|
|
var writer = new Serialization.Writers.AtariLynxCart { Debug = includeDebug };
|
|
return writer.SerializeFile(Model, outputPath);
|
|
}
|
|
}
|
|
}
|