-
Notifications
You must be signed in to change notification settings - Fork 54
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
Extend filesystem support #213
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.
Just a few doc comment fix suggestions. Looking forward to the next release with these features.
Also, if you feel inclined to fix, I noticed utilApple.kt
got an extra redundant ExperimentalForeignApi
OptIn
added:
@file:OptIn(UnsafeNumber::class, ExperimentalForeignApi::class, ExperimentalForeignApi::class)
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.
Nice work!
Please also update README overview/links
Co-authored-by: Jeff Lockhart <jeffdgr8@gmail.com>
* @throws kotlinx.io.IOException when [path] already exists and [mustCreate] is `true`. | ||
* @throws kotlinx.io.IOException when the creation of one of the directories fails. | ||
*/ | ||
public fun createDirectories(path: Path, mustCreate: Boolean = false) |
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.
what happens if mustCreate=false
, an entity on such a path already existed, but it was a file?
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 think it's fine to abstain from reporting an error in that case as the path already exists. Not sure if we need to be more strict about what this path is actually pointing to.
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.
For example, I want to create /a/b/c
directories, but there is already a /a/b/c
file in the file system and at the same time the mustCreate=false
flag.
On the one hand, we cannot throw path already exists error, on the other hand, I call the function of creating directories. It turns out that an error has occurred, but I will receive a message about it postponed when I try to create a new file /a/b/c/my.txt
(this is often whatcreateDirectories
is called for)
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Nice!
Some minor comments. The only major thing for me is naming of FileSytem.read/write
methods
9446187
to
a23f789
Compare
d3d7a77
to
82230d4
Compare
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.
Nice!
Have a few more or less minor comments and it's good to go
import kotlinx.io.RawSource | ||
|
||
/** | ||
* An interface providing basic operations on a filesystem. |
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.
Would be nice to enrich the top-level documentation in the follow up PR
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.
* @throws kotlinx.io.IOException when [path] already exists and [mustCreate] is `true`. | ||
* @throws kotlinx.io.IOException when the creation of one of the directories fails. | ||
*/ | ||
public fun createDirectories(path: Path, mustCreate: Boolean = false) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
df9f483
to
6596964
Compare
This PR is not about bringing full filesystems support, but it rather adds few functions to make life easier.
The change adds basic path processing functions to
Path
:parent
to get the parent path, backed bydirname
on most platformsname
to get the file/directory name, backed bybasename
on most platformsisAbsolute
to check if the path is relative or absolute.Paths, unlike in Okio, are platform dependent, so
a/b\\c.txt
has different meaning on Windows and Linux.PR also brings few functions to work with filesystem. The design is driven by Okio's FileSystem, but functionality are not even close to it.
Supported functionality:
kotilnx.io.files
package remains experimental (even compared to the whole library not being stable yet).Closes: #206 #211 #212 #183 #214