Add string overload for WriteToFile

and also use UTF-8 instead of ASCII to match reads -_-
This commit is contained in:
YoshiRulz 2020-07-26 04:43:50 +10:00
parent b7eb90f990
commit a931d75143
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 4 additions and 4 deletions

View File

@ -61,5 +61,7 @@ namespace BizHawk.Client.Common
return TryWrite(_mmfFiles[filename] = MemoryMappedFile.CreateOrOpen(filename, outputBytes.Length));
}
}
public int WriteToFile(string filename, string outputString) => WriteToFile(filename, Encoding.UTF8.GetBytes(outputString));
}
}

View File

@ -1,5 +1,3 @@
using System.Text;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
@ -34,7 +32,7 @@ namespace BizHawk.Client.EmuHawk
public int MmfScreenshot() => GlobalWin.memoryMappedFiles.ScreenShotToFile();
public int MmfWrite(string mmf_filename, string outputString) => GlobalWin.memoryMappedFiles.WriteToFile(mmf_filename, Encoding.ASCII.GetBytes(outputString));
public int MmfWrite(string mmf_filename, string outputString) => GlobalWin.memoryMappedFiles.WriteToFile(mmf_filename, outputString);
public string MmfRead(string mmf_filename, int expectedSize) => GlobalWin.memoryMappedFiles.ReadFromFile(mmf_filename, expectedSize);

View File

@ -149,7 +149,7 @@ namespace BizHawk.Client.EmuHawk
public int MmfWrite(string mmf_filename, string outputString)
{
CheckMmf();
return GlobalWin.memoryMappedFiles.WriteToFile(mmf_filename, Encoding.ASCII.GetBytes(outputString));
return GlobalWin.memoryMappedFiles.WriteToFile(mmf_filename, outputString);
}
[LuaMethod("mmfRead", "Reads a string from a memory mapped file")]
public string MmfRead(string mmf_filename, int expectedSize)