From c2564514669984e5b47ffe8d888dd48de219e05e Mon Sep 17 00:00:00 2001 From: wisberg Date: Fri, 2 May 2003 21:03:04 +0000 Subject: [PATCH] accept "." as base dir in resolving files --- util/src/org/aspectj/util/FileUtil.java | 27 ++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/util/src/org/aspectj/util/FileUtil.java b/util/src/org/aspectj/util/FileUtil.java index 0a24666c6..77752af44 100644 --- a/util/src/org/aspectj/util/FileUtil.java +++ b/util/src/org/aspectj/util/FileUtil.java @@ -598,11 +598,32 @@ public class FileUtil { } else { result = new File[paths.length]; for (int i = 0; i < result.length; i++) { - result[i] = new File(basedir, paths[i]); + result[i] = newFile(basedir, paths[i]); } } return result; } + + /** + * Create a new File, resolving paths ".." and "." specially. + * @param dir the File for the parent directory of the file + * @param path the path in the parent directory (filename only?) + * @return File for the new file. + */ + private static File newFile(File dir, String path) { + if (".".equals(path)) { + return dir; + } else if ("..".equals(path)) { + File parentDir = dir.getParentFile(); + if (null != parentDir) { + return parentDir; + } else { + return new File(dir, ".."); + } + } else { + return new File(dir, path); + } + } /** * Copy files from source dir into destination directory, @@ -624,8 +645,8 @@ public class FileUtil { for (int i = 0; i < paths.length; i++) { String path = paths[i]; LangUtil.throwIaxIfNull(path, "relativePaths-entry"); - File src = new File(srcDir, relativePaths[i]); - File dest = new File(destDir, path); + File src = newFile(srcDir, paths[i]); + File dest = newFile(destDir, path); File destParent = dest.getParentFile(); if (!destParent.exists()) { destParent.mkdirs(); -- 2.39.5