-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support symlink for NioFSWrappingFS #1275
Conversation
5750324
to
fea8371
Compare
c294f3a
to
5a6e6d9
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.
I got confused a lot by JimFs (and its FS being in memory) but I think it's good now!
// TODO(Benoit) How do deal with multiple directories? Test with Windows someday. | ||
private val delegateRoot = javaNioFileSystem.rootDirectories.first() | ||
|
||
internal class NioFileSystemWrappingFileSystem(private val nioFileSystem: NioFileSystem) : NioSystemFileSystem() { | ||
/** | ||
* On a `java.nio.file.FileSystem`, `java.nio.file.Path` are stateful and hold a reference to the file system they | ||
* got provided from. We need to [resolve][java.nio.file.Path.resolve] all okio paths before doing operations on the | ||
* nio file system in order for things to work properly. | ||
*/ | ||
private fun Path.resolve(readSymlink: Boolean = false): NioPath { |
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.
Maybe I could rename the method to something else
5a6e6d9
to
cc917b2
Compare
path | ||
} | ||
} | ||
val result = entries.mapTo(mutableListOf()) { entry -> dir / entry.toString() } |
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.
everything's simpler once you start using it correctly....
Files.createSymbolicLink(source.resolve(), target.resolve()) | ||
val sourceNioPath = source.resolve() | ||
val targetNioPath = | ||
if (source.isAbsolute && target.isRelative) { |
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.
Why is this necessary? Relative symlinks should be okay?
9e5b9d1
to
00e31d5
Compare
00e31d5
to
a681001
Compare
@@ -2211,6 +2247,7 @@ abstract class AbstractFileSystemTest( | |||
@Test | |||
fun openSymlinkSink() { | |||
if (!supportsSymlink()) return | |||
if (isJimFileSystem()) return |
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.
No description provided.