public override void Write(byte[] buffer, int offset, int count) { if (buffer == null) { throw new ArgumentNullException("buffer"); } else if (offset < 0) { throw new ArgumentOutOfRangeException("offset", "Must be >= 0"); } else if (count < 0) { throw new ArgumentOutOfRangeException("count", "Must be >= 0"); } else if (count > buffer.Length - offset) { throw new ArgumentException("Buffer too small, count/offset wrong"); } else if (!CanWrite) { throw new NotSupportedException("The stream does not support writing"); } ulong bytesWritten; Result result; if (async) { Async.Write(handle, out buffer[offset], (uint)count, writeCallback); Wait(); result = asyncResult; bytesWritten = asyncBytesWritten; } else { result = Sync.Write(handle, out buffer[offset], (ulong)count, out bytesWritten); } Vfs.ThrowException(Uri, result); }
public override void WriteByte(byte value) { if (!CanWrite) { throw new NotSupportedException("The stream does not support writing"); } byte[] buffer = new byte[1]; buffer[0] = value; ulong bytesWritten; Result result; if (async) { Async.Write(handle, out buffer[0], 1, writeCallback); Wait(); result = asyncResult; } else { result = Sync.Write(handle, out buffer[0], 1UL, out bytesWritten); } Vfs.ThrowException(Uri, result); }