/// <summary> /// Writes a string with the given encoding to the given offset of the file /// </summary> /// <param name="index">Index of the file to write</param> /// <param name="e">The encoding to use</param> /// <param name="value">The string to write. The entire string will be written with an ending null character.</param> public static void WriteNullTerminatedString(this IWriteOnlyBinaryDataAccessor accessor, long index, Encoding e, string value) { var nullChar = e.GetBytes(new[] { Convert.ToChar(0) }); var data = e.GetBytes(value); accessor.Write(index, data.Length, data); accessor.Write(index + data.Length, nullChar.Length, nullChar); }
/// <summary> /// Writes a signed 16 bit little endian integer /// </summary> /// <param name="offset">Offset of the integer to write.</param> /// <param name="value">The integer to write</param> public static void WriteInt16(this IWriteOnlyBinaryDataAccessor accessor, long offset, Int16 value) { accessor.Write(offset, 2, BitConverter.GetBytes(value)); }
/// <summary> /// Writes all of the given data to the desired index /// </summary> /// <param name="index">Index of the data to write</param> /// <param name="value">Data to write</param> public static void Write(this IWriteOnlyBinaryDataAccessor accessor, long index, byte[] value) { accessor.Write(index, value.Length, value); }
/// <summary> /// Writes a string with the given encoding to the given offset of the file /// </summary> /// <param name="index">Index of the file to write</param> /// <param name="e">The encoding to use</param> /// <param name="value">The string to write. The entire string will be written without an ending null character.</param> public static void WriteString(this IWriteOnlyBinaryDataAccessor accessor, long index, Encoding e, string value) { accessor.Write(index, e.GetBytes(value)); }
/// <summary> /// Writes an unsigned 64 bit little endian integer /// </summary> /// <param name="offset">Offset of the integer to write.</param> /// <param name="value">The integer to write</param> public static void WriteUInt64(this IWriteOnlyBinaryDataAccessor accessor, long offset, UInt64 value) { accessor.Write(offset, 8, BitConverter.GetBytes(value)); }