-
Notifications
You must be signed in to change notification settings - Fork 10
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
Refactor: use camino utf8-path types where applicable #59
Conversation
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.
I'm fine with the change, it doesn't change anything semantically and the dependency isn't an addition to the (already quite large) tree.
let author = if self.authors.is_empty() { | ||
String::from("Unspecified Author") // as standard with the devkitPRO toolchain | ||
} else { | ||
self.authors.join(", ") |
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.
Originally, I believe I made the choice of including only the first author because there was the slight risk that the combined name of all authors might exceed the SMDH limitations (which is a lengthy 128 bytes in UTF-16 https://www.3dbrew.org/wiki/SMDH#Format, but will never be shown in its entirety if it gets this long).
I guess it doesn't really matter either way, since the authors
field is more-or-less getting abandoned by the Rust community (it's not even shown on crates.io anymore). I'm fine with the change.
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.
Ah, hmm... from looking at the smdhtool
implementation, it seems like anything longer will just get truncated to 0x40
characters anyway: https://github.com/devkitPro/3dstools/blob/master/src/smdhtool.cpp#L423-L429 — manually testing it seems to work as expected too.
We could add a length check of our own and panic if the joined string is too long, but it would require calculating the UTF-16 length of the input UTF-8 string, so I think just letting it get truncated seems fine. Once #58 is implemented users will also be able to override the author string to their liking without needing to modify Cargo.toml
's package.authors
field.
Address review comments and minor cleanup
This is a refactor in preparation for #58 (which I'll need to rebase after this is merged).
I think the changes probably should have no effect — basically this just enforces all paths must be UTF-8. Since we already used
String
all over the place I think that was already kinda required, but now it should be reflected in the types we are using too. Otherwise, I just did some minor cleanup.camino
was already a transitive dependency viacargo_metadata
so no additional code to compile there.One behavior change: all author names are included (joined by
", "
) instead of just the first one, if there's more than one listed for the package.