-
Notifications
You must be signed in to change notification settings - Fork 653
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
feat: Add String(contentsOf: FilePath ...)
#3048
base: main
Are you sure you want to change the base?
Conversation
Motivation: Makes it possible to read contents of an NIOFileSystem.FilePath into a String directly. 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm 100% fine with this change, but given that we're considering using a type other than FilePath
in this module, I wonder if we should sit on this a little bit. @glbrntt?
@Lukasa This is in the
So I would argue that it's better to merge this as it lessens the likelihood that this gets forgotten. And because it's in the underscored module, there's no risk to paint ourselves into a corner. |
It's the big change that I'm concerned about: I wonder whether it's particularly egregious to add a method whose immediate future is to be deprecated or removed in favour of one with a different type. |
I'd be more concerned if this was isolated to a single API, but given we'll have to deprecate and replace many APIs I don't really see this as an issue. |
+1, same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks for opening this! DocC is unhappy about a reference and Johannes' comment re: the copyright header needs addressing but otherwise this looks great.
/// - maximumSizeAllowed: The maximum size of file which can be read, in bytes, as a ``ByteCount``. If the file is larger than this, an error is thrown. | ||
/// - fileSystem: The ``FileSystemProtocol`` instance to use to read the file. | ||
/// | ||
/// - Throws: If the file is larger than `maximumSizeAllowed`, an ``FileSystemError.resourceExhausted`` error will be thrown. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DocC is unhappy with the FileSystemError.resourceExhausted
here. I think you need to say that an error with code FileSystemError/Code-swift.struct/resourceExhausted
is thrown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL. Seems to work, pushing up now.
Motivation:
Makes it possible to read contents of an NIOFileSystem.FilePath into a String directly. Closes #3010.
Modifications:
String+FileSystem.swift
intoNIOFileSystem
target.ConvenienceTests.swift
.Array+FileSystem
initializer as well.Result:
FilePath
is now availableFilePath
now has a test/cc @weissi