diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy index 91e94357..a1b94650 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy @@ -46,6 +46,10 @@ final class QuiltPath implements Path, Comparable { private final String[] paths private final boolean isFileName + static String joinOs(String... parts) { + return parts.join(FileSystems.getDefault().getSeparator()) + } + QuiltPath(QuiltFileSystem filesystem, QuiltParser parsed, boolean isFileName = false) { this.filesystem = filesystem this.parsed = parsed @@ -215,15 +219,17 @@ final class QuiltPath implements Path, Comparable { Path relativize(Path other) { if (this == other) { return null } String file = (other in QuiltPath) ? ((QuiltPath)other).localPath() : other.toString() - String base = [pkg().toString(), parsed.getPath()].join(FileSystems.getDefault().getSeparator()) - log.debug("relativize[$base] in [$file]") + String base = joinOs(pkg().toString(), parsed.getPath()) + println("relativize[$base] in [$file]") int i = file.indexOf(base) if (i < 1) { throw new UnsupportedOperationException("other[$file] does not contain package[$base]") } String tail = file.substring(i + base.size()) - if (tail.size() > 0 && tail[0] == '/') { tail = tail.substring(1) } // drop leading "/" + if (tail.size() > 0 && (tail[0] == '/' || tail[0] == '\\')) { + tail = tail.substring(1) + } // drop leading separator //log.debug("tail[$i] -> $tail") return Paths.get(tail) } diff --git a/plugins/nf-quilt/src/test/nextflow/quilt/QuiltSpecification.groovy b/plugins/nf-quilt/src/test/nextflow/quilt/QuiltSpecification.groovy index b38ab544..ba40aa7b 100644 --- a/plugins/nf-quilt/src/test/nextflow/quilt/QuiltSpecification.groovy +++ b/plugins/nf-quilt/src/test/nextflow/quilt/QuiltSpecification.groovy @@ -23,6 +23,7 @@ import nextflow.quilt.jep.QuiltPackage import java.nio.ByteBuffer import java.nio.channels.SeekableByteChannel import java.nio.file.FileSystem +import java.nio.file.FileSystems import java.nio.file.Files import java.nio.file.Paths import java.nio.file.Path @@ -51,6 +52,10 @@ class QuiltSpecification extends Specification { return 'quilt+s3://udp-spec#package=nf-quilt/source' } + static String OsConvert(String path) { + return path.replace('/', FileSystems.getDefault().getSeparator()) + } + @Shared String testURI @Shared String pluginsMode diff --git a/plugins/nf-quilt/src/test/nextflow/quilt/nio/QuiltNioTest.groovy b/plugins/nf-quilt/src/test/nextflow/quilt/nio/QuiltNioTest.groovy index 0303b252..823f3329 100644 --- a/plugins/nf-quilt/src/test/nextflow/quilt/nio/QuiltNioTest.groovy +++ b/plugins/nf-quilt/src/test/nextflow/quilt/nio/QuiltNioTest.groovy @@ -565,8 +565,8 @@ class QuiltNioTest extends QuiltSpecification { dirs.size() == 4 dirs.contains('null') dirs.contains('foo') - dirs.contains('foo/bar') - dirs.contains('foo/bar/baz') + dirs.contains(OsConvert('foo/bar')) + dirs.contains(OsConvert('foo/bar/baz')) when: dirs = [] @@ -657,8 +657,8 @@ class QuiltNioTest extends QuiltSpecification { dirs.contains('foo') files.size() == 3 files.containsKey('foo') - files.containsKey('foo/bar') - files.containsKey('foo/baz') + files.containsKey(OsConvert('foo/bar')) + files.containsKey(OsConvert('foo/baz')) } void 'should handle file names with same prefix'() {