You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following snippet exits successfully when importing Foundation (macOS or Linux), but if you instead import FoundationEssentials it throws an error when creating temp.
import Foundation // Comment this line and uncomment the next to see the issue
// import FoundationEssentials
print("Creating documents...")letdocuments=tryFileManager.default.url(
for:.documentDirectory,
in:.userDomainMask,
appropriateFor:nil,
create: true
)print("Creating temporary...")
// Raises FoundationEssentials.CocoaError(code: FoundationEssentials.CocoaError.Code(rawValue: 256), userInfo: [:])
lettemp=tryFileManager.default.url(
for:.itemReplacementDirectory,
in:.userDomainMask,
appropriateFor: documents,
create: true
)print("Results")print(temp)print(FileManager.default.fileExists(atPath: temp.path(percentEncoded: false)))
You can run this with the swift:6.0.1 Docker image to see the issue.
Expected behavior
I think temp should be a temporary directory which has been created, probably somewhere like /tmp/abc123/NSIRD_test.swift_xyz456/. I feel that’s the best approximation of what happens on macOS (where we get something like /var/folders/q0/abc123/T/TemporaryItems/NSIRD_test.swift_xyz456/). The particular format isn’t particularly important — I’m basically just looking for a portable form of mkdtemp.
Or at the very least the behavior shouldn’t change when the imported module changes.
Actual behavior
An error is raised from the indicated line (FoundationEssentials only).
The text was updated successfully, but these errors were encountered:
This call has differing behavior when importing
Foundation
vs when importingFoundationEssentials
on Linux:Reproduction
The following snippet exits successfully when importing Foundation (macOS or Linux), but if you instead import FoundationEssentials it throws an error when creating
temp
.You can run this with the
swift:6.0.1
Docker image to see the issue.Expected behavior
I think
temp
should be a temporary directory which has been created, probably somewhere like/tmp/abc123/NSIRD_test.swift_xyz456/
. I feel that’s the best approximation of what happens on macOS (where we get something like/var/folders/q0/abc123/T/TemporaryItems/NSIRD_test.swift_xyz456/
). The particular format isn’t particularly important — I’m basically just looking for a portable form ofmkdtemp
.Or at the very least the behavior shouldn’t change when the imported module changes.
Actual behavior
An error is raised from the indicated line (FoundationEssentials only).
The text was updated successfully, but these errors were encountered: