Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
for non-seekable file handles, the OVERLAPPED offset must be set to 0
  • Loading branch information
adamsitnik committed Oct 27, 2021
commit b42a1ba4a7e8ad71fcf341791dcef2cfbb2dacc5
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public sealed override Task WriteAsync(byte[] buffer, int offset, int count, Can

public sealed override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken)
{
long writeOffset = CanSeek ? Interlocked.Add(ref _filePosition, source.Length) - source.Length : -1;
long writeOffset = CanSeek ? Interlocked.Add(ref _filePosition, source.Length) - source.Length : 0;
return RandomAccess.WriteAtOffsetAsync(_fileHandle, source, writeOffset, cancellationToken, this);
}

Expand All @@ -311,7 +311,7 @@ public sealed override ValueTask<int> ReadAsync(Memory<byte> destination, Cancel
{
if (!CanSeek)
{
return RandomAccess.ReadAtOffsetAsync(_fileHandle, destination, fileOffset: -1, cancellationToken);
return RandomAccess.ReadAtOffsetAsync(_fileHandle, destination, fileOffset: 0, cancellationToken);
}

if (LengthCachingSupported && _length >= 0 && Volatile.Read(ref _filePosition) >= _length)
Expand Down