28 Commits

Author SHA1 Message Date
Jeremy Schonfeld
e555c629ba
Fix Windows symlink handling in FileManager APIs (#858)
* Fix Windows symlink handling in FileManager APIs

* Address feedback
2024-08-16 10:41:44 -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
bc47ca221d
Port directory enumeration related code to WASI (#836)
* Port directory enumeration related code to WASI

For now wasi-libc does not include fts(3) implementation, so mark
features depending on it as unsupported on WASI. Once wasi-libc includes
fts or we decide to implement and maintain our own fts-like API, we can
remove these `#if os(WASI)` guards.

wasi-libc issue tracking fts support:
https://github.com/WebAssembly/wasi-libc/issues/520

Also, wasi-libc defines some constants in a way that ClangImporter can't
understand, so we need to grab them manually through _FoundationCShims in
function call form.

* Delegate error throwing decisions to the delegate
2024-08-12 19:52:15 -07:00
Yuta Saito
41cbea8b57
[wasm] Fall back to a default chunk size when st_blksize is not available (#835)
The `st_blksize` field in `stat` struct is not provided by WASI, so we
fall back to a default chunk size 4KB, which is a common page size.
2024-08-08 16:22:40 -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
Yuta Saito
2a6afeb50a
Implement _copyRegularFile for WASI without sendfile (#787)
WASI doesn't have `sendfile`, so we need to implement the copy in user
space with `read` and `write`. It's not as efficient as `sendfile`, but
it's the best we can do.
2024-08-01 10:50:04 -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
Saleem Abdulrasool
88d6a8d619
FoundationEssentials: make build on Android (#705)
This adjusts the API usage to account for differences on Android. The
biggest source of difference is the nullability, particularly in the
`fts` APIs. Unfortunately, `MMAP_FAILED` is not imported by the clang
importer due to the casting involved so we manually inline the constant
at the single site.
2024-07-01 16:44: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
e473ab75be
FoundationEssentials: fix up linkOrCopyFile on Windows (#675)
Adjust the Windows path for copying (or linking) files. This adds the
missing recursion in the copy (the documentation for `CopyFile2` was not
clear that the recursive copy is not performed).
2024-06-12 09:26:03 -07:00
Saleem Abdulrasool
21ed596f06
FoundationEssentials: adjust error code thrown (#671)
Rather than relaying the underlying system error, replace the error with
the expected error code. This repairs the test case expectation of the
thrown error.
2024-06-12 08:37:16 -07:00
Saleem Abdulrasool
9371cbf702
FoundationEssentials: correct callbacks for moveItem(atPath:toPath:) (#661)
In the case that the destination exists, we should check for continue
after error. If the source does not exist, simply do nothing.

Furthermore, adjust the test to ensure that we are using the path
spelling rather than the FSR.

Take the opportunity to correct an error in the tests where we would not
check the correct captured item set.
2024-06-06 13:54:46 -07:00
Saleem Abdulrasool
38d2d4e7a8
FoundationEssentials: silence a warning (#662)
Convert a `var` to `let` as it was originally. This variable is no
longer mutated and causes a warning.
2024-06-06 09:52:59 -07:00
Saleem Abdulrasool
413b15cbd8
FoundationEssentials: tweak removeFile(_:with:) on Windows (#659)
Ensure that we call the callbacks at the appropriate time. Change the
indentation and encapsulating scope to avoid a double callback.
2024-06-05 13:31:20 -07:00
Jeremy Schonfeld
418fe5bf96
Eliminate removefile shims fixing release mode build (#655)
* (128703942) Eliminate removefile shims

* state -> _
2024-06-04 20:03:35 -07:00
Saleem Abdulrasool
2e26c64cc4
FoundationEssentials: correct the entry spelling for iteration (#653)
When running the test suite we would hit an infinite loop due to the use
of the relative path rather than the absolute path for accessing the
attributes of the file entry.
2024-06-04 09:57:02 -07:00
Saleem Abdulrasool
d1ace948b5
(128078378) FoundationEssentials: correct error handling for item removal (#610)
The condition of the error check was inverted as it was meant to be a
`guard` statement. This was resulting in an infinite loop. With this we
now pass a few additional tests and the test suite no longer hangs.
2024-05-14 13:40:54 -07:00
Jeremy Schonfeld
727bd07830
Utilize URL in FileManager (#589)
* Use URL in FileManager

* Fix warnings

* Fix build failures on Linux

* Remove Locale_ICU warning fix
2024-05-07 15:55:08 -07:00
Saleem Abdulrasool
6ff08b28b8
FoundationEssentials: repair the Windows build after tweaks (#570)
The changes to repair the macOS/Linux build adversely impacted the
Windows build. Accommodate the API and logic changes for Windows.
2024-04-30 08:00:13 -07:00
Saleem Abdulrasool
aabac27b21
FoundationEssentials: implement file operations (#566)
This adds an initial implementation for file operations on Windows. With
this, `FileManager` should at least build on Windows, which unblocks
future work as well as brings us closer to enabling
`FoundationEssentials` on Windows.
2024-04-29 15:34:46 -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
e5211f2926
(122981400) Standardize on using internal import 2024-03-06 13:42:02 -08:00
Jeremy Schonfeld
beeea05206
(123438249) FileManager.removeItem does not throw error when encountering long paths
* (123438249) FileManager.removeItem does not throw error when encoutering long paths

The change makes swift-foundation FileManager.removeItem properly throw
on removefile(3) errors.

* Conform POSIXError to Error

* Clean up warnings and produce more detailed test failures

* Fix macOS CI failure
2024-02-28 13:33:55 -08:00
Jeremy Schonfeld
12d6069721
(123104044) Consolidate/standardize file-based error reporting
* Consolidate/standardize file-based error reporting

* Fix build failures

* Fix test failures
2024-02-16 16:50:16 -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