Skip to content
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Stephen Toub <[email protected]>
  • Loading branch information
2 people authored and github-actions committed Sep 14, 2021
commit a129b2b1c1f10d969a6507d1d3d50eab2f1f58f2
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ private static unsafe void Preallocate(string fullPath, long preallocationSize,
fileHandle.Dispose();
Interop.Kernel32.DeleteFile(fullPath);

throw errorCode == Interop.Errors.ERROR_DISK_FULL
? new IOException(SR.Format(SR.IO_DiskFull_Path_AllocationSize, fullPath, preallocationSize))
: new IOException(SR.Format(SR.IO_FileTooLarge_Path_AllocationSize, fullPath, preallocationSize));
throw new IOException(SR.Format(errorCode == Interop.Errors.ERROR_DISK_FULL ? SR.IO_DiskFull_Path_AllocationSize : SR.IO_FileTooLarge_Path_AllocationSize), fullPath, preallocationSize);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal static bool ShouldPreallocate(long preallocationSize, FileAccess access
=> preallocationSize > 0
&& (access & FileAccess.Write) != 0
&& mode != FileMode.Open && mode != FileMode.Append
&& (mode != FileMode.OpenOrCreate || fileHandle.CanSeek && RandomAccess.GetFileLength(fileHandle) == 0); // allow to extend only new files
&& (mode != FileMode.OpenOrCreate || (fileHandle.CanSeek && RandomAccess.GetFileLength(fileHandle) == 0)); // allow to extend only new files

internal static void ValidateArguments(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, long preallocationSize)
{
Expand Down