Open ghost opened 6 years ago
We could remove all ambiguity and assumptions and be more explicit:
enum ExtensionOption {
case keep
case remove
case `extension`(String)
}
public func rename(to name: String, extension: ExtensionOption) throws
And provide a convenience overload that would take a String
public func rename(to name: String, extension: String) throws {
try rename(to: name, extension: .extension(extension))
}
That way name and extension are both treated as separate parts.
What do you think @rob-nash?
Ye that's a good idea. How about.
enum ExtensionOption {
case keep
case remove
case change(to: String)
}
Is to:
possible ?
I like that. Yeah, it's possible. And it's fantastic.
In order to not break existing code, we'd have to provide a default parameter:
public func rename(to name: String, extension: ExtensionOption = .keep) throws
Which would cover the case where users had used:
try someFile.rename(to: "SomeOtherFile") // without keepExtension
~And then deprecate the previous signature.~ The previous method can be kept around (and would defer to the new method) but its default value of keepExtension = true
has to be removed to avoid ambiguity.
hi @clayellis how might I get in touch with you directly? Are you on twitter?
@rob-nash yep! https://twitter.com/clay_ellis DMs are open. Sorry for the late response — just finished packing/moving into a new house.
Hi @clayellis I think DM's only work if you follow me. I'm not fishing for followers 😜 🙄
Email? robscode@icloud.com
Hi @JohnSundell ,
I'm enjoying the Files API and I'm glad I can help in any way. Even if my contributions are just discussion points that lead to potential pull requests from others.
I have, yet another, discussion point to raise. I hope you don't mind.
RenameItem
Unless I examine the source, it's not clear here if
newName
isname only
orname + extension
.Further, I currently have a situation where the above API is inconvenient.
At the moment I'm unpacking a .pdf file from a CKAsset instance (CloudKit).
.pdf
extension.Perhaps, we might want to have something like the following?
And maybe we can examine the name to see if it contains a
"."
Do you think this is a valid issue and do you have any ideas on this?