-
Notifications
You must be signed in to change notification settings - Fork 61
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 a Path.toFile()
converter on JVM
#292
Comments
I also would like to add that |
I totally agree that these functions would be quite handy, and for now everything should work fine. However, thinking of a direction we're going evolve fs-API, there might be some issues. Currently, kx-io's In that case For |
Huge +1 to this design. Using Okio's FS APIs I sorely miss the NIO design. |
Perhaps kx-io's Say for example, the concrete implementation is a class named Now, say We could then mimic that design for other platforms, in case there's a much better platform-dependent object (similar to Java's The downside to this is that, Additionally, the default or system Suppose one wants a portable interpretation of However, at this point, I'm getting off-topic, and I might even suggest a |
P.S. That |
…and perhaps also, a
Path.toNioPath()
on JVM.Okio has a similar
Path.toFile()
method, along with a complementaryPath.toNioPath()
.While you could technically convert a
Path
into a string and then create a newjava.io.File
out of it, it feels like a waste when there's already aFile
object underneath that we could use. Ifkotlinx-io
has aPath.toFile()
, thenPath.toNioPath()
could also simply be implemented aspath.toFile().toPath()
, which would also return the same NIOPath
instance every time.Now of course, there's also the possibility that the underlying object implementing
Path
will not be aFile
anymore in the future. So the described performance win is irrelevant. However, I also think having such utility conversion methods would be convenient especially when trying to interoperate with JVM (or Android). It's useful for providing features currently present in the JVM but not inkotlinx-io
, such as when implementing a customFileSystem
backed by JVM APIs, or when adding platform-dependent features. Also useful when you need a quick way to interop with some Java library that happens to require aFile
or NIOPath
.Parsing and manipulating paths is also one area where you're not touching the underlying file system to induce IO overhead, but when doing a lot of parsing and manipulation, you generally want that to be performant, so as to not waste precious CPU and battery life unnecessarily, especially when on Android.
The text was updated successfully, but these errors were encountered: