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

Singular createDirectory #280

Open
mgroth0 opened this issue Mar 9, 2024 · 1 comment
Open

Singular createDirectory #280

mgroth0 opened this issue Mar 9, 2024 · 1 comment

Comments

@mgroth0
Copy link

mgroth0 commented Mar 9, 2024

There only exists createDirectories but not a singular createDirectory. A singular createDirectory operation has the beneficial feature of a built in assertion that the parent folder already exists. Currently, I work round this with something like:

fun FileSystem.createDirectory(path: Path, mustCreate: Boolean = true) {
    check(exists(path.parent!!))
    createDirectories(path,mustCreate=mustCreate)
}

This is not ideal becasuse the operation now involves two IO instructions, when I would expect this to be a single IO instruction.

Is there a technical reason why this is difficult to implement, or is it by design?

@fzhinkin
Copy link
Collaborator

No technical reasons not to have such a method (in fact, createDirectories creates directories one by one while climbing up parent paths chain). Current FS support was not properly designed, so it consists of some more or less randomly selected functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants