* Guard out user/group related code on WASI
This change guards out the user/group related code on WASI, as WASI does
not have the concept of users or groups.
* Throw explicit unsupported error if trying to set user or group on WASI
Instead of implicitly ignoring user-given values, we should throw
exception to make it clear that those values cannot be set on WASI.
* Standardize backslashes before string path processing on Windows
* Call _standardizingSlashes() from normalizedPath(with:)
* Return self when possible on non-Windows
This adds the necessary guards and includes for the Android modules.
While the module does not compile currently due to nullability
differences (and in some cases missing declarations), this at least
brings the module to a point where we can start working on the errors
and differences to create a maintainable codebase for Android.
When trying to get the file system representation of a string, we may
have previously used `appendingPathComponent(_:)` which will have used
the incorrect separator. Ensure that all the separators are properly
converted prior to returning the path.
In the case that the path is canonicalised, the `/` would be replaced
with `\`. The leading `\` would interfere with our ability to recognise
the absolute path representation and thus get the wrong response.
* FoundationEssentials: correct path canonicalisation handling on Windows
Strip the extended path prefix for bypassing the Win32 API layer. This
is guaranteed to be prefixed on strings as per the documentation.
* Update Sources/FoundationEssentials/String/String+Path.swift
Co-authored-by: Jeremy Schonfeld <1004103+jmschonfeld@users.noreply.github.com>
---------
Co-authored-by: Jeremy Schonfeld <1004103+jmschonfeld@users.noreply.github.com>
When creating a file system representation from the path, we need to
strip the leading `/` which is added for the RFC representation of the
Windows path. Without this, the C runtime will fail with an invalid
argument error. Unfortunately this regresses the test suite by causing a
hang.
Reimplement `String._transmutingCompressingSlashes` and `pathHasDotDot` without using Regex. Reimplementing this method without Regex allows us to:
- Reduce the additional frames at launch since the Swift rewrite (Regex parsing brings in tons of frames)
- Not having to load additional dylib (`libswift_StringProcessing)
We would previously conditionally call `GetFullPathNameW` and do string
manipulations for normalising the path. Instead, always call
`GetFullPathNameW` to normalise the path as per Windows' rules. This
more importantly will collapse runs of the arc separator, which is
crucial when using extended paths as the NT path form must always use
the normalised paths or the access will fail.
The returned value in the success case does not account for the
terminating nul character, resulting in the value being 1 less than the
allocation required. This was causing a spurious failure and thus unable
to compute the location of the process.
This helper allows us to convert paths to the NT path representation.
The NT Path representation is important for internal usage as it allows
us to bypass the `MAX_PATH` (261) limit for Win32 APIs. In order to do
this, we simply escape the string with the NT prefix (`\\?\`) which
requires that the path is normalised (uses `\` rather than `/`) and
generally should be an absolute path. Using the NT path allows us to use
the fully supported 32k character path length of the NT kernel.
Co-authored-by: Alexander Smarus <bender@readdle.com>
Co-authored-by: Jeremy Schonfeld <1004103+jmschonfeld@users.noreply.github.com>
This allows us to get further into building FoundationEssentials once
again on Windows. Much of the file system work has resulted in this
module no longer being viable on Windows and will need to be replaced to
allow building on Windows which does not have the `fts` APIs.
* Provide public access for some internal functions, to enable swift-corelibs-foundation
* Add access to TimeZone internals for swift-corelibs-foundation
* Fix default TimeZone for Linux
* Remove unneeded private entry point
* Do not use a recursive definition of description for String.Encoding
* Merge in some WASI changes and other Data fixes
* Add temporary initializer to the stub URL
* Remove Hashable conformance for CocoaError. This allows userInfo to be Any instead of AnyHashable
* Remove some protocols which depend on NSError from swift-foundation -- they will live in swift-corelibs-foundation
* Adjust the debug description of the GMT ICU calendar to be a little less implementation-specific
* Use an English-only description for string encodings, for compatibility with existing SCL-F clients
* Use a more compatible definition of a backstop value for Bundle
* (123102499) Swift implementation of setAttributes:forItemAtPath: is slower than the old ObjC implementation
* Move relevant key list to static array
* Fix build failure
* Use smaller buffer for file system representation
* Reword scalars -> code-units
Co-authored-by: Karl <5254025+karwa@users.noreply.github.com>
---------
Co-authored-by: Karl <5254025+karwa@users.noreply.github.com>