diff --git a/csharp/Euler/include/utils.cs b/csharp/Euler/include/utils.cs index b247d277..9fa64a47 100644 --- a/csharp/Euler/include/utils.cs +++ b/csharp/Euler/include/utils.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Runtime.InteropServices; namespace Euler { @@ -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)); } diff --git a/csharp/Euler/include/wasm-fallback.cs b/csharp/Euler/include/wasm-fallback.cs new file mode 100644 index 00000000..df25655b --- /dev/null +++ b/csharp/Euler/include/wasm-fallback.cs @@ -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[] {}; + } + } +}