try {
String filePath = f.getCanonicalPath();
String dirPath = dir.getCanonicalPath();
if (!filePath.substring(0, dirPath.length()).equals(dirPath) && !getConfiguration().allowSymlinks) {
throw new FilenameResolutionException(filename,
"Path is outside allowable root");
}
return f;
} catch (IOException e) {
throw new FilenameResolutionException(filename,
"Failed to resolve path");
}
}