Skip to content

Commit aa951f6

Browse files
committed
Alternative fix
1 parent 3ece9d5 commit aa951f6

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

compiler/src/dotty/tools/dotc/classpath/ClassPath.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ trait SourceFileEntry extends ClassRepresentation {
2424

2525
case class PackageName(dottedString: String) {
2626
def isRoot: Boolean = dottedString.isEmpty
27-
val dirPathTrailingSlash: String = FileUtils.dirPathInArchive(dottedString) + "/"
27+
val dirPathTrailingSlash: String = FileUtils.dirPath(dottedString) + java.io.File.separatorChar
2828

2929
def entryName(entry: String): String = {
3030
if (isRoot) entry else {

compiler/src/dotty/tools/dotc/classpath/FileUtils.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ object FileUtils {
4242
else if (endsJava(fileName)) stripJavaExtension(fileName)
4343
else throw new FatalError("Unexpected source file ending: " + fileName)
4444

45+
/** Returns the relative directory path with `/` as separator */
4546
def dirPath(forPackage: String): String = forPackage.replace('.', JFile.separatorChar)
4647

47-
def dirPathInArchive(forPackage: String): String = forPackage.replace('.', '/')
48-
4948
def endsClass(fileName: String): Boolean =
5049
fileName.length > 6 && fileName.substring(fileName.length - 6) == ".class"
5150

compiler/src/dotty/tools/io/ZipArchive.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
package dotty.tools.io
77

88
import java.net.URL
9-
import java.io.{ IOException, InputStream, OutputStream, FilterInputStream }
9+
import java.io.{ IOException, InputStream, OutputStream, FilterInputStream, File => JFile }
1010
import java.nio.file.Files
1111
import java.util.zip.{ ZipEntry, ZipFile }
1212
import java.util.jar.Manifest
@@ -38,12 +38,12 @@ object ZipArchive {
3838
private def dirName(path: String) = splitPath(path, front = true)
3939
private def baseName(path: String) = splitPath(path, front = false)
4040
private def splitPath(path0: String, front: Boolean): String = {
41-
val isDir = path0.charAt(path0.length - 1) == '/'
41+
val isDir = path0.charAt(path0.length - 1) == JFile.separatorChar
4242
val path = if (isDir) path0.substring(0, path0.length - 1) else path0
43-
val idx = path.lastIndexOf('/')
43+
val idx = path.lastIndexOf(JFile.separatorChar)
4444

4545
if (idx < 0)
46-
if (front) "/"
46+
if (front) JFile.separator
4747
else path
4848
else
4949
if (front) path.substring(0, idx + 1)

0 commit comments

Comments
 (0)