From 2dd18d9375bdbe05f70763019699fba143a06c3b Mon Sep 17 00:00:00 2001 From: WellRedPandit Date: Mon, 10 Apr 2017 19:46:40 -0400 Subject: [PATCH] - --- project/Deps.scala | 2 +- src/main/scala/wrp/smehotron/Smehotron.scala | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/project/Deps.scala b/project/Deps.scala index 92a7fd5..343005b 100644 --- a/project/Deps.scala +++ b/project/Deps.scala @@ -14,7 +14,7 @@ object V { val scalaXml = "1.0.6" val scopt = "3.5.0" val slf4j = "1.7.25" - val tron = "1.0.5" + val tron = "1.0.6" } object Deps { diff --git a/src/main/scala/wrp/smehotron/Smehotron.scala b/src/main/scala/wrp/smehotron/Smehotron.scala index 3d1a4e1..a339599 100644 --- a/src/main/scala/wrp/smehotron/Smehotron.scala +++ b/src/main/scala/wrp/smehotron/Smehotron.scala @@ -325,19 +325,22 @@ object Smehotron extends LazyLogging { } } - def resolve(f: File): String = { + def resolve(f: File, sep: String = File.separator): String = { val extend = Set("catalog", "sch-driver","source", "expected-svrl") val sax = new SAXBuilder() val doc = sax.build(f) + // http://stackoverflow.com/a/23870306 + val rx = if( sep == "/") "\\\\+" else "/+" + val sub = if( sep == "/") "/" else "\\\\" def _resolve(e: Element): Unit = { for( e <- e.getChildren.asScala) { if(extend.contains(e.getName)) { val base = findBase(e) if( base.nonEmpty) { - val newPath = (base.get + File.separator + e.getText).replaceAll(raw"[/\\]+", File.separator) + val newPath = (base.get + sep + e.getText).replaceAll(rx, sub) e.setText(newPath) } else { - e.setText(e.getText.replaceAll(raw"[/\\]+", File.separator)) + e.setText(e.getText.replaceAll(rx, sub)) } } _resolve(e)