Commit Graph
1528 Commits
Author SHA1 Message Date
Jeremy Koritzinsky d924fbc7e9 Merge branch 'main' of github.com:dotnet/runtime into merge-main 2021-09-24 09:26:18 -07:00
Tom DeseynandDavid Cantú 44b44501c7 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ú <[email protected]>

* Update System.Private.CoreLib Strings.resx

* PR feedback

* Remove GetPathToNonExistingFile

* Fix compilation

* Skip checking allocated size on mobile platforms.

Co-authored-by: David Cantú <[email protected]>
2021-09-23 09:25:49 -07:00
Jeremy Koritzinsky 27034bc84b Run slngen to regenerate the solution files. 2021-09-22 17:02:14 -07:00
Andrii Kurdiumov 5588f94924 Remove usused rd.xml files (#59201)
Closes #51112
2021-09-16 16:53:54 -06:00
Jeremy Koritzinsky 81293bfc1e Merge branch 'main' of https://github.com/dotnet/runtime into merge-main 2021-09-14 16:29:42 -07:00
Adam SitnikandStephen Toub 6115ca293f Align preallocationSize behavior (#58726)
Co-authored-by: Stephen Toub <[email protected]>
2021-09-14 13:30:39 +02:00
David Cantú 98c05df043 Address Windows recommendations for Link APIs (#58592)
* NT prefix shall not be treated as a relative path

* Remove file-folder-match validation

* Use SubstituteName instead of PrintName since the latter is just for display and can be misleading

* Fix MS.IO.Redist

* Fix whitespace in Strings.resx

* Address suggestions
2021-09-09 22:48:35 -07:00
Viktor Hofer 36b6247cc7 Update solution files for correct ordering of elements (#58655)
With the newest udpate of slngen, the order of elements (configuration, folders, etc.) is in sync with how Visual Studio arranges them.
Also the order is now deterministic.

Based on that, updating all solution files to have the correct ordering of elements. This change also unblocks adding CI protection for
making sure that solution files are up-to-date in regards to their dependencies as slngen is now generating the files deterministically.
2021-09-04 00:16:15 +02:00
Dan Moseley a161f34667 A few more regex test (#58154)
* Rust parser tests

* Update msg

* comment

* Work around #56945

* Add license notice

* Update url

* feedback
2021-08-31 10:51:12 -06:00
Theodore Tsirpanis 8750e9a849 Enforce scatter/gather file I/O Windows API requirements et. al. (#57424) 2021-08-31 10:28:06 +02:00
David Cantú de6b1e984a Fix detection of unsupported links (#58391)
* Fix detection of unsupported links

* Add Directory.Exists check

* Fix CI issue caused by local testing code
2021-08-30 17:20:11 -07:00
David Cantú cc0c121300 Clean-up duplicated PathInternal files (#57988)
* Clean-up duplicated PathInternal files

* Move PathInternal*.cs to Common
2021-08-27 21:28:12 -07:00
f7848bc095 Add internal junction support to link APIs (#57996)
* Add mount point support to link APIs.

* Add junction and virtual drive tests.

* Move PrintName comment outside of if else of reparseTag check.

* Add Windows platform specific attribute to junction and virtual drive test classes.

* Revert FILE_NAME_OPENED to FILE_NAME_NORMALIZED

* Revert addition of FILE_NAME_OPENED const.

* Remove unnecessary enumeration junction test.

* Rename GetNewCwdPath to ChangeCurrentDirectory

* Make Junction_ResolveLinkTarget a theory and test both resolveFinalTarget

* Shorter name for targetPath string. Typo in comment. Fix Debug.Assert.

* Clarify test comment. Change PlatformDetection for OperatingSystem check.

* Cleaner unit tests for virtual drive, add indirection test

* Skip virtual drive tests in Windows Nano (subst not available). Small test rename.

* Simplify Junctions tests, add indirection test

* Address test suggestions.

* Revert MountHelper.CreateSymbolicLink changes. Unrelated, and will be refactored/removed in the future.
Detect if SUBST is available in Windows machine, to bring back Nano.

* Add dwReserved0 check for mount points in GetFinalLinkTarget.

* Use Yoda we don't.

* Fix CI issues

Co-authored-by: carlossanlop <[email protected]>
Co-authored-by: David Cantu <[email protected]>
2021-08-27 11:36:02 -07:00
Adam Sitnik 3157403165 extend the NO_BUFFERING tests and cover all scenarios: (#57717)
- sync operations on async handle
- async operations on async handle
- sync operations on sync handle
- async operations on sync handle
2021-08-19 16:15:32 +02:00
Viktor Hofer 49c74eec15 Update changed solution files under src/libraries (#57483)
* Update slngen logic and remove unnecessary P2Ps

* Update changed soluion files under src/libraries

* Fix Platforms build

* Update comment in slngen.targets
2021-08-18 19:35:54 +02:00
David Cantú f7ba49d726 Remove validation to stat call for symlinks since is a breaking change (#57551)
* Remove validation to stat call for symlinks since is a breaking change, subsequently remove the symlink cache logic as is no longer needed

* Undo try-catch workaround in PhysicalFileProvider

* Fix tests that were failing due to changes
2021-08-17 11:51:46 -07:00
Adam Sitnik 6442090067 fix IncompleteReadCantSetPositionBeyondEndOfFile test (#57271)
* use ten unique arrays, not the same array 10 times (this should fix the test failure)

* don't run this test for the old FileStream implementation
2021-08-13 07:47:41 +02:00
Adam Sitnik cbc1f6a551 Fix .NET 5 FileStream compat detection in the test utility project (#57288) 2021-08-12 20:41:26 +02:00
Mitchell HwangandMitchell Hwang 126e29cd6e [MacCatalyst][libraries] Update MacCatalyst as Case Preserving for tests (#57167)
Co-authored-by: Mitchell Hwang <[email protected]>
2021-08-11 09:38:58 +02:00
David KarlašandJeff Handley f03c995111 Fix performance for File.GetLastWriteTimeUtc on Unix (#53070)
All this changes are to internal methods which are later called by other public methods which correctly call `ToLocalTime` for local time "overloads".
Performance hit is most visible for application which doesn't need to load local timezone information which takes ~30ms on 2016 MacBook Pro.

Co-authored-by: Jeff Handley <[email protected]>
2021-08-10 10:12:13 +02:00
Adam Sitnik 27059fb834 Ensure Directory.Delete works fine even if user has no ListDirectory permissions (#56996) 2021-08-09 18:56:58 +02:00
Adam Sitnik 6fc8441311 Ensure FileStream.Position is correct after a failed|cancelled WriteAsync attempt (#56716) 2021-08-05 07:56:29 +02:00
Adam Sitnik e176fdf643 Update position before ReadAsync starts, but fix it after incomplete read (#56531)
* move CanRead and CanWrite checks to FileStream

* don't check IsClosed twice_(FileHandle.CanSeek already contains a IsClosed check)

* add a failing test

* handle incomplete async reads

* don't try to cache file length when file is opened for writing, as updating file position before performing async write can lead to invalid cached length value

* maybe Win 7 & 8 fix
2021-07-31 19:37:23 -04:00
Jeremy Koritzinsky 108fcdb61c Merge branch 'main' of github.com:dotnet/runtime into feature/use-dllimport-generator 2021-07-29 10:44:59 -07:00
Viktor Hofer a6b9a63f35 Update libraries solution and NuGet.config files (#56430)
* Update slngen and invocation

* Update NuGet.config files

* Update solution files with slngen
2021-07-28 18:44:17 +02:00
Adam Sitnik eeb4f368a2 Add tests for reads and writes beyond EOF (#56395)
* ensure that reads beyond EOF return 0

* ensure that writes beyond EOF extend the file and the content is zeroed
2021-07-27 20:07:49 +02:00
Maxim Lipnin 5da7094bb1 Disable some library tests due to failures/crash (#55826) 2021-07-19 09:09:35 +03:00
Maxim Lipnin 0acde243da Make Named Pipe Server Stream name fit into allowed length on Android (#55731)
* Make Named Pipe Server Stream name fit into allowed length on Android

* Apply Stephen's suggestion

* Remove redundant parameter

* Take into account possible null terminator
2021-07-16 09:56:18 -04:00
Stephen Toub d2e9f42c60 Augment tests for FileMode.Append (#55513)
To validate that seeking and writing are valid in the region of the file since its initial length.
2021-07-13 12:05:31 -04:00
Stephen Toub dfd618dc64 Use interpolated strings in more places 2021-07-13 10:11:51 -04:00
David Cantú 2d596ecea2 Change server paths to use LOCALHOST (#55523) 2021-07-13 00:50:00 -07:00
Stephen Toub da7bce7605 Change RandomAccess.Write* methods to be void-returning (#55490) 2021-07-12 19:39:21 -04:00
Tom DeseynandJeff Handley 67ecbe844f File.Unix: Replace: increase Windows compatibility (#50234)
* File.Unix: Replace: increase Windows compatibility

- When source and destination are not a file throw UnauthorizedAccessException.
- When source and destination are the same file throw IOException.

* Include paths in exception message

Co-authored-by: Jeff Handley <[email protected]>
2021-07-12 15:22:17 -06:00
Adam SitnikandStephen Toub 2eb0071689 use O_TRUNC when file locking is disabled, avoid ftruncate syscall (#55456)
* add test project with file locking disabled via config file

* use O_TRUNC when file locking is disabled, avoid ftruncate syscall

* Apply suggestions from code review

Co-authored-by: Stephen Toub <[email protected]>
2021-07-10 20:38:44 +02:00
Stephen Toub e0b9fe5146 Fix File.Copy with procfs (#55358) 2021-07-09 19:56:02 -04:00
Adam Sitnik a7a9448c70 fix DeviceInterfaceCanBeOpenedForAsyncIO test (#55414) 2021-07-09 21:38:52 +02:00
Adam Sitnik 8377b0d938 allow FileStream to open any types of files from path (#54676) 2021-07-09 21:01:38 +02:00
dcce0f56e1 Add symbolic link APIs (#54253)
Co-authored-by: David Cantu <[email protected]>
Co-authored-by: carlossanlop <[email protected]>
Co-authored-by: carlossanlop <Carlos Sanchez [email protected]>
2021-07-09 13:17:31 +02:00
Stephen Toub 50413eafd5 Add UnixFileStreamStrategy (#55191)
* Add UnixFileStreamStrategy

* Address PR feedback

* Fix length caching
2021-07-08 11:28:42 -04:00
Stephen Toub 56b250b798 Handle FileOptions.DeleteOnClose on Unix in SafeFileHandle.Dispose (#55153)
* Handle FileOptions.DeleteOnClose on Unix in SafeFileHandle.Dispose

* Move file path into SafeFileHandle on Windows as well

Doing so enables cleaning up a bunch of passing around of the file path, while also enabling the path to be fed to more error paths.

* Update Net5Compat impl as well
2021-07-05 20:34:57 -04:00
f4e88f41cc all RandomAccess methods should work for both sync and async file handles (#54266)
Co-authored-by: campersau <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
2021-07-02 16:09:49 +02:00
Stephen Toub 40bd417ad8 Delete stale references to System.IO.FileSystem.Primitives (#55041) 2021-07-01 23:31:27 -04:00
Adam Sitnik 38df267589 add test for opening and reading from device interface (#54673) 2021-06-30 16:57:51 +02:00
Adam Sitnik 2abd4878e2 More file stream options tests (#53982)
* add more tests

* StreamWriter and StreamReader require FileStreamOptions with necessary access

* allow for bufferSize == 0

* extend the test

* refactor the tests

* Revert "allow for bufferSize == 0"

This reverts commit f1259be18a3446c1b8939883f484cc28347c74cf.
2021-06-26 17:20:32 -04:00
Adam Sitnik 7833828914 [FileStream] add tests for device and UNC paths (#54545)
* add a test for unseekable device by using a path to named pipe

* add a test for seekable device by using DeviceID instead of drive letter

* add a test for a UNC file path (local file share)
2021-06-24 08:58:33 +02:00
Dan Moseley f55390a2e5 Fix sporadic double fd close (#54660)
Fix https://github.com/dotnet/runtime/issues/54589
2021-06-24 00:35:39 -04:00
c0ed319ba3 Change PathInternal.IsCaseSensitive to a constant (#54340)
* Return constants in PathInternal.GetIsCaseSensitive() on mobile platforms

   In particular on Android probing using I/O is slow and contributes to slow app startup.

   Fixes https://github.com/dotnet/runtime/issues/54339

* Implement Path.IsCaseSensitive as PathInternal.IsCaseSensitive

   Also Path.StringComparison => PathInternal.StringComparison

* Add test for PathInternal.IsCaseSensitive

   Move GetIsCaseSensitiveByProbing to FileSystemTest

* Drop PathInternal.s_isCaseSensitive cache field

* Delete Path.IsCaseSensitive and Path.StringComparison

   update callers to use PathInternal.IsCaseSensitive and PathInternal.StringComparison

* Remove catch clause from GetIsCaseSensitiveByProbing

* Mark new test [OuterLoop]

* Apply suggestions from code review

Co-authored-by: Stephen Toub <[email protected]>
Co-authored-by: Jan Kotas <[email protected]>
Co-authored-by: Adam Sitnik <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
2021-06-23 09:44:41 -04:00
Elinor Fung b3d6fb16c4 Merge remote-tracking branch 'upstream/main' into mergeMain 2021-06-18 10:37:13 -07:00
Adam SitnikandStephen Toub 9d771a26f0 Set of offset-based APIs for thread-safe file IO (#53669)
Co-authored-by: Stephen Toub <[email protected]>
2021-06-15 20:59:58 +02:00
Elinor Fung 6271751fca Merge remote-tracking branch 'upstream/main' into HEAD 2021-06-11 10:04:20 -07:00