Skip to content

Fix readFileContents to support non-regular files via FileHandle fallback#566

Merged
bkhouri merged 1 commit into
swiftlang:release/6.4.xfrom
daveinglis:fix/readfilecontents
Jun 25, 2026
Merged

Fix readFileContents to support non-regular files via FileHandle fallback#566
bkhouri merged 1 commit into
swiftlang:release/6.4.xfrom
daveinglis:fix/readfilecontents

Conversation

@daveinglis

Copy link
Copy Markdown
Contributor

The Data API is used for regular files (mmap performance) and FileHandle is the fallback for pipes, FIFOs, and character devices that Data rejects.

cherrypicked from main so we don't regress in 6.4

…back (swiftlang#562)

The Data API is used for regular files (mmap performance) and
FileHandle is the fallback for pipes, FIFOs, and character devices
that Data rejects.
@daveinglis

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@bkhouri

bkhouri commented Jun 25, 2026

Copy link
Copy Markdown

@swift-ci test

@bkhouri bkhouri enabled auto-merge (squash) June 25, 2026 16:25
@bkhouri bkhouri merged commit d45c8b3 into swiftlang:release/6.4.x Jun 25, 2026
52 checks passed
daveinglis added a commit to swiftlang/swift-package-manager that referenced this pull request Jun 27, 2026
…#10235)

Adds tests to catch a regression (rdar://174417799) where
`localFileSystem.readFileContents` broke for FIFOs, named pipes, and
`/dev/stdin` after TSC switched from `fopen/fread` to
`Data(contentsOf:)`, which rejects non-regular files.


-`FileSystemTests.localFileSystemReadFileContentsAcceptsNonRegularFile`:
unit test that calls `localFileSystem.readFileContents` directly on a
FIFO and verifies the content is read correctly.
- `PackageRegistryCommandTests.tokenFileAcceptsNonRegularFile`:
functional test that runs `swift package-registry login --token-file
<fifo>` and verifies the command fails at the network step rather than
the file-read step, confirming `--token-file` accepts non-regular files
as it did before the regression.

Validates:
#9915

cherrypicked from main

Depends on:
swiftlang/swift-tools-support-core#566
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants