Minor File.ReadAllBytes* improvements (#61519)
authorAdam Sitnik <adam.sitnik@gmail.com>
Wed, 17 Nov 2021 12:29:49 +0000 (13:29 +0100)
committerGitHub <noreply@github.com>
Wed, 17 Nov 2021 12:29:49 +0000 (13:29 +0100)
commitd1b381661c082b6bd74a925ec9b91fba6b33e884
tree268a812e5895100b9015f8ab9831d5478a9b6f17
parent10e107debae28de4bd1e710cfe448be3c293e841
Minor File.ReadAllBytes* improvements (#61519)

* switch from FileStream to RandomAccess

* use Array.MaxLength as a limit for File.ReadAllBytes and fix an edge case bug for files: Array.MaxLength < Length < int.MaxValue

* there is no gain of using FileOptions.SequentialScan on Unix, as it requires an additional sys call

Co-authored-by: Dan Moseley <danmose@microsoft.com>
src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs
src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs
src/libraries/System.Private.CoreLib/src/System/IO/File.cs