diff --git a/BrikInstaller.csproj b/BrikInstaller.csproj index d900cc5..32d86b1 100644 --- a/BrikInstaller.csproj +++ b/BrikInstaller.csproj @@ -32,6 +32,15 @@ false + + + root.dat + PackRenderer + + + + true + diff --git a/src/main/Program.cs b/src/main/Program.cs index a208b52..4d577a1 100644 --- a/src/main/Program.cs +++ b/src/main/Program.cs @@ -5,6 +5,7 @@ using BrikInstaller.Utils; using BrikInstaller.Schemas; using BrikInstaller.Services; using System.Net.Http.Json; +using System.Reflection; namespace BrikInstaller; @@ -15,11 +16,24 @@ class Program{ } public static PhotinoWindow CreateMainWindow() { - var BrikPackagePath = Path.Combine(Constants.BaseDirectory, "root.dat"); + string brikPackagePath; + if (Constants.Env == "PROD") { - BrikPackagePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "root.dat"); + brikPackagePath = Path.Combine(Path.GetTempPath(), "brik_root.dat"); + + var assembly = Assembly.GetExecutingAssembly(); + using (Stream? stream = assembly.GetManifestResourceStream("root.dat")) { + if (stream == null) throw new Exception("Ressource 'root.dat' introuvable."); + + using (FileStream fs = new FileStream(brikPackagePath, FileMode.Create, FileAccess.Write)) { + stream.CopyTo(fs); + } + } + } else { + brikPackagePath = Path.Combine(Constants.BaseDirectory, "root.dat"); } - BrikPackage bpkg = new BrikPackage(BrikPackagePath, 66); + + BrikPackage bpkg = new BrikPackage(brikPackagePath, 66); List entries = bpkg.ListEntries(); foreach (string entry in entries) { Console.WriteLine($"[File] > {entry}");