Use canonical path to find parent directory when creating config relative path

This commit is contained in:
nifi 2009-10-30 15:27:26 +00:00
parent 790f2f632a
commit a22348a496

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.149 2009/10/29 17:05:13 fros4943 Exp $ * $Id: GUI.java,v 1.150 2009/10/30 15:27:26 nifi Exp $
*/ */
package se.sics.cooja; package se.sics.cooja;
@ -3953,9 +3953,12 @@ public class GUI extends Observable {
String fileCanonical = file.getCanonicalPath(); String fileCanonical = file.getCanonicalPath();
if (!fileCanonical.startsWith(configCanonical)) { if (!fileCanonical.startsWith(configCanonical)) {
/* SPECIAL CASE: Allow one parent directory */ /* SPECIAL CASE: Allow one parent directory */
configCanonical = configPath.getParentFile().getCanonicalPath(); File parent = new File(configCanonical).getParentFile();
if (parent != null) {
configCanonical = parent.getCanonicalPath();
id += "/.."; id += "/..";
} }
}
if (!fileCanonical.startsWith(configCanonical)) { if (!fileCanonical.startsWith(configCanonical)) {
/* File is not in a config subdirectory */ /* File is not in a config subdirectory */
logger.info("File is not in a config subdirectory: " + file.getAbsolutePath()); logger.info("File is not in a config subdirectory: " + file.getAbsolutePath());