mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
C: fix File.mkdirs() on Windows
This commit is contained in:
parent
cdcaa8947c
commit
9ad0ddd891
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -411,25 +411,37 @@ public class TFile implements Serializable, Comparable<TFile> {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user