mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-21 15:55:40 +00:00
Update isSymlink to be closer to the current version in apache.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@17429 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
dffcc20f5d
commit
e6acec2273
1 file changed
+12
-7
@@ -268,14 +268,19 @@ public class Util {
|
||||
*/
|
||||
//Taken from http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.java?view=markup
|
||||
public static boolean isSymlink(File file) throws IOException {
|
||||
File parent = file.getParentFile();
|
||||
File canonicalFile = file.getCanonicalFile();
|
||||
|
||||
return parent != null
|
||||
&& (!canonicalFile.getName().equals(file.getName()) || !canonicalFile.getPath().startsWith(
|
||||
parent.getCanonicalPath()));
|
||||
}
|
||||
String name = file.getName();
|
||||
if (name.equals(".") || name.equals(".."))
|
||||
return false;
|
||||
|
||||
File fileInCanonicalParent = null;
|
||||
File parentDir = file.getParentFile();
|
||||
if ( parentDir == null ) {
|
||||
fileInCanonicalParent = file;
|
||||
} else {
|
||||
fileInCanonicalParent = new File( parentDir.getCanonicalPath(), name );
|
||||
}
|
||||
return !fileInCanonicalParent.getCanonicalFile().equals( fileInCanonicalParent.getAbsoluteFile() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new temporary directory.
|
||||
|
||||
Reference in new issue
Block a user