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
This commit is contained in:
Jarek Sacha 2023-06-05 18:52:53 -04:00
parent c30b853f64
commit 8718c9310c
No known key found for this signature in database
GPG key ID: F29625CE62288163

View file

@ -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)