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

Add okio or kotlinx-io Path conversion extensions #492

Open
mgroth0 opened this issue Mar 5, 2024 · 6 comments
Open

Add okio or kotlinx-io Path conversion extensions #492

mgroth0 opened this issue Mar 5, 2024 · 6 comments

Comments

@mgroth0
Copy link

mgroth0 commented Mar 5, 2024

Title says it all. Using something like kotlinx-io to support even a subset of the path features in native would be excellent

@JakeWharton
Copy link

JakeWharton commented Mar 5, 2024

Since that library is not stable, you're better off doing a manual convert for now. I suspect once it does go stable it will be supported.

You could also use Okio's multiplatform file system. It is stable, but I wouldn't expect Clikt to take it as a dependency for built-in support. Example:

https://github.com/JakeWharton/video-swatch/blob/484148cc6884ad75652881b7c7c76255991986ca/src/commonMain/kotlin/com/jakewharton/videoswatch/main.kt#L71-L72

@ajalt
Copy link
Owner

ajalt commented Mar 5, 2024

I don't generally have library-specific extensions since calling .convert { it.toWhatever } seems easy enough. But since paths have some extra validation functionality like canBeFolder, it might make sense to provide that once kotlinx-io is stable.

@mgroth0
Copy link
Author

mgroth0 commented Mar 15, 2024

@JakeWharton I actually wasn't aware about okio for native filesystem operations. I tried it and it is working really well. Thank you!

And @ajalt, you are right and that is exactly why I made this issue. Because the JVM API is more than just a conversion but also has fancy checks like canBeFolder, it would seem beneficial to support than more evenly across platforms if possible.

@ajalt ajalt changed the title Support path arguments for native Add okio or kotlinx-io Path conversion extensions Dec 2, 2024
@Wavesonics
Copy link

makes sense, might be nice to add an example to the docs where it says that file and path are only available on the jvm, and point people to this solution.

@ajalt
Copy link
Owner

ajalt commented Dec 2, 2024

The docs on multiplatform support already mention that they're JVM-only.

@Wavesonics
Copy link

Right, I'm suggesting it mention that for other targets you could use Okio and add a .convert()

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

No branches or pull requests

4 participants