提高代码兼容性

This commit is contained in:
makejava 2018-08-01 14:39:30 +08:00
parent 0265363527
commit 712830c468
1 changed files with 12 additions and 6 deletions

View File

@ -286,12 +286,18 @@ public class VelocityUtils {
cacheDataUtils.setSavePath(savePath);
}
String projectPath = cacheDataUtils.getProject().getBasePath();
if (savePath.indexOf(projectPath) == 0) {
savePath = savePath.substring(projectPath.length());
if (savePath.startsWith("/")) {
savePath = "." + savePath;
} else {
savePath = "./" + savePath;
if (projectPath!=null) {
// 兼容Linux路径
if (projectPath.contains("\\")) {
projectPath = projectPath.replace("\\", "/");
}
if (savePath.indexOf(projectPath) == 0) {
savePath = savePath.substring(projectPath.length());
if (savePath.startsWith("/")) {
savePath = "." + savePath;
} else {
savePath = "./" + savePath;
}
}
}