Skip to content

Commit 4232cf4

Browse files
committed
Update Net5Compat impl as well
1 parent 87d6461 commit 4232cf4

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/libraries/System.Private.CoreLib/src/System/IO/Strategies/Net5CompatFileStreamStrategy.Unix.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected override void Dispose(bool disposing)
108108

109109
if (SafeFileHandle.t_lastCloseErrorInfo != null)
110110
{
111-
throw Interop.GetExceptionForIoErrno(SafeFileHandle.t_lastCloseErrorInfo.GetValueOrDefault(), _path, isDirectory: false);
111+
throw Interop.GetExceptionForIoErrno(SafeFileHandle.t_lastCloseErrorInfo.GetValueOrDefault(), _fileHandle.Path, isDirectory: false);
112112
}
113113
}
114114
}
@@ -156,7 +156,7 @@ private void FlushOSBuffer()
156156
// doesn't support synchronization. In such cases there's nothing to flush.
157157
break;
158158
default:
159-
throw Interop.GetExceptionForIoErrno(errorInfo, _path, isDirectory: false);
159+
throw Interop.GetExceptionForIoErrno(errorInfo, _fileHandle.Path, isDirectory: false);
160160
}
161161
}
162162
}
@@ -604,14 +604,14 @@ private long SeekCore(SafeFileHandle fileHandle, long offset, SeekOrigin origin,
604604
Debug.Assert(fileHandle.CanSeek);
605605
Debug.Assert(origin >= SeekOrigin.Begin && origin <= SeekOrigin.End);
606606

607-
long pos = FileStreamHelpers.CheckFileCall(Interop.Sys.LSeek(fileHandle, offset, (Interop.Sys.SeekWhence)(int)origin), _path); // SeekOrigin values are the same as Interop.libc.SeekWhence values
607+
long pos = FileStreamHelpers.CheckFileCall(Interop.Sys.LSeek(fileHandle, offset, (Interop.Sys.SeekWhence)(int)origin), fileHandle.Path); // SeekOrigin values are the same as Interop.libc.SeekWhence values
608608
_filePosition = pos;
609609
return pos;
610610
}
611611

612612
private int CheckFileCall(int result, bool ignoreNotSupported = false)
613613
{
614-
FileStreamHelpers.CheckFileCall(result, _path, ignoreNotSupported);
614+
FileStreamHelpers.CheckFileCall(result, _fileHandle?.Path, ignoreNotSupported);
615615

616616
return result;
617617
}

src/libraries/System.Private.CoreLib/src/System/IO/Strategies/Net5CompatFileStreamStrategy.Windows.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ private unsafe int ReadNative(Span<byte> buffer)
374374
if (errorCode == Interop.Errors.ERROR_INVALID_PARAMETER)
375375
ThrowHelper.ThrowArgumentException_HandleNotSync(nameof(_fileHandle));
376376

377-
throw Win32Marshal.GetExceptionForWin32Error(errorCode, _path);
377+
throw Win32Marshal.GetExceptionForWin32Error(errorCode, _fileHandle.Path);
378378
}
379379
}
380380
Debug.Assert(r >= 0, "FileStream's ReadNative is likely broken.");
@@ -578,7 +578,7 @@ private unsafe void WriteCore(ReadOnlySpan<byte> source)
578578
// to a handle opened asynchronously.
579579
if (errorCode == Interop.Errors.ERROR_INVALID_PARAMETER)
580580
throw new IOException(SR.IO_FileTooLongOrHandleNotSync);
581-
throw Win32Marshal.GetExceptionForWin32Error(errorCode, _path);
581+
throw Win32Marshal.GetExceptionForWin32Error(errorCode, _fileHandle.Path);
582582
}
583583
}
584584
Debug.Assert(r >= 0, "FileStream's WriteCore is likely broken.");
@@ -776,7 +776,7 @@ private unsafe Task<int> ReadNativeAsync(Memory<byte> destination, int numBuffer
776776
}
777777
else
778778
{
779-
throw Win32Marshal.GetExceptionForWin32Error(errorCode, _path);
779+
throw Win32Marshal.GetExceptionForWin32Error(errorCode, _fileHandle.Path);
780780
}
781781
}
782782
else if (cancellationToken.CanBeCanceled) // ERROR_IO_PENDING
@@ -978,7 +978,7 @@ private unsafe Task WriteAsyncInternalCore(ReadOnlyMemory<byte> source, Cancella
978978
}
979979
else
980980
{
981-
throw Win32Marshal.GetExceptionForWin32Error(errorCode, _path);
981+
throw Win32Marshal.GetExceptionForWin32Error(errorCode, _fileHandle.Path);
982982
}
983983
}
984984
else if (cancellationToken.CanBeCanceled) // ERROR_IO_PENDING

src/libraries/System.Private.CoreLib/src/System/IO/Strategies/Net5CompatFileStreamStrategy.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ internal sealed partial class Net5CompatFileStreamStrategy : FileStreamStrategy
1919
/// <summary>Whether the file is opened for reading, writing, or both.</summary>
2020
private readonly FileAccess _access;
2121

22-
/// <summary>The path to the opened file.</summary>
23-
private readonly string? _path;
24-
2522
/// <summary>The next available byte to be read from the _buffer.</summary>
2623
private int _readPos;
2724

@@ -82,7 +79,6 @@ internal Net5CompatFileStreamStrategy(string path, FileMode mode, FileAccess acc
8279
{
8380
string fullPath = Path.GetFullPath(path);
8481

85-
_path = fullPath;
8682
_access = access;
8783
_bufferLength = bufferSize;
8884

@@ -293,7 +289,7 @@ internal override SafeFileHandle SafeFileHandle
293289
}
294290
}
295291

296-
internal override string Name => _path ?? SR.IO_UnknownFileName;
292+
internal override string Name => _fileHandle.Path ?? SR.IO_UnknownFileName;
297293

298294
internal override bool IsAsync => _useAsyncIO;
299295

0 commit comments

Comments
 (0)