20 package net.sf.gridarta.model.scripts;
23 import java.io.IOException;
25 import org.apache.log4j.Category;
26 import org.apache.log4j.Logger;
27 import org.jetbrains.annotations.NotNull;
52 public static String
localizeEventPath(@NotNull
final File localMapDir,
final File f, @NotNull
final File mapDir) {
53 if (!mapDir.exists()) {
54 LOG.warn(
"Map directory '" + mapDir.getAbsolutePath() +
"' does not exist!");
60 for (tmp = f.getParentFile(); tmp !=
null && !tmp.getAbsolutePath().equalsIgnoreCase(localMapDir.getAbsolutePath()); tmp = tmp.getParentFile()) {
69 path = f.getAbsolutePath().substring(mapDir.getCanonicalPath().length());
70 }
catch (
final IOException ignored) {
71 path = f.getAbsolutePath().substring(mapDir.getAbsolutePath().length());
73 path = path.replace(
'\\',
'/');
74 if (!path.startsWith(
"/")) {
80 path = f.getAbsolutePath().substring(localMapDir.getCanonicalPath().length());
81 }
catch (
final IOException ignored) {
82 path = f.getAbsolutePath().substring(localMapDir.getAbsolutePath().length());
84 path = path.replace(
'\\',
'/');
85 while (!path.isEmpty() && path.startsWith(
"/")) {
86 path = path.substring(1);
103 String defScriptName = archetypeName.trim();
104 final int i = defScriptName.indexOf(
' ');
106 if (defScriptName.length() > 12 || defScriptName.lastIndexOf(
' ') != i) {
108 defScriptName = defScriptName.substring(0, i);
111 defScriptName = defScriptName.substring(0, i) + defScriptName.substring(i + 1, i + 2).toUpperCase() + defScriptName.substring(i + 2);
114 if (defScriptName.length() >= 3) {
115 defScriptName = defScriptName.substring(0, 1).toUpperCase() + defScriptName.substring(1);
117 defScriptName +=
"Script" + scriptEnding;
119 return pathManager.getMapPath(
new File(baseDir, defScriptName));