`.capacity` is backed by malloc introspection (`malloc_size`), which is
not available on all platforms. The workaround is straightforward here,
thankfully: instead, use the minimum capacity already specified.
- `withNullTerminatedSystemChars` makes it clear that the null-termination is included. Operations where the null-termination is included should be obvious.
- The original implementation includes a trailing zero with the full collection, but the implementation for a slice does not. As a result, given a `let s: SystemString`, `s.string` was not equal to `s[…].string`
Quoting the [wasi.dev landing page](https://wasi.dev):
> The WebAssembly System Interface (WASI) is a group of standard API specifications for software compiled to the W3C WebAssembly (Wasm) standard. WASI is designed to provide a secure standard interface for applications that can be compiled to Wasm from any language, and that may run anywhere—from browsers to clouds to embedded devices.
Currently support for WASI in Swift is based on [`wasi-libc`](https://github.com/WebAssembly/wasi-libc).
Adding support for `wasi-libc` mostly amounted to excluding unsupported errnos, adding TLS dictionary storage shim for single-threaded environment, and adding constants in C headers for macros that Clang importer currently doesn't support.
Co-authored-by: Guillaume Lessard <guillaume.lessard@apple.com>
# Conflicts:
# Sources/System/FileOperations.swift
# Sources/System/Internals/Syscalls.swift
The values of these flags on Windows do not overlap, and more
particularly, `O_RDONLY` is actually zero on Windows, which means we
cannot test for it by AND-ing.
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
- The original implementation simply forwarded to the underlying `nullTerminatedStorage`, which contains one element – a null terminator – more than the actual `String`.
- This isn’t in keeping with the sperit of `withContiguousStorageIfAvailable()`, which should present exactly the elements of the collection.