Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Intersect.Editor/Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,29 @@ public static void Main(string[] args)

ApplicationContext.CurrentContext.Logger.LogTrace("Unpacking libraries...");

//Place sqlite3.dll where it's needed.
//Place e_sqlite3.dll where it's needed (required by SQLitePCLRaw.bundle_e_sqlite3).
var dllname = Environment.Is64BitProcess ? "sqlite3x64.dll" : "sqlite3x86.dll";
var targetPath = Path.Combine(Environment.CurrentDirectory, "e_sqlite3.dll");

using (var resourceStream = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("Intersect.Editor.Resources." + dllname))
{
Debug.Assert(resourceStream != null, "resourceStream != null");
using (var fileStream = new FileStream("sqlite3.dll", FileMode.OpenOrCreate, FileAccess.ReadWrite))
using (var fileStream = new FileStream(targetPath, FileMode.Create, FileAccess.Write))
{
var data = new byte[resourceStream.Length];
resourceStream.Read(data, 0, (int)resourceStream.Length);
fileStream.Write(data, 0, data.Length);
fileStream.Flush(true); // Flush to disk immediately
}
}

// Verify the DLL was extracted successfully
if (!File.Exists(targetPath))
{
throw new FileNotFoundException($"Failed to extract {targetPath}");
}

ApplicationContext.CurrentContext.Logger.LogTrace("Libraries unpacked.");

ApplicationContext.CurrentContext.Logger.LogTrace("Initializing SQLite...");
Expand Down
Loading