-
Notifications
You must be signed in to change notification settings - Fork 64
Extend filesystem support #213
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
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
d9a0e11
Basic FS options
fzhinkin 406c5ac
Implement move on linux
fzhinkin 7e36522
Updated API dump
fzhinkin 54ad37a
Reimplemented tempFileName
fzhinkin 2969314
Add platform-specific Path.parent
fzhinkin 568fefb
Fixed Path.parent behavior
fzhinkin 58c607b
Support mkdirs
fzhinkin 16b6733
Debug test failure
fzhinkin c2b8770
Debug test failure
fzhinkin dbbc66f
Fix dirname on Linux
fzhinkin 6296c41
Added some documentation, implemented eq/hc for Path and fixed tests
fzhinkin 5bcc04e
Cleanup
fzhinkin 1f21fa4
Renamed files
fzhinkin 5a7eb00
Cleanup
fzhinkin e8640ec
Improve exception message
fzhinkin 7cae417
Fixed test
fzhinkin eb9293f
Fixed test failures on Windows
fzhinkin 1c7150a
Support Path.name, Path.isAbsolute and path metadata retrieval
fzhinkin e4c3f8e
Throw FileNotFoundException where applicable
fzhinkin 93f6387
Fix path handling on Windows
fzhinkin e6e8f66
Updated documentation
fzhinkin ce99021
Fixed concatenation
fzhinkin 5ec5c5a
Seal FileSystem interface
fzhinkin 63385d2
Update Api
fzhinkin d664d37
Fixed typos
fzhinkin 87d45f8
Support file size retrieval
fzhinkin 1534d3e
Stub Wasm FS implementation
fzhinkin 70b706f
Renamed test methods
fzhinkin aad5f56
Sanity test for Path::equals
fzhinkin ff6ec3d
Fixed/clarified KDoc and added/fixed related tests
fzhinkin a23f789
Make temporaryDir independent of a particular FS instance
fzhinkin 76506b0
Cleanup
fzhinkin 7ba61cb
Use anonymous system FS subclasses
fzhinkin 15e94ed
Cleanup
fzhinkin 73feef4
Supported append-to-file mode for sinks, changes sink/source signatures
fzhinkin 5dd47e1
Make Path.source/sink regular functions, not expects.
fzhinkin a086319
Improve move docs and add tests
fzhinkin 82230d4
Updated doc, removed some checks from the atomicMoveDir test
fzhinkin 8ce1616
Improved documentation
fzhinkin e31befe
Throw exception when createDirectories failed because path exists and…
fzhinkin 1914297
Move Path.separator, FS.SystemFS and FS.SystemTempDir to top-level co…
fzhinkin 6596964
Cleanup
fzhinkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. | ||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
package kotlinx.io.files | ||
|
||
import kotlinx.cinterop.ExperimentalForeignApi | ||
import kotlinx.cinterop.toKString | ||
import platform.posix.__posix_basename | ||
import platform.posix.dirname | ||
|
||
@OptIn(ExperimentalForeignApi::class) | ||
internal actual fun dirnameImpl(path: String): String { | ||
return dirname(path)?.toKString() ?: "" | ||
} | ||
|
||
@OptIn(ExperimentalForeignApi::class) | ||
internal actual fun basenameImpl(path: String): String { | ||
return __posix_basename(path)?.toKString() ?: "" | ||
} | ||
|
||
internal actual fun isAbsoluteImpl(path: String): Boolean = path.startsWith('/') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. | ||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. | ||
*/ | ||
@file:OptIn(ExperimentalForeignApi::class) | ||
|
||
package kotlinx.io.files | ||
|
||
import kotlinx.cinterop.ExperimentalForeignApi | ||
import kotlinx.cinterop.cstr | ||
import kotlinx.cinterop.memScoped | ||
import kotlinx.cinterop.toKString | ||
import kotlinx.io.IOException | ||
import platform.Foundation.NSTemporaryDirectory | ||
import platform.posix.* | ||
|
||
|
||
internal actual fun atomicMoveImpl(source: Path, destination: Path) { | ||
if (rename(source.path, destination.path) != 0) { | ||
throw IOException("Move failed: ${strerror(errno)?.toKString()}") | ||
} | ||
} | ||
|
||
public actual val SystemTemporaryDirectory: Path | ||
get() = Path(NSTemporaryDirectory()) | ||
|
||
internal actual fun dirnameImpl(path: String): String { | ||
memScoped { | ||
return dirname(path.cstr.ptr)?.toKString() ?: "" | ||
} | ||
} | ||
|
||
internal actual fun basenameImpl(path: String): String { | ||
memScoped { | ||
return basename(path.cstr.ptr)?.toKString() ?: "" | ||
} | ||
} | ||
|
||
internal actual fun isAbsoluteImpl(path: String): Boolean = path.startsWith('/') | ||
|
||
internal actual fun mkdirImpl(path: String) { | ||
if (mkdir(path, PermissionAllowAll) != 0) { | ||
throw IOException("mkdir failed: ${strerror(errno)?.toKString()}") | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.