From 78448de03da4e96e3370e7f9e23a5e5029c1740e Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Thu, 25 May 2023 09:22:14 -0400 Subject: [PATCH] Update note on `relativeTo` workaround and the bug in Scala Native See https://github.com/scala-native/scala-native/issues/3293 --- .../scala/ij_plugins/imagej_launcher/Updater.scala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/scala/ij_plugins/imagej_launcher/Updater.scala b/src/main/scala/ij_plugins/imagej_launcher/Updater.scala index 8720fe5..5c298c7 100644 --- a/src/main/scala/ij_plugins/imagej_launcher/Updater.scala +++ b/src/main/scala/ij_plugins/imagej_launcher/Updater.scala @@ -48,9 +48,14 @@ object Updater: private def relativeTo(src: Path, base: Path): RelPath = // This does what src.relativeTo(base) should do - // Problems is in the native code on Windows, it creates relative path by adding `../` at the beginning of the path - // rather than creating a relative path - // Implementation is very limited and assumes specific relation between src and base that should hold in our case + // Problems is in the native code on Windows, + // os.Path#relativeTo creates relative path by adding `../` at the beginning of the absolute path, + // co you may get `../C:\a\b` which leads to a exception soon after. + // The issue is with Scala Native implementation of java.nio.file.Path#relativize on Windows, + // See https://github.com/scala-native/scala-native/issues/3293 + + // This implementation is very limited but sufficient for our use. + // It assumes specific relation between src and base. val srcStr = src.toString val baseStr = base.toString @@ -60,7 +65,6 @@ object Updater: val relStr = srcStr.drop(baseStr.length + 1) RelPath(relStr) - private def deleteEmptyDirs(dir: Path, logger: Logger): Unit = logger.debug(s"Cleaning directory: $dir") os.list(dir)