joseph_ivie
08/14/2025, 11:01 PMkevin.cianfarini
08/14/2025, 11:07 PMkevin.cianfarini
08/14/2025, 11:07 PMtemporary function has a hidden static dependency on the system file system which is really difficult to use under test.joseph_ivie
08/14/2025, 11:08 PMSystemTemporaryDirectory which AFAIK only applies to the SystemFileSystem.joseph_ivie
08/14/2025, 11:10 PMFile was in many ways much better to use than the follow up Path specifically because I can't meaningfully use a Path without a file system attached anyways.
This combines the best of both worlds, making a nice syntax while enabling the use of multiple file systems.
The only thing I really don't like about it is atomicMove, which can crash due to poor usage by the user.joseph_ivie
08/14/2025, 11:11 PMMichael Paus
08/15/2025, 7:02 AMjoseph_ivie
08/15/2025, 2:29 PMval FileSystem.root: KFile get() = ...
SystemFileSystem.root.path("opt", "myprogram", "data.csv")Michael Paus
08/15/2025, 2:36 PMjoseph_ivie
08/15/2025, 2:40 PMZonedDateTime wrapper I made for KotlinX Date. It's just a convenience wrapper for moving data that is clearly associated around and doing operations that require both.
I wouldn't ever suggest removing Path and FileSystem in favor of this. This is just supposed to be a convenience and readability improvement tool.kevin.cianfarini
08/15/2025, 2:43 PMjava.io.File and java.nio.Path examples.joseph_ivie
08/15/2025, 3:16 PMThere's an HTTP client hiding in the URL class. When I call openStream(), that client is prepared and put to work. I don’t like being cut out of that setup! Ican't dependency-inject my own configured instance for production or a fake in a test.It's not hiding in
KFile. It's directly accessible and it can be controlled. If the argument is that there should be no default file system in the constructor, I can agree with that. In fact, I'll go change the definition in the snippet.
Creating a KFile now looks like this: SystemFileSystem.root.path("path", "to", "my", "file")
I might write an Android app that sends its collection of cached images to the server as a List<File>. My server could call File.delete() to free up space on that Android device, but that's not what would happen!
KFile isn't serializable, so no, you couldn't send it any more than you could send FileSystem. In addition, with the removal of the default file system in the constructor, it's clear to the user that you can't just use a String to represent this type.
Subclassingis another thing you could do, but shouldn’t:File
KFile is a final, transparent tuple of a separate identifier and service.
In short, I don't think any of the arguments made in the blog apply, at least not with the change I just made.
In addition, I think keeping Path and FileSystem separate in common usage actually has a different set of dangers - namely, accidentally using a Path with the wrong FileSystem! When moving them around in code, they should remain bound together. If you don't, you either have to have the discipline to pass them around together every time and keep which one belongs to which straight or - more likely, if you have junior devs - you'll end up having a bunch of functions just use SystemFileSystem hardcoded that need all of their headers changed.Mark
08/17/2025, 1:06 PMjw
09/20/2025, 4:09 AMjw
09/20/2025, 4:09 AMPath-like design as opposed to Okio's design.iseki
09/30/2025, 6:10 PMA: B: C: and so on, but also the \\server\hostname and even the \\?C:\ (I don't think we should hide the complexity to the user, it will make them failed when they need the platform string representation.).iseki
09/30/2025, 6:22 PMjoseph_ivie
09/30/2025, 7:12 PM/C/Program Files/whaterver
Not sure what makes more sense. I just need something standard to use for my library so that I'm not hurting adoption with non-standard API exposure. I'm no file systems expertiseki
09/30/2025, 7:15 PMexec("notepad.exe", txtPath.toString())iseki
09/30/2025, 7:16 PMiseki
09/30/2025, 7:18 PM/C/... can be also treated as <CUR_DRIVER>:\C\... Boom. So in my PR I remove any calls to MinGW and replaced them with Win32 API. Here's Windows, not POSIX compliant.joseph_ivie
09/30/2025, 7:35 PMPath should be a platform-independent strictly data-class concept, and I really really really don't want toString() to depend on the current platform, since at least in the current design, Path could be used to represent a path on several different file systems, each of which may have their own string rendering. You might be on Windows, but if you are using a FileSystem that represents a remote HTTP/REST based file system or some other form of remote file system, it doesn't really matter what Windows thinks the path format should be.
I think `KFile`'s toString() could support that case, however, since we would know what FileSystem is being referred to and what textual representation it uses.joseph_ivie
09/30/2025, 7:36 PMjoseph_ivie
09/30/2025, 7:37 PMKFile<FileSystemType> could actually be really good to explicitly restrict inputs to using local file systems in some scenarios?iseki
09/30/2025, 7:40 PMjoseph_ivie
09/30/2025, 7:41 PMPath.toString() intended for use with tools as a whole - heck, I might even deliberately choose its string representation to be something like [path, to, thing] just to prevent people from making assumptions that toString() could be used safely that way.joseph_ivie
09/30/2025, 7:41 PMKFile probably can't have a toString() for that reason.iseki
09/30/2025, 7:43 PMiseki
09/30/2025, 7:45 PMjava.nio.file.Path gave up to the problem, they represents all path in platform format...iseki
09/30/2025, 7:45 PMfile:// ?joseph_ivie
09/30/2025, 7:54 PMtoString() for KFile.
When you say "the problem" you're referring to the use of KFile or Path or whatever else in a practical setting with the command line or system tools, right? I think that having an explicit toPlatformString() that applies only to KFile<SystemFileSystem> would make a lot of sense, but really, even that seems imperfect. The only truly safe thing I can think of would probably be to have the CLI or process running tool have its own conversion function for converting a KFile or Path into a string for usage.joseph_ivie
09/30/2025, 7:55 PMfun exec(vararg args: KFile<SystemFileSystem> | String) or something like that being a good function header, but we don't have union typesiseki
09/30/2025, 7:56 PMjoseph_ivie
09/30/2025, 7:56 PMtoString() to toDebugString() or something like that.joseph_ivie
09/30/2025, 7:57 PMList<String> under the hood of Path is probably the closest to both making sense and being universally compatible, but even then that makes .. and . kind of strange. kotlinx.io.Path isn't attached to a particular file system - to attach it, I recommended KFile which is the class at the top of this thread.joseph_ivie
09/30/2025, 7:58 PMjoseph_ivie
09/30/2025, 7:59 PMList<String | ParentFileReference> perhapsiseki
09/30/2025, 8:00 PM\\?\MY_LAPTOP\shaRe\foo
C:\shAre\foo
\share\foo
fOo
You're also have to consider how to handling the equality(case sensitive or insensitive). I'm still not refer to dot and dotdot.joseph_ivie
09/30/2025, 8:01 PMiseki
09/30/2025, 8:03 PMiseki
09/30/2025, 8:04 PMiseki
09/30/2025, 8:04 PMjoseph_ivie
09/30/2025, 8:06 PMFile with platform compatibility more times than I can count.iseki
09/30/2025, 8:09 PMjava.nio.file.Path . No string representation except I have to I/O the path...joseph_ivie
09/30/2025, 8:10 PMPath and File and whatever else. These days I work hard to make sure they don't go in or out of string representation wherever humanly possible