[release/6.0-rc2] File preallocationSize: align Windows and Unix behavior. (#59532)
* Align preallocationSize behavior (#58726)
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* File preallocationSize: align Windows and Unix behavior. (#59338)
* File preallocationSize: align Windows and Unix behavior.
This aligns Windows and Unix behavior of preallocationSize for the
intended use-case of specifing the size of a file that will be written.
For this use-case, the expected FileAccess is Write, and the file should be
a new one (FileMode.Create*) or a truncated file (FileMode.Truncate).
Specifing a preallocationSize for other modes, or non-writable files throws ArgumentException.
The opened file will have a length of zero, and is ready to be written to by the user.
If the requested size cannot be allocated, an IOException is thrown.
When the OS/filesystem does not support pre-allocating, preallocationSize is ignored.
* fix pal_io preprocessor checks
* pal_io more fixes
* ctor_options_as.Windows.cs: fix compilation
* Update tests
* tests: use preallocationSize from all public APIs
* pal_io: add back FreeBSD, fix OSX
* tests: check allocated is zero when preallocation is not supported.
* Only throw for not enough space errors
* Fix compilation
* Add some more tests
* Fix ExtendedPathsAreSupported test
* Apply suggestions from code review
Co-authored-by: David Cantú <dacantu@microsoft.com>
* Update System.Private.CoreLib Strings.resx
* PR feedback
* Remove GetPathToNonExistingFile
* Fix compilation
* Skip checking allocated size on mobile platforms.
Co-authored-by: David Cantú <dacantu@microsoft.com>
* Fix unused fileDescriptor
* void fd when unused
* Address feedback
Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Tom Deseyn <tom.deseyn@gmail.com>
26 files changed: