Fix relative path

This commit is contained in:
Jesse Boyd 2016-12-13 14:57:54 +11:00
parent 0a3a1c813d
commit 67b918b048
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -344,6 +344,7 @@ public class SchematicCommands {
}
private List<String> listFiles(String prefix, File[] files) {
File dir = worldEdit.getWorkingDirectoryFile(prefix);
if (prefix == null) prefix = "";
List<String> result = new ArrayList<String>();
for (File file : files) {
@ -352,8 +353,14 @@ public class SchematicCommands {
build.append("\u00a72");
ClipboardFormat format = ClipboardFormat.findByFile(file);
boolean inRoot = file.getParentFile().getName().equals(prefix);
build.append(inRoot ? file.getName() : file.getPath().split(Pattern.quote(prefix + File.separator))[1])
.append(": ").append(format == null ? "Unknown" : format.name());
if (inRoot) {
build.append(file.getName());
} else {
String relative = dir.toURI().relativize(file.toURI()).getPath();
String[] split = file.getPath().split(Pattern.quote(prefix + File.separator));
build.append(relative);
}
build.append(": ").append(format == null ? "Unknown" : format.name());
result.add(build.toString());
}
return result;