Updated comments and correct visibility of FlushInternal() method
This commit is contained in:
parent
dd3c4fee52
commit
c9a069e5d3
@ -108,7 +108,14 @@ namespace UniversalEditor
|
||||
/// </returns>
|
||||
protected internal abstract int WriteInternal(byte[] buffer, int start, int count);
|
||||
|
||||
internal virtual void FlushInternal()
|
||||
/// <summary>
|
||||
/// Clears all buffers for this <see cref="Accessor" /> and causes any buffered data to be written to the underlying device.
|
||||
/// </summary>
|
||||
public void Flush()
|
||||
{
|
||||
FlushInternal();
|
||||
}
|
||||
protected virtual void FlushInternal()
|
||||
{
|
||||
}
|
||||
|
||||
@ -129,8 +136,7 @@ namespace UniversalEditor
|
||||
mvarIsOpen = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Closes this <see cref="Accessor" />, making the underlying stream available to be re-opened by another
|
||||
/// <see cref="Accessor" />.
|
||||
/// Closes this <see cref="Accessor" />, making the underlying stream available to be re-opened by another <see cref="Accessor" />.
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
|
||||
@ -66,7 +66,7 @@ namespace UniversalEditor.Accessors
|
||||
return count;
|
||||
}
|
||||
|
||||
internal override void FlushInternal()
|
||||
protected override void FlushInternal()
|
||||
{
|
||||
mvarFileStream.Flush();
|
||||
}
|
||||
|
||||
@ -88,5 +88,10 @@ namespace UniversalEditor.Accessors
|
||||
protected override void CloseInternal()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void FlushInternal()
|
||||
{
|
||||
mvarBaseStream.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,8 +151,63 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
return (multiplier * b1);
|
||||
}
|
||||
|
||||
public DateTime ReadISO9660DateTime ()
|
||||
|
||||
/// <summary>
|
||||
/// Reads a <see cref="DateTime" /> in a format that encodes the <see cref="System.DateTime.Kind" /> property in a 2-bit field
|
||||
/// and the <see cref="System.DateTime.Ticks" /> property in a 62-bit field.
|
||||
/// </summary>
|
||||
/// <returns>An object that is equivalent to the System.DateTime object that was serialized by the <see cref="System.DateTime.ToBinary" /> method.</returns>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// The serialized <see cref="Int64" /> value is less than <see cref="System.DateTime.MinValue" /> or greater than <see cref="System.DateTime.MaxValue" />.
|
||||
/// </exception>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public DateTime ReadDateTime()
|
||||
{
|
||||
return ReadDateTime64();
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads a <see cref="DateTime" /> in a format that encodes the <see cref="System.DateTime.Kind" /> property in a 2-bit field
|
||||
/// and the <see cref="System.DateTime.Ticks" /> property in a 62-bit field.
|
||||
/// </summary>
|
||||
/// <returns>An object that is equivalent to the System.DateTime object that was serialized by the <see cref="System.DateTime.ToBinary" /> method.</returns>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// The serialized <see cref="Int64" /> value is less than <see cref="System.DateTime.MinValue" /> or greater than <see cref="System.DateTime.MaxValue" />.
|
||||
/// </exception>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public DateTime ReadDateTime64()
|
||||
{
|
||||
long l = ReadInt64();
|
||||
return DateTime.FromBinary(l);
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads a <see cref="DateTime" /> in a format that encodes the <see cref="System.DateTime.Kind" /> property in a 2-bit field
|
||||
/// and the <see cref="System.DateTime.Ticks" /> property in a 30-bit field.
|
||||
/// </summary>
|
||||
/// <returns>An object that is equivalent to the System.DateTime object that was serialized by the <see cref="System.DateTime.ToBinary" /> method.</returns>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// The serialized <see cref="Int32" /> value is less than <see cref="System.DateTime.MinValue" /> or greater than <see cref="System.DateTime.MaxValue" />.
|
||||
/// </exception>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public DateTime ReadDateTime32()
|
||||
{
|
||||
int l = ReadInt32();
|
||||
return DateTime.FromBinary(l);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a <see cref="DateTime" /> in ISO-9660 format (yyyyMMddHHMMSSssT).
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="DateTime" /> read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
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");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a string from the current stream. The string is prefixed with the length, encoded as an integer seven bits at a time.
|
||||
/// </summary>
|
||||
/// <returns>The string being read.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public string ReadLengthPrefixedString()
|
||||
{
|
||||
int num = 0;
|
||||
@ -212,32 +274,77 @@ namespace UniversalEditor.IO
|
||||
return ReadFixedLengthString(count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a string of the specified length from the current stream. This method does not trim null characters; use <see cref="String.TrimNull" /> to do this.
|
||||
/// </summary>
|
||||
/// <param name="length">The length of the string to read.</param>
|
||||
/// <returns>The string being read.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public string ReadFixedLengthString(byte length)
|
||||
{
|
||||
return this.ReadFixedLengthString(length, base.Accessor.DefaultEncoding);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a string of the specified length from the current stream. This method does not trim null characters; use <see cref="String.TrimNull" /> to do this.
|
||||
/// </summary>
|
||||
/// <param name="length">The length of the string to read.</param>
|
||||
/// <returns>The string being read.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public string ReadFixedLengthString(int length)
|
||||
{
|
||||
return ReadFixedLengthString(length, base.Accessor.DefaultEncoding);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a string of the specified length from the current stream. This method does not trim null characters; use <see cref="String.TrimNull" /> to do this.
|
||||
/// </summary>
|
||||
/// <param name="length">The length of the string to read.</param>
|
||||
/// <returns>The string being read.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public string ReadFixedLengthString(uint length)
|
||||
{
|
||||
return this.ReadFixedLengthString(length, base.Accessor.DefaultEncoding);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a string of the specified length from the current stream. This method does not trim null characters; use <see cref="String.TrimNull" /> to do this.
|
||||
/// </summary>
|
||||
/// <param name="length">The length of the string to read.</param>
|
||||
/// <returns>The string being read.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public string ReadFixedLengthString(byte length, Encoding encoding)
|
||||
{
|
||||
return this.ReadFixedLengthString((int) length, encoding);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a string of the specified length from the current stream using the specified encoding. This method does not trim null characters; use <see cref="String.TrimNull" /> to do this.
|
||||
/// </summary>
|
||||
/// <param name="length">The length of the string to read.</param>
|
||||
/// <param name="encoding">The <see cref="Encoding" /> to use to convert the bytes read into a <see cref="String" /> instance.</param>
|
||||
/// <returns>The string being read.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public string ReadFixedLengthString(int length, Encoding encoding)
|
||||
{
|
||||
byte[] id = ReadBytes(length);
|
||||
return encoding.GetString(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a string of the specified length from the current stream using the specified encoding. This method does not trim null characters; use <see cref="String.TrimNull" /> to do this.
|
||||
/// </summary>
|
||||
/// <param name="length">The length of the string to read.</param>
|
||||
/// <param name="encoding">The <see cref="Encoding" /> to use to convert the bytes read into a <see cref="String" /> instance.</param>
|
||||
/// <returns>The string being read.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public string ReadFixedLengthString(uint length, Encoding encoding)
|
||||
{
|
||||
int l1 = (int) length;
|
||||
@ -250,19 +357,39 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
return encoding.GetString(id);
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads a string of the specified length from the current stream. This method does not trim null characters; use <see cref="String.TrimNull" /> to do this.
|
||||
/// </summary>
|
||||
/// <param name="length">The length of the string to read.</param>
|
||||
/// <returns>The string being read.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public string ReadFixedLengthString(long length)
|
||||
{
|
||||
return ReadFixedLengthString(length, base.Accessor.DefaultEncoding);
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads a string of the specified length from the current stream using the specified encoding. This method does not trim null characters; use <see cref="String.TrimNull" /> to do this.
|
||||
/// </summary>
|
||||
/// <param name="length">The length of the string to read.</param>
|
||||
/// <param name="encoding">The <see cref="Encoding" /> to use to convert the bytes read into a <see cref="String" /> instance.</param>
|
||||
/// <returns>The string being read.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public string ReadFixedLengthString(long length, Encoding encoding)
|
||||
{
|
||||
return encoding.GetString(ReadBytes((ulong)length));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 16-byte (128-bit) GUID value from the stream.
|
||||
/// Reads a 16-byte (128-bit) <see cref="Guid" /> value from the current stream and advances the current position of the stream by sixteen bytes.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>A 16-byte (128-bit) <see cref="Guid" /> value read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
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);
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads an array of 16-byte (128-bit) <see cref="Guid" /> values from the current stream and advances the current position of the stream by sixteen bytes times the number of values read.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of values to read from the current stream.</param>
|
||||
/// <returns>An array of 16-byte (128-bit) <see cref="Guid" /> values read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public Guid[] ReadGuidArray(int count)
|
||||
{
|
||||
Guid[] retval = new Guid[count];
|
||||
@ -316,6 +451,13 @@ namespace UniversalEditor.IO
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 2-byte signed integer from the current stream and advances the current position of the stream by two bytes.
|
||||
/// </summary>
|
||||
/// <returns>A 2-byte signed integer read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public short ReadInt16()
|
||||
{
|
||||
byte[] buffer = ReadBytes((uint)2);
|
||||
@ -332,6 +474,14 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
return BitConverter.ToInt16(_buffer, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of values to read from the current stream.</param>
|
||||
/// <returns>An array of 2-byte signed integers read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public short[] ReadInt16Array(int count)
|
||||
{
|
||||
short[] retval = new short[count];
|
||||
@ -341,7 +491,46 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 2-byte unsigned integer from the current stream and advances the current position of the stream by two bytes.
|
||||
/// </summary>
|
||||
/// <returns>A 2-byte unsigned integer read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
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));
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of values to read from the current stream.</param>
|
||||
/// <returns>An array of 2-byte unsigned integers read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public ushort[] ReadUInt16Array(int count)
|
||||
{
|
||||
ushort[] retval = new ushort[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
retval[i] = ReadUInt16();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads a 3-byte signed integer from the current stream and advances the current position of the stream by three bytes.
|
||||
/// </summary>
|
||||
/// <returns>A 3-byte signed integer read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public int ReadInt24()
|
||||
{
|
||||
byte[] buffer = ReadBytes((uint)3);
|
||||
@ -362,6 +551,14 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
return BitConverter.ToInt32(_buffer, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of values to read from the current stream.</param>
|
||||
/// <returns>An array of 3-byte signed integers read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public int[] ReadInt24Array(int count)
|
||||
{
|
||||
int[] retval = new int[count];
|
||||
@ -371,7 +568,47 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 3-byte unsigned integer from the current stream and advances the current position of the stream by three bytes.
|
||||
/// </summary>
|
||||
/// <returns>A 3-byte unsigned integer read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
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));
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of values to read from the current stream.</param>
|
||||
/// <returns>An array of 3-byte unsigned integers read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public uint[] ReadUInt24Array(int count)
|
||||
{
|
||||
uint[] retval = new uint[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
retval[i] = ReadUInt24();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads a 4-byte signed integer from the current stream and advances the current position of the stream by four bytes.
|
||||
/// </summary>
|
||||
/// <returns>A 4-byte signed integer read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public int ReadInt32()
|
||||
{
|
||||
byte[] buffer = ReadBytes((uint)4);
|
||||
@ -392,6 +629,14 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
return BitConverter.ToInt32(_buffer, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of values to read from the current stream.</param>
|
||||
/// <returns>An array of 4-byte signed integers read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public int[] ReadInt32Array(int count)
|
||||
{
|
||||
int[] retval = new int[count];
|
||||
@ -401,7 +646,59 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 4-byte unsigned integer from the current stream but does not advance the current position of the stream.
|
||||
/// </summary>
|
||||
/// <returns>A 4-byte unsigned integer read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public uint PeekUInt32()
|
||||
{
|
||||
uint value = ReadUInt32();
|
||||
Seek(-4, SeekOrigin.Current);
|
||||
return value;
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads a 4-byte unsigned integer from the current stream and advances the current position of the stream by four bytes.
|
||||
/// </summary>
|
||||
/// <returns>A 4-byte unsigned integer read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
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));
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of values to read from the current stream.</param>
|
||||
/// <returns>An array of 4-byte unsigned integers read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public uint[] ReadUInt32Array(int count)
|
||||
{
|
||||
uint[] retval = new uint[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
retval[i] = ReadUInt32();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads an 8-byte signed integer from the current stream and advances the current position of the stream by eight bytes.
|
||||
/// </summary>
|
||||
/// <returns>An 8-byte signed integer read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public long ReadInt64()
|
||||
{
|
||||
byte[] buffer = ReadBytes((uint)8);
|
||||
@ -430,6 +727,14 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
return BitConverter.ToInt64(_buffer, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of values to read from the current stream.</param>
|
||||
/// <returns>An array of 8-byte signed integers read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
public long[] ReadInt64Array(int count)
|
||||
{
|
||||
long[] retval = new long[count];
|
||||
@ -439,6 +744,47 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads an 8-byte unsigned integer from the current stream and advances the current position of the stream by eight bytes.
|
||||
/// </summary>
|
||||
/// <returns>An 8-byte unsigned integer read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
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();
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of values to read from the current stream.</param>
|
||||
/// <returns>An array of 8-byte unsigned integers read from the current stream.</returns>
|
||||
/// <exception cref="System.IO.EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ReadInt16String()
|
||||
@ -700,7 +957,10 @@ namespace UniversalEditor.IO
|
||||
short length = ReadInt16();
|
||||
return this.ReadFixedLengthString((int)length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a length-prefixed string that is prefixed with an unsigned short (2-byte) length, rather than an int (4-byte) length.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a <see cref="Version" /> from the
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Version ReadVersion()
|
||||
{
|
||||
byte parts = ReadByte();
|
||||
@ -1422,20 +1671,43 @@ namespace UniversalEditor.IO
|
||||
return line;
|
||||
}
|
||||
|
||||
public void Seek(int length, SeekOrigin origin)
|
||||
/// <summary>
|
||||
/// Sets the current position of the associated <see cref="Accessor" />.
|
||||
/// </summary>
|
||||
/// <param name="offset">The offset at which to place the associated <see cref="Accessor" /> relative to the specified <see cref="SeekOrigin" />.</param>
|
||||
/// <param name="origin">The <see cref="SeekOrigin" /> that the <see cref="offset" /> is relative to.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.NotSupportedException">The stream does not support seeking, such as if the stream is constructed from a pipe or console output.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">Methods were called after the stream was closed.</exception>
|
||||
public void Seek(int offset, SeekOrigin origin)
|
||||
{
|
||||
base.Accessor.Seek(length, origin);
|
||||
base.Accessor.Seek(offset, origin);
|
||||
}
|
||||
public void Seek(long length, SeekOrigin origin)
|
||||
/// <summary>
|
||||
/// Sets the current position of the associated <see cref="Accessor" />.
|
||||
/// </summary>
|
||||
/// <param name="offset">The offset at which to place the associated <see cref="Accessor" /> relative to the specified <see cref="SeekOrigin" />.</param>
|
||||
/// <param name="origin">The <see cref="SeekOrigin" /> that the <see cref="offset" /> is relative to.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.NotSupportedException">The stream does not support seeking, such as if the stream is constructed from a pipe or console output.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">Methods were called after the stream was closed.</exception>
|
||||
public void Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
base.Accessor.Seek(length, origin);
|
||||
base.Accessor.Seek(offset, origin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
base.Accessor.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the amount of data remaining to be read by the associated <see cref="Accessor" />.
|
||||
/// </summary>
|
||||
/// <exception cref="System.NotSupportedException">The stream does not support seeking, such as if the stream is constructed from a pipe or console output.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">Methods were called after the stream was closed.</exception>
|
||||
public long Remaining { get { return base.Accessor.Remaining; } }
|
||||
|
||||
public string ReadStringUntilAny(char[] anyOf)
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a two-byte signed integer to the current stream and advances the stream position by two bytes.
|
||||
/// </summary>
|
||||
/// <param name="value">The two-byte signed integer to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteInt16(short value)
|
||||
{
|
||||
byte[] _buffer = BitConverter.GetBytes(value);
|
||||
@ -206,6 +219,25 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
WriteBytes(buffer);
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of two-byte signed integers to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteInt16Array(short[] values)
|
||||
{
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
WriteInt16(values[i]);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Writes a two-byte unsigned integer to the current stream and advances the stream position by two bytes.
|
||||
/// </summary>
|
||||
/// <param name="value">The two-byte unsigned integer to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteUInt16(ushort value)
|
||||
{
|
||||
byte[] _buffer = BitConverter.GetBytes(value);
|
||||
@ -222,6 +254,25 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
WriteBytes(buffer);
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of two-byte unsigned integers to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteUInt16Array(ushort[] values)
|
||||
{
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
WriteUInt16(values[i]);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Writes a three-byte signed integer to the current stream and advances the stream position by three bytes.
|
||||
/// </summary>
|
||||
/// <param name="value">The three-byte signed integer to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteInt24 (int value)
|
||||
{
|
||||
byte[] buffer = new byte[3];
|
||||
@ -239,6 +290,25 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
WriteBytes(buffer);
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of three-byte signed integers to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteInt24Array(int[] values)
|
||||
{
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
WriteInt24(values[i]);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Writes a three-byte unsigned integer to the current stream and advances the stream position by three bytes.
|
||||
/// </summary>
|
||||
/// <param name="value">The three-byte unsigned integer to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteUInt24(uint value)
|
||||
{
|
||||
byte[] buffer = new byte[3];
|
||||
@ -256,6 +326,25 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
WriteBytes(buffer);
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of three-byte unsigned integers to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteUInt24Array(uint[] values)
|
||||
{
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
WriteUInt24(values[i]);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Writes a four-byte signed integer to the current stream and advances the stream position by four bytes.
|
||||
/// </summary>
|
||||
/// <param name="value">The four-byte signed integer to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteInt32(int value)
|
||||
{
|
||||
byte[] _buffer = BitConverter.GetBytes(value);
|
||||
@ -276,6 +365,12 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
WriteBytes(buffer);
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of four-byte signed integers to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteInt32Array(int[] values)
|
||||
{
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
@ -283,6 +378,12 @@ namespace UniversalEditor.IO
|
||||
WriteInt32(values[i]);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Writes a four-byte unsigned integer to the current stream and advances the stream position by four bytes.
|
||||
/// </summary>
|
||||
/// <param name="value">The four-byte unsigned integer to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteUInt32(uint value)
|
||||
{
|
||||
byte[] _buffer = BitConverter.GetBytes(value);
|
||||
@ -303,6 +404,25 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
WriteBytes(buffer);
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of four-byte unsigned integers to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteUInt32Array(uint[] values)
|
||||
{
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
WriteUInt32(values[i]);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Writes an eight-byte signed integer to the current stream and advances the stream position by eight bytes.
|
||||
/// </summary>
|
||||
/// <param name="value">The eight-byte signed integer to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteInt64(long value)
|
||||
{
|
||||
byte[] _buffer = new byte[8];
|
||||
@ -330,6 +450,25 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
WriteBytes(_buffer);
|
||||
}
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of eight-byte signed integers to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteInt64Array(long[] values)
|
||||
{
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
WriteInt64(values[i]);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Writes an eight-byte unsigned integer to the current stream and advances the stream position by eight bytes.
|
||||
/// </summary>
|
||||
/// <param name="value">The eight-byte unsigned integer to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteUInt64(ulong value)
|
||||
{
|
||||
byte[] _buffer = new byte[8];
|
||||
@ -357,8 +496,26 @@ namespace UniversalEditor.IO
|
||||
}
|
||||
WriteBytes(_buffer);
|
||||
}
|
||||
|
||||
public void WriteObject (object value)
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of eight-byte unsigned integers to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteUInt64Array(ulong[] values)
|
||||
{
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
WriteUInt64(values[i]);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Writes an arbitrary object to the current stream and advances the stream position by the number of bytes needed to store the object.
|
||||
/// </summary>
|
||||
/// <param name="value">The object to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteObject(object value)
|
||||
{
|
||||
Type objectType = value.GetType ();
|
||||
|
||||
@ -445,12 +602,97 @@ namespace UniversalEditor.IO
|
||||
WriteObject (fi.GetValue (value));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of objects to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteObjectArray(object[] values)
|
||||
{
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
WriteObject(values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a <see cref="DateTime" /> in a format that encodes the <see cref="System.DateTime.Kind" /> property in a 2-bit field
|
||||
/// and the <see cref="System.DateTime.Ticks" /> property in a 62-bit field.
|
||||
/// </summary>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
public void WriteDateTime(DateTime value)
|
||||
{
|
||||
WriteInt64(value.ToBinary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a four-byte floating-point value to the current stream and advances the stream position by four bytes.
|
||||
/// </summary>
|
||||
/// <param name="value">The four-byte floating-point value to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
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);
|
||||
}
|
||||
/// <summary>
|
||||
/// Writes an eight-byte floating-point value to the current stream and advances the stream position by eight bytes.
|
||||
/// </summary>
|
||||
/// <param name="value">The eight-byte floating-point value to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
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);
|
||||
}
|
||||
/// <summary>
|
||||
/// Writes a decimal value to the current stream and advances the stream position by sixteen bytes.
|
||||
/// </summary>
|
||||
/// <param name="value">The decimal value to write.</param>
|
||||
/// <exception cref="System.IO.IOException">An I/O error occurs.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all buffers for the associated <see cref="Accessor" /> and causes any buffered data to be written to the underlying device.
|
||||
/// </summary>
|
||||
public void Flush()
|
||||
{
|
||||
base.Accessor.FlushInternal();
|
||||
base.Accessor.Flush();
|
||||
}
|
||||
/// <summary>
|
||||
/// Closes the associated <see cref="Accessor" /> and the underlying stream.
|
||||
/// </summary>
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user