diff --git a/CSharp/Libraries/UniversalEditor.Core/Accessor.cs b/CSharp/Libraries/UniversalEditor.Core/Accessor.cs
index f606a3fe..c9c4fa09 100644
--- a/CSharp/Libraries/UniversalEditor.Core/Accessor.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/Accessor.cs
@@ -108,7 +108,14 @@ namespace UniversalEditor
///
protected internal abstract int WriteInternal(byte[] buffer, int start, int count);
- internal virtual void FlushInternal()
+ ///
+ /// Clears all buffers for this and causes any buffered data to be written to the underlying device.
+ ///
+ public void Flush()
+ {
+ FlushInternal();
+ }
+ protected virtual void FlushInternal()
{
}
@@ -129,8 +136,7 @@ namespace UniversalEditor
mvarIsOpen = true;
}
///
- /// Closes this , making the underlying stream available to be re-opened by another
- /// .
+ /// Closes this , making the underlying stream available to be re-opened by another .
///
public void Close()
{
diff --git a/CSharp/Libraries/UniversalEditor.Core/Accessors/FileAccessor.cs b/CSharp/Libraries/UniversalEditor.Core/Accessors/FileAccessor.cs
index ef29811b..15b0c1c8 100644
--- a/CSharp/Libraries/UniversalEditor.Core/Accessors/FileAccessor.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/Accessors/FileAccessor.cs
@@ -66,7 +66,7 @@ namespace UniversalEditor.Accessors
return count;
}
- internal override void FlushInternal()
+ protected override void FlushInternal()
{
mvarFileStream.Flush();
}
diff --git a/CSharp/Libraries/UniversalEditor.Core/Accessors/StreamAccessor.cs b/CSharp/Libraries/UniversalEditor.Core/Accessors/StreamAccessor.cs
index 2b1925a9..d72771c8 100644
--- a/CSharp/Libraries/UniversalEditor.Core/Accessors/StreamAccessor.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/Accessors/StreamAccessor.cs
@@ -88,5 +88,10 @@ namespace UniversalEditor.Accessors
protected override void CloseInternal()
{
}
+
+ protected override void FlushInternal()
+ {
+ mvarBaseStream.Flush();
+ }
}
}
diff --git a/CSharp/Libraries/UniversalEditor.Core/IO/Reader.cs b/CSharp/Libraries/UniversalEditor.Core/IO/Reader.cs
index 7a5bf67e..8947b956 100644
--- a/CSharp/Libraries/UniversalEditor.Core/IO/Reader.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/IO/Reader.cs
@@ -151,8 +151,63 @@ namespace UniversalEditor.IO
}
return (multiplier * b1);
}
-
- public DateTime ReadISO9660DateTime ()
+
+ ///
+ /// Reads a in a format that encodes the property in a 2-bit field
+ /// and the property in a 62-bit field.
+ ///
+ /// An object that is equivalent to the System.DateTime object that was serialized by the method.
+ ///
+ /// The serialized value is less than or greater than .
+ ///
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public DateTime ReadDateTime()
+ {
+ return ReadDateTime64();
+ }
+ ///
+ /// Reads a in a format that encodes the property in a 2-bit field
+ /// and the property in a 62-bit field.
+ ///
+ /// An object that is equivalent to the System.DateTime object that was serialized by the method.
+ ///
+ /// The serialized value is less than or greater than .
+ ///
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public DateTime ReadDateTime64()
+ {
+ long l = ReadInt64();
+ return DateTime.FromBinary(l);
+ }
+ ///
+ /// Reads a in a format that encodes the property in a 2-bit field
+ /// and the property in a 30-bit field.
+ ///
+ /// An object that is equivalent to the System.DateTime object that was serialized by the method.
+ ///
+ /// The serialized value is less than or greater than .
+ ///
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public DateTime ReadDateTime32()
+ {
+ int l = ReadInt32();
+ return DateTime.FromBinary(l);
+ }
+
+ ///
+ /// Reads a in ISO-9660 format (yyyyMMddHHMMSSssT).
+ ///
+ /// The read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public DateTime ReadISO9660DateTime()
{
string year = ReadFixedLengthString (4);
int nYear = int.Parse (year);
@@ -201,6 +256,13 @@ namespace UniversalEditor.IO
throw new ArgumentOutOfRangeException("Invalid 7-bit encoded Int32");
}
+ ///
+ /// Reads a string from the current stream. The string is prefixed with the length, encoded as an integer seven bits at a time.
+ ///
+ /// The string being read.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public string ReadLengthPrefixedString()
{
int num = 0;
@@ -212,32 +274,77 @@ namespace UniversalEditor.IO
return ReadFixedLengthString(count);
}
+ ///
+ /// Reads a string of the specified length from the current stream. This method does not trim null characters; use to do this.
+ ///
+ /// The length of the string to read.
+ /// The string being read.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public string ReadFixedLengthString(byte length)
{
return this.ReadFixedLengthString(length, base.Accessor.DefaultEncoding);
}
-
+ ///
+ /// Reads a string of the specified length from the current stream. This method does not trim null characters; use to do this.
+ ///
+ /// The length of the string to read.
+ /// The string being read.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public string ReadFixedLengthString(int length)
{
return ReadFixedLengthString(length, base.Accessor.DefaultEncoding);
}
-
+ ///
+ /// Reads a string of the specified length from the current stream. This method does not trim null characters; use to do this.
+ ///
+ /// The length of the string to read.
+ /// The string being read.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public string ReadFixedLengthString(uint length)
{
return this.ReadFixedLengthString(length, base.Accessor.DefaultEncoding);
}
-
+ ///
+ /// Reads a string of the specified length from the current stream. This method does not trim null characters; use to do this.
+ ///
+ /// The length of the string to read.
+ /// The string being read.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public string ReadFixedLengthString(byte length, Encoding encoding)
{
return this.ReadFixedLengthString((int) length, encoding);
}
-
+ ///
+ /// Reads a string of the specified length from the current stream using the specified encoding. This method does not trim null characters; use to do this.
+ ///
+ /// The length of the string to read.
+ /// The to use to convert the bytes read into a instance.
+ /// The string being read.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public string ReadFixedLengthString(int length, Encoding encoding)
{
byte[] id = ReadBytes(length);
return encoding.GetString(id);
}
-
+ ///
+ /// Reads a string of the specified length from the current stream using the specified encoding. This method does not trim null characters; use to do this.
+ ///
+ /// The length of the string to read.
+ /// The to use to convert the bytes read into a instance.
+ /// The string being read.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public string ReadFixedLengthString(uint length, Encoding encoding)
{
int l1 = (int) length;
@@ -250,19 +357,39 @@ namespace UniversalEditor.IO
}
return encoding.GetString(id);
}
+ ///
+ /// Reads a string of the specified length from the current stream. This method does not trim null characters; use to do this.
+ ///
+ /// The length of the string to read.
+ /// The string being read.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public string ReadFixedLengthString(long length)
{
return ReadFixedLengthString(length, base.Accessor.DefaultEncoding);
}
+ ///
+ /// Reads a string of the specified length from the current stream using the specified encoding. This method does not trim null characters; use to do this.
+ ///
+ /// The length of the string to read.
+ /// The to use to convert the bytes read into a instance.
+ /// The string being read.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public string ReadFixedLengthString(long length, Encoding encoding)
{
return encoding.GetString(ReadBytes((ulong)length));
}
///
- /// Reads a 16-byte (128-bit) GUID value from the stream.
+ /// Reads a 16-byte (128-bit) value from the current stream and advances the current position of the stream by sixteen bytes.
///
- ///
+ /// A 16-byte (128-bit) value read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public Guid ReadGuid()
{
uint a = 0;
@@ -306,6 +433,14 @@ namespace UniversalEditor.IO
}
return new Guid(a, b, c, d, e, f, g, h, i, j, k);
}
+ ///
+ /// Reads an array of 16-byte (128-bit) values from the current stream and advances the current position of the stream by sixteen bytes times the number of values read.
+ ///
+ /// The number of values to read from the current stream.
+ /// An array of 16-byte (128-bit) values read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public Guid[] ReadGuidArray(int count)
{
Guid[] retval = new Guid[count];
@@ -316,6 +451,13 @@ namespace UniversalEditor.IO
return retval;
}
+ ///
+ /// Reads a 2-byte signed integer from the current stream and advances the current position of the stream by two bytes.
+ ///
+ /// A 2-byte signed integer read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public short ReadInt16()
{
byte[] buffer = ReadBytes((uint)2);
@@ -332,6 +474,14 @@ namespace UniversalEditor.IO
}
return BitConverter.ToInt16(_buffer, 0);
}
+ ///
+ /// Reads an array of 2-byte signed integers from the current stream and advances the current position of the stream by two bytes times the number of values read.
+ ///
+ /// The number of values to read from the current stream.
+ /// An array of 2-byte signed integers read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public short[] ReadInt16Array(int count)
{
short[] retval = new short[count];
@@ -341,7 +491,46 @@ namespace UniversalEditor.IO
}
return retval;
}
-
+ ///
+ /// Reads a 2-byte unsigned integer from the current stream and advances the current position of the stream by two bytes.
+ ///
+ /// A 2-byte unsigned integer read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public ushort ReadUInt16()
+ {
+ byte[] buffer = ReadBytes(2);
+ if (base.Endianness == Endianness.LittleEndian)
+ {
+ return (ushort)(buffer[0] | (buffer[1] << 8));
+ }
+ return (ushort)(buffer[1] | (buffer[0] << 8));
+ }
+ ///
+ /// Reads an array of 2-byte unsigned integers from the current stream and advances the current position of the stream by two bytes times the number of values read.
+ ///
+ /// The number of values to read from the current stream.
+ /// An array of 2-byte unsigned integers read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public ushort[] ReadUInt16Array(int count)
+ {
+ ushort[] retval = new ushort[count];
+ for (int i = 0; i < count; i++)
+ {
+ retval[i] = ReadUInt16();
+ }
+ return retval;
+ }
+ ///
+ /// Reads a 3-byte signed integer from the current stream and advances the current position of the stream by three bytes.
+ ///
+ /// A 3-byte signed integer read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public int ReadInt24()
{
byte[] buffer = ReadBytes((uint)3);
@@ -362,6 +551,14 @@ namespace UniversalEditor.IO
}
return BitConverter.ToInt32(_buffer, 0);
}
+ ///
+ /// Reads an array of 3-byte signed integers from the current stream and advances the current position of the stream by three bytes times the number of values read.
+ ///
+ /// The number of values to read from the current stream.
+ /// An array of 3-byte signed integers read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public int[] ReadInt24Array(int count)
{
int[] retval = new int[count];
@@ -371,7 +568,47 @@ namespace UniversalEditor.IO
}
return retval;
}
-
+ ///
+ /// Reads a 3-byte unsigned integer from the current stream and advances the current position of the stream by three bytes.
+ ///
+ /// A 3-byte unsigned integer read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public uint ReadUInt24()
+ {
+ // TODO: Test this out!
+ byte[] buffer = ReadBytes(3);
+ if (base.Endianness == Endianness.LittleEndian)
+ {
+ return (uint)((buffer[2] << 16) | (buffer[1] << 8) | (buffer[0]));
+ }
+ return (uint)((buffer[2]) | (buffer[1] << 8) | (buffer[0] << 16));
+ }
+ ///
+ /// Reads an array of 3-byte unsigned integers from the current stream and advances the current position of the stream by three bytes times the number of values read.
+ ///
+ /// The number of values to read from the current stream.
+ /// An array of 3-byte unsigned integers read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public uint[] ReadUInt24Array(int count)
+ {
+ uint[] retval = new uint[count];
+ for (int i = 0; i < count; i++)
+ {
+ retval[i] = ReadUInt24();
+ }
+ return retval;
+ }
+ ///
+ /// Reads a 4-byte signed integer from the current stream and advances the current position of the stream by four bytes.
+ ///
+ /// A 4-byte signed integer read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public int ReadInt32()
{
byte[] buffer = ReadBytes((uint)4);
@@ -392,6 +629,14 @@ namespace UniversalEditor.IO
}
return BitConverter.ToInt32(_buffer, 0);
}
+ ///
+ /// Reads an array of 4-byte signed integers from the current stream and advances the current position of the stream by four bytes times the number of values read.
+ ///
+ /// The number of values to read from the current stream.
+ /// An array of 4-byte signed integers read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public int[] ReadInt32Array(int count)
{
int[] retval = new int[count];
@@ -401,7 +646,59 @@ namespace UniversalEditor.IO
}
return retval;
}
-
+ ///
+ /// Reads a 4-byte unsigned integer from the current stream but does not advance the current position of the stream.
+ ///
+ /// A 4-byte unsigned integer read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public uint PeekUInt32()
+ {
+ uint value = ReadUInt32();
+ Seek(-4, SeekOrigin.Current);
+ return value;
+ }
+ ///
+ /// Reads a 4-byte unsigned integer from the current stream and advances the current position of the stream by four bytes.
+ ///
+ /// A 4-byte unsigned integer read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public uint ReadUInt32()
+ {
+ byte[] buffer = ReadBytes((uint)4);
+ if (base.Endianness == Endianness.LittleEndian)
+ {
+ return (uint)(((buffer[0] | (buffer[1] << 8)) | (buffer[2] << 0x10)) | (buffer[3] << 0x18));
+ }
+ return (uint)(((buffer[3] | (buffer[2] << 8)) | (buffer[1] << 0x10)) | (buffer[0] << 0x18));
+ }
+ ///
+ /// Reads an array of 4-byte unsigned integers from the current stream and advances the current position of the stream by four bytes times the number of values read.
+ ///
+ /// The number of values to read from the current stream.
+ /// An array of 4-byte unsigned integers read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public uint[] ReadUInt32Array(int count)
+ {
+ uint[] retval = new uint[count];
+ for (int i = 0; i < count; i++)
+ {
+ retval[i] = ReadUInt32();
+ }
+ return retval;
+ }
+ ///
+ /// Reads an 8-byte signed integer from the current stream and advances the current position of the stream by eight bytes.
+ ///
+ /// An 8-byte signed integer read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public long ReadInt64()
{
byte[] buffer = ReadBytes((uint)8);
@@ -430,6 +727,14 @@ namespace UniversalEditor.IO
}
return BitConverter.ToInt64(_buffer, 0);
}
+ ///
+ /// Reads an array of 8-byte signed integers from the current stream and advances the current position of the stream by eight bytes times the number of values read.
+ ///
+ /// The number of values to read from the current stream.
+ /// An array of 8-byte signed integers read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
public long[] ReadInt64Array(int count)
{
long[] retval = new long[count];
@@ -439,6 +744,47 @@ namespace UniversalEditor.IO
}
return retval;
}
+ ///
+ /// Reads an 8-byte unsigned integer from the current stream and advances the current position of the stream by eight bytes.
+ ///
+ /// An 8-byte unsigned integer read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public ulong ReadUInt64()
+ {
+ byte[] buffer = ReadBytes((uint)8);
+ if (base.Endianness == Endianness.LittleEndian)
+ {
+ uint num = (uint)(((buffer[0] | (buffer[1] << 8)) | (buffer[2] << 0x10)) | (buffer[3] << 0x18));
+ uint num2 = (uint)(((buffer[4] | (buffer[5] << 8)) | (buffer[6] << 0x10)) | (buffer[7] << 0x18));
+ return (ulong)(num << 0x20 | num2);
+ }
+ else if (base.Endianness == Endianness.BigEndian)
+ {
+ uint num = (uint)(((buffer[7] | (buffer[6] << 8)) | (buffer[5] << 0x10)) | (buffer[4] << 0x18));
+ uint num2 = (uint)(((buffer[3] | (buffer[2] << 8)) | (buffer[1] << 0x10)) | (buffer[0] << 0x18));
+ return (ulong)(num << 0x20 | num2);
+ }
+ throw new InvalidOperationException();
+ }
+ ///
+ /// Reads an array of 8-byte unsigned integers from the current stream and advances the current position of the stream by eight bytes times the number of values read.
+ ///
+ /// The number of values to read from the current stream.
+ /// An array of 8-byte unsigned integers read from the current stream.
+ /// The end of the stream is reached.
+ /// The stream is closed.
+ /// An I/O error occurs.
+ public ulong[] ReadUInt64Array(int count)
+ {
+ ulong[] retval = new ulong[count];
+ for (int i = 0; i < count; i++)
+ {
+ retval[i] = ReadUInt64();
+ }
+ return retval;
+ }
public float ReadSingle()
{
@@ -508,69 +854,6 @@ namespace UniversalEditor.IO
return retval;
}
- public ushort ReadUInt16 ()
- {
- byte[] buffer = ReadBytes(2);
- if (base.Endianness == Endianness.LittleEndian)
- {
- return (ushort)(buffer[0] | (buffer[1] << 8));
- }
- return (ushort)(buffer[1] | (buffer[0] << 8));
- }
- public ushort[] ReadUInt16Array(int count)
- {
- ushort[] retval = new ushort[count];
- for (int i = 0; i < count; i++)
- {
- retval[i] = ReadUInt16();
- }
- return retval;
- }
-
- public uint ReadUInt24()
- {
- // TODO: Test this out!
- byte[] buffer = ReadBytes(3);
- if (base.Endianness == Endianness.LittleEndian)
- {
- return (uint)((buffer[2] << 16) | (buffer[1] << 8) | (buffer[0]));
- }
- return (uint)((buffer[2]) | (buffer[1] << 8) | (buffer[0] << 16));
- }
- public uint[] ReadUInt24Array(int count)
- {
- uint[] retval = new uint[count];
- for (int i = 0; i < count; i++)
- {
- retval[i] = ReadUInt24();
- }
- return retval;
- }
-
- public uint ReadUInt32()
- {
- byte[] buffer = ReadBytes((uint)4);
- if (base.Endianness == Endianness.LittleEndian)
- {
- return (uint)(((buffer[0] | (buffer[1] << 8)) | (buffer[2] << 0x10)) | (buffer[3] << 0x18));
- }
- return (uint)(((buffer[3] | (buffer[2] << 8)) | (buffer[1] << 0x10)) | (buffer[0] << 0x18));
- }
- public uint[] ReadUInt32Array(int count)
- {
- uint[] retval = new uint[count];
- for (int i = 0; i < count; i++)
- {
- retval[i] = ReadUInt32();
- }
- return retval;
- }
- public uint PeekUInt32()
- {
- uint value = ReadUInt32();
- Seek(-4, SeekOrigin.Current);
- return value;
- }
public int ReadVariableLengthInt32()
{
@@ -625,32 +908,6 @@ namespace UniversalEditor.IO
return retval;
}
- public ulong ReadUInt64()
- {
- byte[] buffer = ReadBytes((uint)8);
- if (base.Endianness == Endianness.LittleEndian)
- {
- uint num = (uint)(((buffer[0] | (buffer[1] << 8)) | (buffer[2] << 0x10)) | (buffer[3] << 0x18));
- uint num2 = (uint)(((buffer[4] | (buffer[5] << 8)) | (buffer[6] << 0x10)) | (buffer[7] << 0x18));
- return (ulong)(num << 0x20 | num2);
- }
- else if (base.Endianness == Endianness.BigEndian)
- {
- uint num = (uint)(((buffer[7] | (buffer[6] << 8)) | (buffer[5] << 0x10)) | (buffer[4] << 0x18));
- uint num2 = (uint)(((buffer[3] | (buffer[2] << 8)) | (buffer[1] << 0x10)) | (buffer[0] << 0x18));
- return (ulong)(num << 0x20 | num2);
- }
- throw new InvalidOperationException();
- }
- public ulong[] ReadUInt64Array(int count)
- {
- ulong[] retval = new ulong[count];
- for (int i = 0; i < count; i++)
- {
- retval[i] = ReadUInt64();
- }
- return retval;
- }
public string ReadNullTerminatedString()
{
@@ -692,7 +949,7 @@ namespace UniversalEditor.IO
}
///
- /// Reads a length-prefixed string that is prefixed with a short (2-byte) length, rather than an int (4-byte) length.
+ /// Reads a length-prefixed string that is prefixed with a signed short (2-byte) length, rather than an int (4-byte) length.
///
///
public string ReadInt16String()
@@ -700,7 +957,10 @@ namespace UniversalEditor.IO
short length = ReadInt16();
return this.ReadFixedLengthString((int)length);
}
-
+ ///
+ /// Reads a length-prefixed string that is prefixed with an unsigned short (2-byte) length, rather than an int (4-byte) length.
+ ///
+ ///
public string ReadUInt16String()
{
ushort length = ReadUInt16();
@@ -841,21 +1101,6 @@ namespace UniversalEditor.IO
return list.ToArray();
}
- public DateTime ReadDateTime()
- {
- return ReadDateTime64();
- }
- public DateTime ReadDateTime64()
- {
- long l = ReadInt64 ();
- return DateTime.FromBinary(l);
- }
- public DateTime ReadDateTime32()
- {
- int l = ReadInt32();
- return DateTime.FromBinary(l);
- }
-
// TODO: TEST THIS!!
public decimal ReadDecimal()
{
@@ -1124,6 +1369,10 @@ namespace UniversalEditor.IO
return ReadFixedLengthString(length);
}
+ ///
+ /// Reads a from the
+ ///
+ ///
public Version ReadVersion()
{
byte parts = ReadByte();
@@ -1422,20 +1671,43 @@ namespace UniversalEditor.IO
return line;
}
- public void Seek(int length, SeekOrigin origin)
+ ///
+ /// Sets the current position of the associated .
+ ///
+ /// The offset at which to place the associated relative to the specified .
+ /// The that the is relative to.
+ /// An I/O error occurs.
+ /// The stream does not support seeking, such as if the stream is constructed from a pipe or console output.
+ /// Methods were called after the stream was closed.
+ public void Seek(int offset, SeekOrigin origin)
{
- base.Accessor.Seek(length, origin);
+ base.Accessor.Seek(offset, origin);
}
- public void Seek(long length, SeekOrigin origin)
+ ///
+ /// Sets the current position of the associated .
+ ///
+ /// The offset at which to place the associated relative to the specified .
+ /// The that the is relative to.
+ /// An I/O error occurs.
+ /// The stream does not support seeking, such as if the stream is constructed from a pipe or console output.
+ /// Methods were called after the stream was closed.
+ public void Seek(long offset, SeekOrigin origin)
{
- base.Accessor.Seek(length, origin);
+ base.Accessor.Seek(offset, origin);
}
-
+ ///
+ /// Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
+ ///
public void Close()
{
base.Accessor.Close();
}
+ ///
+ /// Gets the amount of data remaining to be read by the associated .
+ ///
+ /// The stream does not support seeking, such as if the stream is constructed from a pipe or console output.
+ /// Methods were called after the stream was closed.
public long Remaining { get { return base.Accessor.Remaining; } }
public string ReadStringUntilAny(char[] anyOf)
diff --git a/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs b/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs
index 16703e73..1c784426 100644
--- a/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs
@@ -66,6 +66,13 @@ namespace UniversalEditor.IO
byte[] data = encoding.GetBytes(new char[] { value });
WriteBytes(data);
}
+ public void WriteCharArray(char[] values)
+ {
+ for (int i = 0; i < values.Length; i++)
+ {
+ WriteChar(values[i]);
+ }
+ }
public void Write(char value)
{
@@ -190,6 +197,12 @@ namespace UniversalEditor.IO
WriteNullTerminatedString(ssz, encoding);
}
+ ///
+ /// Writes a two-byte signed integer to the current stream and advances the stream position by two bytes.
+ ///
+ /// The two-byte signed integer to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
public void WriteInt16(short value)
{
byte[] _buffer = BitConverter.GetBytes(value);
@@ -206,6 +219,25 @@ namespace UniversalEditor.IO
}
WriteBytes(buffer);
}
+ ///
+ /// Writes an array of two-byte signed integers to the current stream and advances the stream position by two bytes times the number of values written.
+ ///
+ /// The array of two-byte signed integers to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
+ public void WriteInt16Array(short[] values)
+ {
+ for (int i = 0; i < values.Length; i++)
+ {
+ WriteInt16(values[i]);
+ }
+ }
+ ///
+ /// Writes a two-byte unsigned integer to the current stream and advances the stream position by two bytes.
+ ///
+ /// The two-byte unsigned integer to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
public void WriteUInt16(ushort value)
{
byte[] _buffer = BitConverter.GetBytes(value);
@@ -222,6 +254,25 @@ namespace UniversalEditor.IO
}
WriteBytes(buffer);
}
+ ///
+ /// Writes an array of two-byte unsigned integers to the current stream and advances the stream position by two bytes times the number of values written.
+ ///
+ /// The array of two-byte unsigned integers to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
+ public void WriteUInt16Array(ushort[] values)
+ {
+ for (int i = 0; i < values.Length; i++)
+ {
+ WriteUInt16(values[i]);
+ }
+ }
+ ///
+ /// Writes a three-byte signed integer to the current stream and advances the stream position by three bytes.
+ ///
+ /// The three-byte signed integer to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
public void WriteInt24 (int value)
{
byte[] buffer = new byte[3];
@@ -239,6 +290,25 @@ namespace UniversalEditor.IO
}
WriteBytes(buffer);
}
+ ///
+ /// Writes an array of three-byte signed integers to the current stream and advances the stream position by three bytes times the number of values written.
+ ///
+ /// The array of three-byte signed integers to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
+ public void WriteInt24Array(int[] values)
+ {
+ for (int i = 0; i < values.Length; i++)
+ {
+ WriteInt24(values[i]);
+ }
+ }
+ ///
+ /// Writes a three-byte unsigned integer to the current stream and advances the stream position by three bytes.
+ ///
+ /// The three-byte unsigned integer to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
public void WriteUInt24(uint value)
{
byte[] buffer = new byte[3];
@@ -256,6 +326,25 @@ namespace UniversalEditor.IO
}
WriteBytes(buffer);
}
+ ///
+ /// Writes an array of three-byte unsigned integers to the current stream and advances the stream position by three bytes times the number of values written.
+ ///
+ /// The array of three-byte unsigned integers to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
+ public void WriteUInt24Array(uint[] values)
+ {
+ for (int i = 0; i < values.Length; i++)
+ {
+ WriteUInt24(values[i]);
+ }
+ }
+ ///
+ /// Writes a four-byte signed integer to the current stream and advances the stream position by four bytes.
+ ///
+ /// The four-byte signed integer to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
public void WriteInt32(int value)
{
byte[] _buffer = BitConverter.GetBytes(value);
@@ -276,6 +365,12 @@ namespace UniversalEditor.IO
}
WriteBytes(buffer);
}
+ ///
+ /// Writes an array of four-byte signed integers to the current stream and advances the stream position by four bytes times the number of values written.
+ ///
+ /// The array of four-byte signed integers to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
public void WriteInt32Array(int[] values)
{
for (int i = 0; i < values.Length; i++)
@@ -283,6 +378,12 @@ namespace UniversalEditor.IO
WriteInt32(values[i]);
}
}
+ ///
+ /// Writes a four-byte unsigned integer to the current stream and advances the stream position by four bytes.
+ ///
+ /// The four-byte unsigned integer to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
public void WriteUInt32(uint value)
{
byte[] _buffer = BitConverter.GetBytes(value);
@@ -303,6 +404,25 @@ namespace UniversalEditor.IO
}
WriteBytes(buffer);
}
+ ///
+ /// Writes an array of four-byte unsigned integers to the current stream and advances the stream position by four bytes times the number of values written.
+ ///
+ /// The array of four-byte unsigned integers to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
+ public void WriteUInt32Array(uint[] values)
+ {
+ for (int i = 0; i < values.Length; i++)
+ {
+ WriteUInt32(values[i]);
+ }
+ }
+ ///
+ /// Writes an eight-byte signed integer to the current stream and advances the stream position by eight bytes.
+ ///
+ /// The eight-byte signed integer to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
public void WriteInt64(long value)
{
byte[] _buffer = new byte[8];
@@ -330,6 +450,25 @@ namespace UniversalEditor.IO
}
WriteBytes(_buffer);
}
+ ///
+ /// Writes an array of eight-byte signed integers to the current stream and advances the stream position by eight bytes times the number of values written.
+ ///
+ /// The array of eight-byte signed integers to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
+ public void WriteInt64Array(long[] values)
+ {
+ for (int i = 0; i < values.Length; i++)
+ {
+ WriteInt64(values[i]);
+ }
+ }
+ ///
+ /// Writes an eight-byte unsigned integer to the current stream and advances the stream position by eight bytes.
+ ///
+ /// The eight-byte unsigned integer to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
public void WriteUInt64(ulong value)
{
byte[] _buffer = new byte[8];
@@ -357,8 +496,26 @@ namespace UniversalEditor.IO
}
WriteBytes(_buffer);
}
-
- public void WriteObject (object value)
+ ///
+ /// Writes an array of eight-byte unsigned integers to the current stream and advances the stream position by eight bytes times the number of values written.
+ ///
+ /// The array of eight-byte unsigned integers to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
+ public void WriteUInt64Array(ulong[] values)
+ {
+ for (int i = 0; i < values.Length; i++)
+ {
+ WriteUInt64(values[i]);
+ }
+ }
+ ///
+ /// Writes an arbitrary object to the current stream and advances the stream position by the number of bytes needed to store the object.
+ ///
+ /// The object to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
+ public void WriteObject(object value)
{
Type objectType = value.GetType ();
@@ -445,12 +602,97 @@ namespace UniversalEditor.IO
WriteObject (fi.GetValue (value));
}
}
-
+ ///
+ /// Writes an array of arbitrary objects to the current stream and advances the stream position by the number of bytes needed to store the objects.
+ ///
+ /// The array of objects to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
+ public void WriteObjectArray(object[] values)
+ {
+ for (int i = 0; i < values.Length; i++)
+ {
+ WriteObject(values[i]);
+ }
+ }
+
+ ///
+ /// Writes a in a format that encodes the property in a 2-bit field
+ /// and the property in a 62-bit field.
+ ///
+ /// An I/O error occurs.
+ /// The stream is closed.
public void WriteDateTime(DateTime value)
{
WriteInt64(value.ToBinary());
}
+ ///
+ /// Writes a four-byte floating-point value to the current stream and advances the stream position by four bytes.
+ ///
+ /// The four-byte floating-point value to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
+ public void WriteSingle(float value)
+ {
+ byte[] buffer = BitConverter.GetBytes(value);
+ byte[] _buffer = new byte[4];
+ if (base.Endianness == Endianness.BigEndian)
+ {
+ _buffer[0] = buffer[3];
+ _buffer[1] = buffer[2];
+ _buffer[2] = buffer[1];
+ _buffer[3] = buffer[0];
+ }
+ else
+ {
+ _buffer[0] = buffer[0];
+ _buffer[1] = buffer[1];
+ _buffer[2] = buffer[2];
+ _buffer[3] = buffer[3];
+ }
+ WriteBytes(_buffer);
+ }
+ ///
+ /// Writes an eight-byte floating-point value to the current stream and advances the stream position by eight bytes.
+ ///
+ /// The eight-byte floating-point value to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
+ public void WriteDouble(double value)
+ {
+ byte[] buffer = BitConverter.GetBytes(value);
+ byte[] _buffer = new byte[8];
+ if (base.Endianness == Endianness.BigEndian)
+ {
+ _buffer[0] = buffer[7];
+ _buffer[1] = buffer[6];
+ _buffer[2] = buffer[5];
+ _buffer[3] = buffer[4];
+ _buffer[4] = buffer[3];
+ _buffer[5] = buffer[2];
+ _buffer[6] = buffer[1];
+ _buffer[7] = buffer[0];
+ }
+ else
+ {
+ _buffer[0] = buffer[0];
+ _buffer[1] = buffer[1];
+ _buffer[2] = buffer[2];
+ _buffer[3] = buffer[3];
+ _buffer[4] = buffer[4];
+ _buffer[5] = buffer[5];
+ _buffer[6] = buffer[6];
+ _buffer[7] = buffer[7];
+ }
+ WriteBytes(_buffer);
+ }
+ ///
+ /// Writes a decimal value to the current stream and advances the stream position by sixteen bytes.
+ ///
+ /// The decimal value to write.
+ /// An I/O error occurs.
+ /// The stream is closed.
public void WriteDecimal(decimal value)
{
int[] bits = decimal.GetBits(value);
@@ -565,56 +807,6 @@ namespace UniversalEditor.IO
base.Accessor.Position += paddingCount;
}
-
- public void WriteSingle(float value)
- {
- byte[] buffer = BitConverter.GetBytes(value);
- byte[] _buffer = new byte[4];
- if (base.Endianness == Endianness.BigEndian)
- {
- _buffer[0] = buffer[3];
- _buffer[1] = buffer[2];
- _buffer[2] = buffer[1];
- _buffer[3] = buffer[0];
- }
- else
- {
- _buffer[0] = buffer[0];
- _buffer[1] = buffer[1];
- _buffer[2] = buffer[2];
- _buffer[3] = buffer[3];
- }
- WriteBytes(_buffer);
- }
- public void WriteDouble(double value)
- {
- byte[] buffer = BitConverter.GetBytes(value);
- byte[] _buffer = new byte[8];
- if (base.Endianness == Endianness.BigEndian)
- {
- _buffer[0] = buffer[7];
- _buffer[1] = buffer[6];
- _buffer[2] = buffer[5];
- _buffer[3] = buffer[4];
- _buffer[4] = buffer[3];
- _buffer[5] = buffer[2];
- _buffer[6] = buffer[1];
- _buffer[7] = buffer[0];
- }
- else
- {
- _buffer[0] = buffer[0];
- _buffer[1] = buffer[1];
- _buffer[2] = buffer[2];
- _buffer[3] = buffer[3];
- _buffer[4] = buffer[4];
- _buffer[5] = buffer[5];
- _buffer[6] = buffer[6];
- _buffer[7] = buffer[7];
- }
- WriteBytes(_buffer);
- }
-
public void WriteDoubleEndianInt16(short value)
{
WriteInt16(value);
@@ -691,30 +883,20 @@ namespace UniversalEditor.IO
WriteFixedLengthString(value);
}
+ ///
+ /// Clears all buffers for the associated and causes any buffered data to be written to the underlying device.
+ ///
public void Flush()
{
- base.Accessor.FlushInternal();
+ base.Accessor.Flush();
}
+ ///
+ /// Closes the associated and the underlying stream.
+ ///
public void Close()
{
base.Accessor.Close();
}
-
- public void WriteUInt16Array(ushort[] values)
- {
- for (int i = 0; i < values.Length; i++)
- {
- WriteUInt16(values[i]);
- }
- }
-
- public void WriteCharArray(char[] values)
- {
- for (int i = 0; i < values.Length; i++)
- {
- WriteChar(values[i]);
- }
- }
}
}