Skip to content

Commit 0c3e55b

Browse files
committed
Path fix for doc-tool and QuoteDriver
In QuoteDriver, previous we have path like the following on windows: /C:/Users/dotty/My%20Programs/Java/Test/bin/myJar.jar Credit: https://stackoverflow.com/questions/6164448/convert-url-to-normal-windows-filename-java
1 parent 0a7ffbc commit 0c3e55b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ object QuoteDriver {
9696
case cl: URLClassLoader =>
9797
// Loads the classes loaded by this class loader
9898
// When executing `run` or `test` in sbt the classpath is not in the property java.class.path
99-
val newClasspath = cl.getURLs.map(_.getFile())
99+
import java.nio.file.Paths
100+
val newClasspath = cl.getURLs.map(url => Paths.get(url.toURI).toFile)
100101
newClasspath.mkString("", java.io.File.pathSeparator, if (classpath0 == "") "" else java.io.File.pathSeparator + classpath0)
101102
case _ => classpath0
102103
}

doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ case class Site(
167167
private def defaultParams(pageLocation: JFile, additionalDepth: Int = 0): DefaultParams = {
168168
val pathFromRoot = stripRoot(pageLocation)
169169
val baseUrl: String = {
170-
val rootLen = root.getAbsolutePath.split(sep).length
171-
val assetLen = pageLocation.getAbsolutePath.split(sep).length
172-
"../" * (assetLen - rootLen - 1 + additionalDepth) + "."
170+
val rootLen = root.toPath.normalize.getNameCount
171+
val assetLen = pageLocation.toPath.normalize.getNameCount
172+
"../" * (assetLen - rootLen + additionalDepth) + "."
173173
}
174174

175175
DefaultParams(
@@ -203,7 +203,7 @@ case class Site(
203203

204204
val path = if (scala.util.Properties.isWin)
205205
e.path.map(_.replace("<", "_").replace(">", "_"))
206-
else
206+
else
207207
e.path
208208
val target = mkdirs(fs.getPath(outDir.getAbsolutePath + sep + "api" + sep + path.mkString(sep) + suffix))
209209
val params = defaultParams(target.toFile, -1).withPosts(blogInfo).withEntity(Some(e)).toMap

0 commit comments

Comments
 (0)