From 8718c9310c0a287c2fbfe6431ef28ceb6507e2a1 Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Mon, 5 Jun 2023 18:52:53 -0400 Subject: [PATCH] Remove workaround for Scala Native issue #3293, it was resolved in v.0.4.13 See https://github.com/scala-native/scala-native/issues/3293 --- .../ij_plugins/imagej_launcher/Updater.scala | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/main/scala/ij_plugins/imagej_launcher/Updater.scala b/src/main/scala/ij_plugins/imagej_launcher/Updater.scala index d73e70c..62219c4 100644 --- a/src/main/scala/ij_plugins/imagej_launcher/Updater.scala +++ b/src/main/scala/ij_plugins/imagej_launcher/Updater.scala @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2000-2023 Jarek Sacha. All Rights Reserved. + * Author's e-mail: jpsacha at gmail.com + */ + package ij_plugins.imagej_launcher import os.{Path, RelPath} @@ -23,8 +28,7 @@ object Updater: os.walk(updateDir) .filter(os.isFile) .foreach: src => -// val relativeDir = src.relativeTo(updateDir) - val dst = ijDir / relativeTo(src, updateDir) + val dst = ijDir / src.relativeTo(updateDir) if os.size(src) == 0 then logger.debug(s"remove: $dst") if !dryRun then os.remove(dst) @@ -45,25 +49,6 @@ object Updater: ex.printStackTrace() Left(s"Failed to perform update: ${ex.getMessage} - ${ex.getClass.getSimpleName}") - private def relativeTo(src: Path, base: Path): RelPath = - // This does what src.relativeTo(base) should do - // 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 - require(baseStr.nonEmpty) - require(srcStr.startsWith(baseStr)) - - 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)