+ special case: allow single parent directory when saving relative source file paths

This commit is contained in:
fros4943 2009-03-17 09:16:36 +00:00
parent 13b364bcc1
commit 0580b4ea9d

View File

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: GUI.java,v 1.118 2009/03/13 15:15:37 fros4943 Exp $ * $Id: GUI.java,v 1.119 2009/03/17 09:16:36 fros4943 Exp $
*/ */
package se.sics.cooja; package se.sics.cooja;
@ -3812,10 +3812,16 @@ public class GUI extends Observable {
String configCanonical = configPath.getCanonicalPath(); String configCanonical = configPath.getCanonicalPath();
String fileCanonical = file.getCanonicalPath(); String fileCanonical = file.getCanonicalPath();
if (!fileCanonical.startsWith(configCanonical)) {
/* SPECIAL CASE: Allow one parent directory */
configCanonical = configPath.getParentFile().getCanonicalPath();
configIdentifier += "/..";
if (!fileCanonical.startsWith(configCanonical)) { if (!fileCanonical.startsWith(configCanonical)) {
/*logger.warn("Error when converting to config relative path: file not in config directory: " + file.getAbsolutePath());*/ /*logger.warn("Error when converting to config relative path: file not in config directory: " + file.getAbsolutePath());*/
return file; return file;
} }
}
/* Replace config's canonical path with config identifier */ /* Replace config's canonical path with config identifier */
String newFilePath = fileCanonical.replace(configCanonical, configIdentifier); String newFilePath = fileCanonical.replace(configCanonical, configIdentifier);