Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIOFileSystem: missing String(contentsOf:maximumSizeAllowed:) #3010

Closed
weissi opened this issue Dec 1, 2024 · 1 comment · Fixed by #3048
Closed

NIOFileSystem: missing String(contentsOf:maximumSizeAllowed:) #3010

weissi opened this issue Dec 1, 2024 · 1 comment · Fixed by #3048

Comments

@weissi
Copy link
Member

weissi commented Dec 1, 2024

Expected behavior

        let string = try await String(
            contentsOf: "/etc/hosts",
            maximumSizeAllowed: .mebibytes(12)
        )

should work.

Actual behavior

API not available

@ali-ahsan-ali
Copy link
Contributor

ali-ahsan-ali commented Dec 8, 2024

Taking a look 👍🏽. Does this need triaging first, as in do the CODEOWNERS need to approve this API should exist?

EDIT: Any pointers on starting. At first I thought we could re-use the same Array API since the result is a ByteBuffer that can then be turned into a String, but I wonder if there is something else that is the intended solution.

glbrntt added a commit that referenced this issue Jan 16, 2025
### Motivation:

Makes it possible to read contents of an NIOFileSystem.FilePath into a
String directly. Closes #3010.

### Modifications:

- Added a new `String+FileSystem.swift` into `NIOFileSystem` target.
- Added basic tests to the existing `ConvenienceTests.swift`.
- Added a test to cover `Array+FileSystem` initializer as well.

### Result:

- String initializer for `FilePath` is now available
- Array initializer for `FilePath` now has a test

---------

Co-authored-by: George Barnett <[email protected]>
Co-authored-by: Cory Benfield <[email protected]>
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 a pull request may close this issue.

2 participants