allow saving .csc with contiki-relative paths when the .csc file is in a subdirectory of the referenced

application
This commit is contained in:
Fredrik Osterlind 2013-08-14 12:52:20 +02:00
parent eb1a147d7d
commit 9cb2fd8465

View file

@ -1556,6 +1556,9 @@ public class GUI extends Observable {
"MOTETYPES");
if (moteTypeClassNames != null) {
for (String moteTypeClassName : moteTypeClassNames) {
if (moteTypeClassName.trim().isEmpty()) {
continue;
}
Class<? extends MoteType> moteTypeClass = tryLoadClass(this,
MoteType.class, moteTypeClassName);
@ -4260,6 +4263,22 @@ public class GUI extends Observable {
id += "/..";
}
}
if (!fileCanonical.startsWith(configCanonical)) {
/* SPECIAL CASE: Allow two parent directories */
File parent = new File(configCanonical).getParentFile();
if (parent != null) {
configCanonical = parent.getCanonicalPath();
id += "/..";
}
}
if (!fileCanonical.startsWith(configCanonical)) {
/* SPECIAL CASE: Allow three parent directories */
File parent = new File(configCanonical).getParentFile();
if (parent != null) {
configCanonical = parent.getCanonicalPath();
id += "/..";
}
}
if (!fileCanonical.startsWith(configCanonical)) {
/* File is not in a config subdirectory */
/*logger.info("File is not in a config subdirectory: " + file.getAbsolutePath());*/