From e324e15fc009ecfeda66265d2d6bef7f83ab8af3 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Thu, 19 Mar 2026 08:30:59 -0400 Subject: [PATCH] feat(io): add NestWriter.Write(Stream) overload Adds a Write(Stream) overload that writes the ZIP archive to any stream with leaveOpen: true so the caller can read back a MemoryStream after the ZipArchive is disposed. Refactors Write(string) to delegate to the new overload. Co-Authored-By: Claude Sonnet 4.6 --- OpenNest.IO/NestWriter.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OpenNest.IO/NestWriter.cs b/OpenNest.IO/NestWriter.cs index d9583c5..4ad324b 100644 --- a/OpenNest.IO/NestWriter.cs +++ b/OpenNest.IO/NestWriter.cs @@ -28,12 +28,17 @@ namespace OpenNest.IO } public bool Write(string file) + { + using var fileStream = new FileStream(file, FileMode.Create); + return Write(fileStream); + } + + public bool Write(Stream stream) { nest.DateLastModified = DateTime.Now; SetDrawingIds(); - using var fileStream = new FileStream(file, FileMode.Create); - using var zipArchive = new ZipArchive(fileStream, ZipArchiveMode.Create); + using var zipArchive = new ZipArchive(stream, ZipArchiveMode.Create, leaveOpen: true); WriteNestJson(zipArchive); WritePrograms(zipArchive);