Skip to content

Commit

Permalink
prep for eventual wasm packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Aug 5, 2024
1 parent 1e28d19 commit 78de599
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions csharp/Euler/include/utils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Runtime.InteropServices;

namespace Euler
{
Expand All @@ -14,11 +15,15 @@ private static string GetDataPath(string name)

public static string GetDataFileText(string name)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY")))
return WasmIOFallback.GetText(name);
return File.ReadAllText(GetDataPath(name));
}

public static byte[] GetDataFileBytes(string name)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY")))
return WasmIOFallback.GetBytes(name);
return File.ReadAllBytes(GetDataPath(name));
}

Expand Down
17 changes: 17 additions & 0 deletions csharp/Euler/include/wasm-fallback.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.IO;

namespace Euler
{
public static class WasmIOFallback
{
public static string GetText(string name)
{
return "";
}

public static byte[] GetBytes(string name)
{
return new byte[] {};
}
}
}

0 comments on commit 78de599

Please sign in to comment.