From d355d3c9b745a5ed3cf2525b1449b52f0070daa2 Mon Sep 17 00:00:00 2001 From: Wizzy69 Date: Fri, 18 Nov 2022 10:38:47 +0200 Subject: [PATCH 1/2] --- PluginManager/Logger.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PluginManager/Logger.cs b/PluginManager/Logger.cs index c643aa8..83ebc2f 100644 --- a/PluginManager/Logger.cs +++ b/PluginManager/Logger.cs @@ -57,7 +57,8 @@ namespace PluginManager LogEvent?.Invoke(message); } - public static void Write(char c) + + public static void Write(T c) { LogEvent?.Invoke($"{c}"); } From e3511cd96b738c516e00915ca419459c846ed929 Mon Sep 17 00:00:00 2001 From: Wizzy69 Date: Fri, 18 Nov 2022 10:45:43 +0200 Subject: [PATCH 2/2] --- PluginManager/Others/Functions.cs | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/PluginManager/Others/Functions.cs b/PluginManager/Others/Functions.cs index cac962e..12ae516 100644 --- a/PluginManager/Others/Functions.cs +++ b/PluginManager/Others/Functions.cs @@ -81,6 +81,39 @@ public static class Functions } } + /// + /// Read content of a packed file as a + /// + /// The file name inside the archive + /// The archive name + public static async Task ReadStreamFromPAKAsync(string fileName, string archFile) + { + + archFile = pakFolder + archFile; + if (!File.Exists(archFile)) + throw new Exception("Failed to load file !"); + + try + { + Stream stream = Stream.Null; + using (var fs = new FileStream(archFile, FileMode.Open)) + using (var zip = new ZipArchive(fs, ZipArchiveMode.Read)) + { + foreach (var entry in zip.Entries) + if (entry.Name == fileName || entry.FullName == fileName) + stream = entry.Open(); + } + + return stream; + } + catch (Exception ex) + { + ex.WriteErrFile(); + await Task.Delay(100); + return await ReadStreamFromPAKAsync(fileName, archFile); + } + } + /// /// Write logs to file