summaryrefslogtreecommitdiffstats
path: root/util/src
diff options
context:
space:
mode:
authorwisberg <wisberg>2003-05-02 21:03:04 +0000
committerwisberg <wisberg>2003-05-02 21:03:04 +0000
commitc2564514669984e5b47ffe8d888dd48de219e05e (patch)
tree85db8c13c237e1f737dc592c8f579db7975aa49d /util/src
parentbcdbd68f76629692a5e780702086bff96cdc4c7c (diff)
downloadaspectj-c2564514669984e5b47ffe8d888dd48de219e05e.tar.gz
aspectj-c2564514669984e5b47ffe8d888dd48de219e05e.zip
accept "." as base dir in resolving files
Diffstat (limited to 'util/src')
-rw-r--r--util/src/org/aspectj/util/FileUtil.java27
1 files 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();