38 Commits

Author SHA1 Message Date
Johannes Weiss
601e847faa
always @preconcurrency import Glibc (#1175)
Co-authored-by: Johannes Weiss <johannes@jweiss.io>
2025-03-04 09:25:51 -08:00
Jonathan Flat
8a95c62e3e
(141294361) URL.appendingPathExtension("") appends a trailing dot (#1082) 2024-12-11 14:20:31 -08:00
Jeremy Schonfeld
2eeb1b0772
(140882573) Home directory for non-existent user should not fall back to /var/empty or %ALLUSERSPROFILE% (#1072) 2024-12-06 15:51:08 -08:00
Jeremy Schonfeld
b0313440a4
(140789630) Correct buffer size logic when calling confstr (#1064) 2024-12-02 15:11:44 -08:00
Jeremy Schonfeld
71eefee7fc
Fetching user/group info causes race conditions (#994)
* Avoid racy stdlib functions for fetching user/group info

* Refactor naming

* Fix build failure
2024-10-23 09:18:15 -07:00
Alex Hoppen
3f9171072d
Conditionalize stripping of \\?\ on it actually being present (#974)
As far as I know `\\?\` is always returned by `GetFinalPathNameByHandleW` but it’s better to be safe and actually check instead of unconditionally trimming the first 4 characters from the returned path.

See https://github.com/swiftlang/swift-tools-support-core/pull/485#discussion_r1795781075
2024-10-11 11:38:06 -07:00
Jonathan Flat
09bdd0d0b5
(137287143) URL path extension APIs should strip trailing slashes (#965) 2024-10-07 11:49:51 -06:00
Jonathan Flat
706ef7f9ea
(128094957) String+Path parsing performance improvements (#927) 2024-09-19 15:58:19 -07:00
rjmansfield
9d9a53722d
Fix deleteLastPathComponent() for absolute paths with trailing / (#897)
Paths like /home/ would return "" instead of /

Co-authored-by: Ryan Mansfield <ryan_mansfield@apple.com>
2024-09-05 15:35:11 -07:00
Jeremy Schonfeld
ecf5445939
Fix Windows home directory for specific user (#861)
* Fix Windows home directory for specific user

* Fix test failure
2024-08-16 13:32:04 -07:00
Jonathan Flat
83073e236e
(133878310) URL.fileSystemPath should drop all trailing slashes (#852) 2024-08-16 09:32:42 -07:00
Jeremy Schonfeld
ebb00b8077
Use fallback home directory on Windows (#854)
* Use %SystemDrive\Users\Public as fallback home directory on Windows

* Update to ALLUSERSPROFILE

* Fix test failure

* Fix iOS test failure
2024-08-15 17:27:56 -07:00
finagolfin
c15a5e1f5c
[Android] Use the Bionic module in more places (#842)
Also, use `canImport()` wherever importing APIs, reserving `os(Android)` for
platform differences.
2024-08-15 14:34:15 -07:00
Evan Wilde
aecc1b158c
[main] Get Swift-Foundation building against MUSL for Swift Static SDK (#848)
* Get FoundationEssentials building

Adding the missing musl imports to get FoundationEssentials building for
the Swift static SDKs again.

Also providing an option to disable building the macros. The macros
aren't necessary for building the library and will not be run as part of
the static SDK. No need to bloat the SDK or build times further. For
Swift 6, the macros should be provided by the toolchain since the
toolchain and SDK are current revlocked due to swiftmodules.

* Get FoundationInternationalization building

Adding the missing Musl imports to get FoundationInternationalization
building for the static SDK.
2024-08-14 13:34:15 -07:00
Alex Lorenz
ad6ca71b4e
[android] fix the LP32 armv7/i686 android build (#846)
* [android] fix the LP32 armv7/i686 android build

* Update Sources/FoundationEssentials/Android+Extensions.swift

Co-authored-by: Jeremy Schonfeld <1004103+jmschonfeld@users.noreply.github.com>

* drop the android Lp32 specific operator &

---------

Co-authored-by: Jeremy Schonfeld <1004103+jmschonfeld@users.noreply.github.com>
2024-08-14 10:56:25 -07:00
Yuta Saito
c82d1673eb
Add WASI platform conditions for libc imports and word size (#776)
* Add `import WASILibc` statements to libc import chains

* Declare wasm32 arch as 32-bit environment

* Switch to _pointerBitWidth for architecture checks

This change switches the architecture checks in Data.swift to use the
_pointerBitWidth instead of the arch() checks for consistency with newer
platforms.
2024-08-02 09:55:56 -07:00
Jonathan Flat
628fe671f9
Prevent null character in Windows home directory (#808) 2024-08-01 21:03:00 -07:00
Yuta Saito
0b3974d351
Guard out user/group related code on WASI (#783)
* 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.
2024-08-01 09:23:13 -07:00
Jeremy Schonfeld
75a3f5a047
[Windows] Standardize slashes before path processing (#731)
* Standardize backslashes before string path processing on Windows

* Call _standardizingSlashes() from normalizedPath(with:)

* Return self when possible on non-Windows
2024-07-15 09:51:58 -07:00
Jeremy Schonfeld
c3fc214351
(130296407) Gracefully handle confstr failures (#728) 2024-07-11 16:28:47 -07:00
Saleem Abdulrasool
a7692238a8
FoundationEssentials: initial pass to add Android support (#704)
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.
2024-06-26 16:00:37 -07:00
Charles Hu
60506f3af4
Renamed _CShims to _FoundationCShims (#656)
Rationale: _CShims will effectivly become semi-public in the toolchain. We add the Foundation prefix to make it less generic.
2024-06-21 16:18:38 -07:00
Saleem Abdulrasool
08d50c1caa
FoundationEssentials: correct path canonicalisation handling on Windows (#639)
* 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>
2024-05-30 13:12:47 -07:00
Charles Hu
b762e818f5
Improve String+Path performance by removing Regex (#612)
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)
2024-05-15 13:00:05 -07:00
Jonathan Flat
e991656bd0
URL.init(filePath:) should resolve against the base URL before checking if the file is a directory (#606) 2024-05-13 17:22:28 -07:00
Jonathan Flat
4a526630f8
Support Windows URL paths in FoundationEssentials (#602) 2024-05-13 19:22:08 +00:00
Jonathan Flat
361efcf5fe
Port URL and URLComponents to swift-foundation (#586) 2024-05-06 09:51:18 -07:00
Saleem Abdulrasool
f299bde9df
FoundationEssentials: implement some path utilities on Windows (#547)
Add an implementation for querying the user's home directory and for
resolving symbolic links on Windows.
2024-04-17 14:26:00 -07:00
Saleem Abdulrasool
9491cce69c
FoundationEssentials: add some missing imports for Windows (#520)
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.
2024-03-29 14:19:23 -07:00
Jeremy Schonfeld
544ec6c816
(123714904) Ensure stable home directory for processes calling seteuid
* (123714904) Ensure stable home directory for processes calling seteuid

* (123714904) Add comments
2024-03-21 13:16:19 -07:00
Jeremy Schonfeld
e5211f2926
(122981400) Standardize on using internal import 2024-03-06 13:42:02 -08:00
Jeremy Schonfeld
61835133f8
(123525912) FileManager should standardize home directory paths (#452) 2024-03-06 11:47:21 -08:00
Jeremy Schonfeld
0e23938f4b
(123636178) Resolving symlinks can remove prefix from path 2024-02-26 12:58:09 -08:00
Jeremy Schonfeld
5b06c5d5ac
(123102499) FileManager's setAttributes:forItemAtPath: is unnecessarily slow
* (123102499) Swift implementation of setAttributes:forItemAtPath: is slower than the old ObjC implementation

* Move relevant key list to static array

* Fix build failure
2024-02-20 11:46:54 -08:00
Jeremy Schonfeld
b8ef4ce99c
(122106445) Exclude some paths from automount standardization
* (122106445) Exclude some paths from automount standardization

* Fix linux build failure
2024-02-19 13:04:07 -08:00
Jeremy Schonfeld
33856a556d
(120741818) Port FileManager to swift-foundation
* (120741818) Port FileManager to swift-foundation

* (120741818) Fix linux test failures

* (120741818) Fix build failures
2024-02-09 15:03:43 -08:00
Jonathan Flat
f907600758
(121150146) String.lastPathComponent should return last non-empty component
Co-authored-by: Jonathan Flat <jflat@apple.com>
2024-02-07 14:13:53 -08:00
Tony Parker
4499edd7b1
Implement Data reading and writing (#377)
* Implement Data reading and writing

* Use swift-foundation-local for dependency name in benchmark
2024-01-17 13:04:41 -08:00