Skip to content

Commit

Permalink
A little cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeThomsen committed Oct 27, 2019
1 parent 778c07d commit 4063255
Showing 1 changed file with 2 additions and 22 deletions.
Expand Up @@ -151,36 +151,16 @@ public void extract(String archive, String destinationDirectory) throws ArchiveE
* @return
*/
private boolean startsWithPath(String destPath, String destDir) {
if (destDir.startsWith(destDir)) {
if (destPath.startsWith(destDir)) {
return true;
} else if (destDir.length() > destPath.length()) {
return false;
} else {
/*
* The first check should handle case-sensitive file systems. We need this
* in order to weed out case-sensitive file systems with a non-existent path
* that slipped through the first test.
*/
if (new File(destPath).exists() && !(new File(destPath.toLowerCase()).exists())) {
return false;
}

boolean retVal = true;
for (int index = 0; index < destDir.length(); index++) {
char left = destPath.charAt(index);
char right = destDir.charAt(index);

if (left != right) {
char leftUc = Character.toUpperCase(left);
char rightUc = Character.toUpperCase(right);

if (leftUc != rightUc) {
retVal = false;
}
}
}

return retVal;
return destPath.toLowerCase().startsWith(destDir.toLowerCase());
}
}
}

0 comments on commit 4063255

Please sign in to comment.