mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
external compiler: fixed directory names for caches
This commit is contained in:
@@ -2,6 +2,7 @@ package org.jetbrains.jps.incremental.storage;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.PathUtilRt;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
@@ -121,7 +122,7 @@ public class BuildTargetsState {
|
||||
}
|
||||
|
||||
public File getTargetDataRoot(BuildTarget target) {
|
||||
return new File(getTargetTypeDataRoot(target.getTargetType()), target.getId());
|
||||
return new File(getTargetTypeDataRoot(target.getTargetType()), PathUtilRt.suggestFileName(target.getId(), true, true));
|
||||
}
|
||||
|
||||
public void clean() {
|
||||
|
||||
@@ -77,61 +77,26 @@ public class PathUtil {
|
||||
|
||||
@NotNull
|
||||
public static String getFileName(@NotNull String path) {
|
||||
if (path.length() == 0) {
|
||||
return "";
|
||||
}
|
||||
final char c = path.charAt(path.length() - 1);
|
||||
int end = c == '/' || c == '\\' ? path.length() - 1 : path.length();
|
||||
int start = Math.max(path.lastIndexOf('/', end - 1), path.lastIndexOf('\\', end - 1)) + 1;
|
||||
return path.substring(start, end);
|
||||
return PathUtilRt.getFileName(path);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getParentPath(@NotNull String path) {
|
||||
if (path.length() == 0) {
|
||||
return "";
|
||||
}
|
||||
int end = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'));
|
||||
if (end == path.length() - 1) {
|
||||
end = Math.max(path.lastIndexOf('/', end - 1), path.lastIndexOf('\\', end - 1));
|
||||
}
|
||||
return end == -1 ? "" : path.substring(0, end);
|
||||
return PathUtilRt.getParentPath(path);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String suggestFileName(@NotNull String text) {
|
||||
return suggestFileName(text, false, false);
|
||||
return PathUtilRt.suggestFileName(text);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String suggestFileName(@NotNull String text, final boolean allowDots, final boolean allowSpaces) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char c = text.charAt(i);
|
||||
if (!isValidFileNameChar(c) || (!allowDots && c == '.') || (!allowSpaces && Character.isWhitespace(c))) {
|
||||
result.append('_');
|
||||
}
|
||||
else {
|
||||
result.append(c);
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
return PathUtilRt.suggestFileName(text, allowDots, allowSpaces);
|
||||
}
|
||||
|
||||
public static boolean isValidFileName(@NotNull String fileName) {
|
||||
if (fileName.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < fileName.length(); i++) {
|
||||
if (!isValidFileNameChar(fileName.charAt(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return PathUtilRt.isValidFileName(fileName);
|
||||
}
|
||||
|
||||
private static boolean isValidFileNameChar(char c) {
|
||||
return c != '/' && c != '\\' && c != '\t' && c != '\n' && c != '\r' && c != ':' && c != ';' && c != '*' && c != '?' &&
|
||||
c != '"' && c != '\'' && c != '<' && c != '>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class PathUtilRt {
|
||||
@NotNull
|
||||
public static String getFileName(@NotNull String path) {
|
||||
if (path.length() == 0) {
|
||||
return "";
|
||||
}
|
||||
final char c = path.charAt(path.length() - 1);
|
||||
int end = c == '/' || c == '\\' ? path.length() - 1 : path.length();
|
||||
int start = Math.max(path.lastIndexOf('/', end - 1), path.lastIndexOf('\\', end - 1)) + 1;
|
||||
return path.substring(start, end);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getParentPath(@NotNull String path) {
|
||||
if (path.length() == 0) {
|
||||
return "";
|
||||
}
|
||||
int end = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'));
|
||||
if (end == path.length() - 1) {
|
||||
end = Math.max(path.lastIndexOf('/', end - 1), path.lastIndexOf('\\', end - 1));
|
||||
}
|
||||
return end == -1 ? "" : path.substring(0, end);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String suggestFileName(@NotNull String text) {
|
||||
return suggestFileName(text, false, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String suggestFileName(@NotNull String text, final boolean allowDots, final boolean allowSpaces) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char c = text.charAt(i);
|
||||
if (!isValidFileNameChar(c) || (!allowDots && c == '.') || (!allowSpaces && Character.isWhitespace(c))) {
|
||||
result.append('_');
|
||||
}
|
||||
else {
|
||||
result.append(c);
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static boolean isValidFileName(@NotNull String fileName) {
|
||||
if (fileName.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < fileName.length(); i++) {
|
||||
if (!isValidFileNameChar(fileName.charAt(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private static boolean isValidFileNameChar(char c) {
|
||||
return c != '/' && c != '\\' && c != '\t' && c != '\n' && c != '\r' && c != ':' && c != ';' && c != '*' && c != '?' &&
|
||||
c != '"' && c != '\'' && c != '<' && c != '>';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user