diff --git a/Libraries/UniversalEditor.Core/IO/Reader.cs b/Libraries/UniversalEditor.Core/IO/Reader.cs index 71b8533c..3a259fc5 100644 --- a/Libraries/UniversalEditor.Core/IO/Reader.cs +++ b/Libraries/UniversalEditor.Core/IO/Reader.cs @@ -141,6 +141,13 @@ namespace UniversalEditor.IO return buffer; } + [CLSCompliant(false)] + public sbyte[] ReadSBytes(long length) + { + byte[] buffer = ReadBytes(length); + return (sbyte[])(Array)buffer; + } + public int ReadCompactInt32() { int multiplier = 1; diff --git a/Libraries/UniversalEditor.Core/IO/Writer.cs b/Libraries/UniversalEditor.Core/IO/Writer.cs index 1936f853..a912f886 100644 --- a/Libraries/UniversalEditor.Core/IO/Writer.cs +++ b/Libraries/UniversalEditor.Core/IO/Writer.cs @@ -62,6 +62,21 @@ namespace UniversalEditor.IO Write(data, 0, data.Length); } + [CLSCompliant(false)] + public void WriteSBytes(sbyte[] data) + { + if (data == null) return; + + // thanks https://stackoverflow.com/questions/829983/how-to-convert-a-sbyte-to-byte-in-c + byte[] realdata = (byte[])(Array)data; + + for (int i = 0; i < Transformations.Count; i++) + { + realdata = Transformations[i].Transform(realdata); + } + Write(realdata, 0, realdata.Length); + } + public void WriteFixedLengthBytes(byte[] data, int count) { if (data == null) data = new byte[0];