Add Vision support
### Motivation:
https://github.com/apple/swift-nio/issues/2900 - close this
### Modifications:
- Bump SystemPackage to 1.4.0 and remove @preconcurrency
- remove `#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) ||
os(Linux) || os(Android)` to allow for visionOS support
- Remove conditional import for swift system
### Result:
Vision OS support
Motivation:
Get this repo building again for Android with the new overlay
Modifications:
- Import the new module or overlay wherever `Glibc` is used
- Keep this repo building with Swift 5 by duplicating some declarations
Result:
All the same tests keep passing on my Android CI, finagolfin/swift-android-sdk#158
* Apply formatting
* Apply no block comments rule
* Apply OmitExplicitReturns
* Apple OnlyOneTrailingClosureArgument
* Apply NoAssignmentInExpressions
* Fix up DontRepeatTypeInStaticProperties lint errors
* Apply `OrderedImports`
* Apply `ReplaceForEachWithForLoop`
* format file
* Enable the formatting pipeline
* Adopt `AmbiguousTrailingClosureOverload`
* Fix license header
* Fix format check
* Fix `EndOfLineComment`
* Fix CI
* Adapt CI script to check if changes when running formatting
* Separate lint and format into to steps
* Fix format
* Adopt `UseEarlyExits`
* Revert "Adopt `UseEarlyExits`"
This reverts commit d1ac5bbe12.
This PR adds API to set a file's last accessed and last modified times, as well as a `touch()` shorthand that updates both to the current time.
Motivation:
Feature request: https://github.com/apple/swift-nio/issues/2712
Modifications:
This PR adds API to set a file's last accessed and last modified times, as well as a `touch()` shorthand that updates both to the current time.
Result:
Files' last accessed and last modified times can be updated.
Motivation:
'renameat2' can fail with EINVAL if the RENAME_NOREPLACE flag isn't
supported. However, not all kernel versions support this flag which can
result in an error when creating a file 'transactionally'.
Using 'renameat2' only happens on Linux as a fallback when O_TMPFILE
isn't available.
Modifications:
- On Linux, fallback to a combination of 'stat' and 'rename' if 'renameat2' fails with EINVAL.
- Add a couple of tests
Result:
Files can still be created exclusively
Motivation:
The name of the syscall used in errors for all rename calls is "rename".
However, this isn't always correct, in some cases "renamex_np" is used,
and in others "renameat2" is used.
Modifications:
- Allow the name of the syscall to be provided to the rename error
- Use the correct syscall name
Result:
Better errors
Motivation:
There are two thread pools: one in NIOFileSystem and one in NIOPosix; we
should avoid the duplication.
Modifications:
- Switch to using NIOThreadPool
- Remove the old thread pool and associated code
- Add an init to FileSystem which takes a thread pool
Result:
Less duplication
Motivation:
When a file is created 'atomically' and the descriptor is detached from
its handle then the user is provided with the descriptor for a temporary
file, and the desired file is never created.
Modifications:
Where supported, atomically created files use a temporary unnamed file
which is then linked on close. Elsewhere a temporary named file is
created which is renamed on closed.
Temporary unnamed files are linked in detach but not closed. Temporary
named files are linked to the desired path before being unlinked.
- Break out the logic for materializing a file created using a temporary
unnamed file
- Add syscalls and error mappings for link(2) and unlink(2)
Result:
Atomically created files behave as expected when detached
Motivation:
Get the new module building and tested on my Android CI again
Modifications:
- Add force unwraps where needed
- Update C types and account for nullability annotations in NDK 26
- Use /data/local/tmp for the `temporaryDirectory` and invoke it in the tests, instead of /tmp directly
- Don't copy over extended attributes
- Android doesn't support hard-linking on most partitions, so don't use it for materializing temporary files
Result:
Everything works again on Android
Motivation:
SwiftNIO doesn't compile for visionOS because NIOFileSystem depends on
Swift System which doesn't yet support visionOS.
As NIOFileSystem isn't yet stable API we can define it out on some
platforms.
Modifications:
- Only define NIOFileSystem on macOS, iOS, tvOS, watchOS, Linux and
Android.
- Only include Swift System on the same platforms
Result:
SwiftNIO compiles on visionOS, albeit without NIOFileSystem.
Use direct syscall for `renameat2` because Musl doesn't include
a wrapper for it. Similarly, define the constants ourselves.
Add Musl imports in relevant places.
Motivation:
I/O is typically blocking, but options for interacting with the
filesystem using `async` APIs are limited. This change adds a new module
to NIO, `NIOFileSystem`. At the moment this is exposed as the
`_NIOFileSystem` product while users get a chance to try it out and
provide feedback.
During this time the API of `NIOFileSystem` is subject to change.
Breaking changes will come in _minor_ NIO releases and additive changes
may come in _patch_ releases of NIO.
Modifications:
- Add `NIOFileSystem`, `NIOFileSystemFoundationCompat`,
`NIOFileSystemTests`, `NIOFileSystemIntegrationTests`, and
`NIOFileSystemFoundationCompatTests`.
- Update docs
- Update CNIOLinux and CNIODarwin shims
Result:
File system can be accessed via `async` APIs