Browse Source

Refactoring Tar: extract getCanonicalPrefix()

master
Marc Strapetz 4 years ago
parent
commit
5034c2c241
1 changed files with 10 additions and 6 deletions
  1. +10
    -6
      src/main/org/apache/tools/ant/taskdefs/Tar.java

+ 10
- 6
src/main/org/apache/tools/ant/taskdefs/Tar.java View File

@@ -405,12 +405,7 @@ public class Tar extends MatchingTask {
return;
}

String prefix = tarFileSet.getPrefix(this.getProject());
// '/' is appended for compatibility with the zip task.
if (!prefix.isEmpty() && !prefix.endsWith("/")) {
prefix += "/";
}
vPath = prefix + vPath;
vPath = getCanonicalPrefix(tarFileSet, this.getProject()) + vPath;
} else {
vPath = fullpath;
}
@@ -785,6 +780,15 @@ public class Tar extends MatchingTask {
return tfs;
}

private static String getCanonicalPrefix(TarFileSet tarFileSet, Project project) {
String prefix = tarFileSet.getPrefix(project);
// '/' is appended for compatibility with the zip task.
if (prefix.isEmpty() || prefix.endsWith("/")) {
return prefix;
}
return prefix += "/";
}

/**
* This is a FileSet with the option to specify permissions
* and other attributes.


Loading…
Cancel
Save