Skip to content

Commit

Permalink
Yeeted assembly extraction methods
Browse files Browse the repository at this point in the history
Since the Varjo SDK dll is now delivered alongside the main module, we no longer have a need for assembly extraction.
  • Loading branch information
Chickenbreadlp committed Apr 27, 2023
1 parent 43314a7 commit 8d3e904
Showing 1 changed file with 0 additions and 50 deletions.
50 changes: 0 additions & 50 deletions VarjoNativeInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,56 +107,6 @@ private bool LoadLibrary()
return true;
}


// I can't ask nicely to add my DLL into the dependency list so I had to steal code from the main repo :(
private IEnumerable<string> ExtractAssemblies(IEnumerable<string> resourceNames)
{
var extractedPaths = new List<string>();

var dirName = Path.Combine(Utils.PersistentDataDirectory, "StockLibs");
if (!Directory.Exists(dirName))
Directory.CreateDirectory(dirName);

foreach (var dll in resourceNames)
{
var dllPath = Path.Combine(dirName, GetAssemblyNameFromPath(dll));

using (var stm = Assembly.GetAssembly(typeof(VarjoNativeInterface)).GetManifestResourceStream("VRCFTVarjoModule.TrackingLibs." + dll))
{
try
{
using (Stream outFile = File.Create(dllPath))
{
const int sz = 4096;
var buf = new byte[sz];
while (true)
{
if (stm == null) continue;
var nRead = stm.Read(buf, 0, sz);
if (nRead < 1)
break;
outFile.Write(buf, 0, nRead);
}
}

extractedPaths.Add(dllPath);
}
catch (Exception e)
{
Logger.LogError($"Failed to get DLL: " + e.Message);
}
}
}
return extractedPaths;
}

private static string GetAssemblyNameFromPath(string path)
{
var splitPath = path.Split('.').ToList();
splitPath.Reverse();
return splitPath[1] + ".dll";
}

private static bool VarjoAvailable()
{
// totally not how the official Varjo library works under the hood
Expand Down

0 comments on commit 8d3e904

Please sign in to comment.