diff --git a/classlib/src/main/java/org/teavm/classlib/fs/c/CVirtualFile.java b/classlib/src/main/java/org/teavm/classlib/fs/c/CVirtualFile.java index 59a21ef9f..796b511a4 100644 --- a/classlib/src/main/java/org/teavm/classlib/fs/c/CVirtualFile.java +++ b/classlib/src/main/java/org/teavm/classlib/fs/c/CVirtualFile.java @@ -36,7 +36,8 @@ public class CVirtualFile implements VirtualFile { @Override public String getName() { - return path.substring(path.lastIndexOf('/') + 1); + char separatorChar = fileSystem.isWindows() ? '\\' : '/'; + return path.substring(path.lastIndexOf(separatorChar) + 1); } @Override @@ -174,7 +175,10 @@ public class CVirtualFile implements VirtualFile { return CFileSystem.length(chars, chars.length); } - private static String constructPath(String parent, String child) { - return parent.endsWith("/") ? parent + child : parent + "/" + child; + private String constructPath(String parent, String child) { + char separatorChar = fileSystem.isWindows() ? '\\' : '/'; + return !parent.isEmpty() && parent.charAt(parent.length() - 1) == separatorChar + ? parent + child + : parent + separatorChar + child; } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TFile.java b/classlib/src/main/java/org/teavm/classlib/java/io/TFile.java index dc1bcec1f..31bba071a 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TFile.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TFile.java @@ -411,25 +411,37 @@ public class TFile implements Serializable, Comparable { public boolean mkdirs() { String path = getCanonicalPathImpl(); - int i = path.indexOf(separatorChar); - if (i < 0) { + if (path.indexOf(separatorChar) < 0) { return false; } + int i = path.length(); + + do { + VirtualFile file = fs().getFile(path.substring(0, i)); + if (file.isDirectory()) { + break; + } else if (file.isFile()) { + return false; + } + + i = path.lastIndexOf(separatorChar, i - 1); + } while (i >= 0); + i++; + while (i < path.length()) { int next = path.indexOf(separatorChar, i); if (next < 0) { next = path.length(); } - - VirtualFile parent = fs().getFile(path.substring(0, i)); - if (!parent.createDirectory(path.substring(i, next))) { - VirtualFile child = fs().getFile(path.substring(0, next)); - if (!child.isDirectory()) { - return false; - } + if (next == i + 1) { + break; } + VirtualFile file = fs().getFile(path.substring(0, i)); + if (!file.createDirectory(path.substring(i, next))) { + return false; + } i = next + 1; } diff --git a/tools/junit/src/main/java/org/teavm/junit/CRunStrategy.java b/tools/junit/src/main/java/org/teavm/junit/CRunStrategy.java index 983ab31a9..08cfe4489 100644 --- a/tools/junit/src/main/java/org/teavm/junit/CRunStrategy.java +++ b/tools/junit/src/main/java/org/teavm/junit/CRunStrategy.java @@ -119,6 +119,11 @@ class CRunStrategy implements TestRunStrategy { } lines.add(line); stdout.add(line); + if (lines.size() > 10000) { + output.addAll(lines); + process.destroy(); + return false; + } } } catch (IOException e) { // do nothing