2026-04-14 10:19:04 -04:00
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace SabreTools.Wrappers
|
|
|
|
|
{
|
|
|
|
|
public partial class AtariLynxCart : IWritable
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc/>
|
2026-04-14 10:25:05 -04:00
|
|
|
public bool Write(string outputPath, bool includeDebug)
|
2026-04-14 10:19:04 -04:00
|
|
|
{
|
2026-04-14 10:25:05 -04:00
|
|
|
// Ensure an output path
|
|
|
|
|
if (string.IsNullOrEmpty(outputPath))
|
|
|
|
|
{
|
|
|
|
|
string outputFilename = Filename is null
|
2026-04-14 10:27:23 -04:00
|
|
|
? (Guid.NewGuid().ToString() + ".lnx")
|
|
|
|
|
: (Filename + ".new");
|
|
|
|
|
outputPath = Path.GetFullPath(outputFilename);
|
2026-04-14 10:25:05 -04:00
|
|
|
}
|
2026-04-14 10:19:04 -04:00
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-14 12:03:19 -04:00
|
|
|
// Create and use the writer
|
|
|
|
|
var writer = new Serialization.Writers.AtariLynxCart { Debug = includeDebug };
|
|
|
|
|
return writer.SerializeFile(Model, outputPath);
|
2026-04-14 10:19:04 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|