@@ -537,7 +537,13 @@ public class Project {
} while (!curtarget.getName().equals(targetName));
} while (!curtarget.getName().equals(targetName));
}
}
public File resolveFile(String fileName) {
/**
* Return the canonical form of fileName as an absolute path.
*
* <p>If fileName is a relative file name, resolve it relative to
* rootDir.</p>
*/
public File resolveFile(String fileName, File rootDir) {
fileName = fileName.replace('/', File.separatorChar).replace('\\', File.separatorChar);
fileName = fileName.replace('/', File.separatorChar).replace('\\', File.separatorChar);
// deal with absolute files
// deal with absolute files
@@ -580,14 +586,14 @@ public class Project {
return new File(sb.toString());
return new File(sb.toString());
}
}
File file = new File(base Dir.getAbsolutePath());
File file = new File(root Dir.getAbsolutePath());
StringTokenizer tok = new StringTokenizer(fileName, File.separator, false);
StringTokenizer tok = new StringTokenizer(fileName, File.separator, false);
while (tok.hasMoreTokens()) {
while (tok.hasMoreTokens()) {
String part = tok.nextToken();
String part = tok.nextToken();
if (part.equals("..")) {
if (part.equals("..")) {
String parentFile = file.getParent();
String parentFile = file.getParent();
if (parentFile == null) {
if (parentFile == null) {
throw new BuildException("The file or path you specified (" + fileName + ") is invalid releative to " + base Dir.getAbsolutePath());
throw new BuildException("The file or path you specified (" + fileName + ") is invalid releative to " + root Dir.getAbsolutePath());
}
}
file = new File(parentFile);
file = new File(parentFile);
} else if (part.equals(".")) {
} else if (part.equals(".")) {
@@ -607,6 +613,10 @@ public class Project {
}
}
}
}
public File resolveFile(String fileName) {
return resolveFile(fileName, baseDir);
}
/**
/**
* Translate a path into its native (platform specific) format.
* Translate a path into its native (platform specific) format.
* <p>
* <p>