From 1707dbd92bc91c4586ffa99c215d69595653b1b6 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 2 Mar 2025 21:24:46 +0000 Subject: [PATCH] Add support for in-memory ReadWriteZipFiles. --- OpenRA.Game/FileSystem/ZipFile.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/FileSystem/ZipFile.cs b/OpenRA.Game/FileSystem/ZipFile.cs index b396dc43d4..c28036dd80 100644 --- a/OpenRA.Game/FileSystem/ZipFile.cs +++ b/OpenRA.Game/FileSystem/ZipFile.cs @@ -98,11 +98,11 @@ namespace OpenRA.FileSystem { readonly MemoryStream pkgStream = new(); - public ReadWriteZipFile(string filename, bool create = false) + public ReadWriteZipFile(string filename = null, bool create = false) { // SharpZipLib breaks when asked to update archives loaded from outside streams or files // We can work around this by creating a clean in-memory-only file, cutting all outside references - if (!create) + if (!string.IsNullOrEmpty(filename) && !create) { using (var copy = new MemoryStream(File.ReadAllBytes(filename))) { @@ -122,7 +122,8 @@ namespace OpenRA.FileSystem void Commit() { - File.WriteAllBytes(Name, pkgStream.ToArray()); + if (!string.IsNullOrEmpty(Name)) + File.WriteAllBytes(Name, pkgStream.ToArray()); } public void Update(string filename, byte[] contents)