The compiler now imports these as their canonical type, allowing us to
directly use without the explicit type cast. Due to the floor of Swift
6.3, we must preserve the type cast values. Introduce an overlay to
explicitly cast the values in the older compilers.
On Windows, there is a built-in maximum path limitation of 260 characters under most conditions. This can be extended to 32767 characters under either of the following two conditions:
- Adding the longPathAware attribute to the executable's manifest AND enabling the LongPathsEnabled system-wide registry key or group policy.
- Ensuring fully qualified paths passed to Win32 APIs are prefixed with \\?\
Unfortunately, the former is not realistic for the Swift ecosystem, since it requires developers to have awareness of this specific Windows limitation, AND set longPathAware in their apps' manifest AND expect end users of those apps to change their system configuration.
Instead, this patch transparently prefixes all eligible paths in calls to Win32 APIs with the \\?\ prefix to allow them to work with paths longer than 260 characters without requiring the caller of System to manually prefix the paths.
See https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation for more info.
- `withNullTerminatedSystemChars` makes it clear that the null-termination is included. Operations where the null-termination is included should be obvious.
Broke `FilePathTemp.swift` into separate files for POSIX and
Windows.
Added tests for permissions code on Windows.
Added leading underscores to some function names.
Made some other functions `fileprivate`.
rdar://125087707
The swift-system tests were not passing, for various reasons, mostly
to do with path related confusion.
As part of this, add a function to create a temporary directory, as that
was one of the problems.
Also add Windows support for pipe() and ftruncate(), which was missing.
rdar://125087707
Ensure that FilePath and SystemString's invariants are enforced when decoding.
Cherry-pick of merge-commit 9c42c54644
from PR #189
# Conflicts:
# Sources/System/FilePath/FilePath.swift
If there's anything between them, DocC doesn't recognize that the doc
comment belongs to the declaration that comes after the interruption,
resulting in that declaration being undocumented.
This brings the contents of this package up to date with versions of the ABI stable `System` module that shipped in recent iOS/macOS releases.
Most changes only touch internal implementation details, but some ABI-related fixes also affect the public API. There are no source-incompatible changes.
- ABI stability fixes (un-deprecate CModeT, don't use PlatformChar in inlinable contexts that need to deploy to iOS 14)
- New utilities: `_RawBuffer`, `Array<String>._withCStringArray`, `_withOptionalUnsafePointerOrNull`, `_withStackBuffer`, `system_memset`
- Prefer using explicit optionals to implicitly-unwrapped ones
- Add support for wildcard matching in mocking tests
- A bunch of new availability annotations. (I expect there will be more of these coming in future PRs.)
Availability annotations now follow a rigid syntax that mentions the swift-system version that introduced the entry point:
```
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
public func greeting() -> String {
"Hello"
}
```
This is designed to be processed by automated source generation tools.
Un-deprecate withCString, but make sure it's not available on Windows (because
the types will not match). withPlatformString is still the preferred
expression of this and favors more portable code.
When building on Windows, we rely on the `withPlatformString` to convert
the strings to the native platform encoding (UTF-16). The public
`FilePath.withPlatformString` is marked as `@_alwaysEmitIntoClient` and
references the `_withPlatformString` which is marked as `internal`.
Annotate the function as `@usableFromInline` to enable the inlined
method to reference this function.
Scrap the separate module SystemInternals and instead have it be a
subdirectory. Adjust all access control accordingly. One day, when Swift gets
proper submodules or supermodules (i.e. resilience domains), we can reinstate
it. For now, a separate module makes binary distribution much more
complicated.