diff options
author | Stefan Bodewig <bodewig@apache.org> | 2003-02-17 12:59:24 +0000 |
---|---|---|
committer | Stefan Bodewig <bodewig@apache.org> | 2003-02-17 12:59:24 +0000 |
commit | dde5bb12505395c4a804f56780f30ceed23ba85d (patch) | |
tree | 4c92173f8b5a18d65e31ef31ec94bdaac1b4bbf3 /src/main | |
parent | ff2bad349247985370f0c10ab4e503eb717ad5d8 (diff) | |
download | ant-dde5bb12505395c4a804f56780f30ceed23ba85d.tar.gz |
Tighten up contract for resource names.
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274099 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/main')
4 files changed, 23 insertions, 6 deletions
diff --git a/src/main/org/apache/tools/ant/types/Resource.java b/src/main/org/apache/tools/ant/types/Resource.java index 78bb2f29f..76a5cd3f9 100644 --- a/src/main/org/apache/tools/ant/types/Resource.java +++ b/src/main/org/apache/tools/ant/types/Resource.java @@ -79,6 +79,9 @@ public class Resource implements Cloneable { * only sets the name. * * <p>This is a dummy, used for not existing resources.</p> + * + * @param name relative path of the resource. Expects + * "/" to be used as the directory separator. */ public Resource(String name) { this(name, false, 0, false); @@ -86,11 +89,18 @@ public class Resource implements Cloneable { /** * sets the name, lastmodified flag, and exists flag + * + * @param name relative path of the resource. Expects + * "/" to be used as the directory separator. */ public Resource(String name, boolean exists, long lastmodified) { this(name, exists, lastmodified, false); } + /** + * @param name relative path of the resource. Expects + * "/" to be used as the directory separator. + */ public Resource(String name, boolean exists, long lastmodified, boolean directory) { this.name = name; @@ -107,11 +117,17 @@ public class Resource implements Cloneable { * <p>example for a file with fullpath /var/opt/adm/resource.txt * in a file set with root dir /var/opt it will be * adm/resource.txt.</p> + * + * <p>"/" will be used as the directory separator.</p> */ public String getName() { return name; } + /** + * @param name relative path of the resource. Expects + * "/" to be used as the directory separator. + */ public void setName(String name) { this.name = name; } diff --git a/src/main/org/apache/tools/ant/types/ResourceFactory.java b/src/main/org/apache/tools/ant/types/ResourceFactory.java index 04ff63840..26a79e1ae 100644 --- a/src/main/org/apache/tools/ant/types/ResourceFactory.java +++ b/src/main/org/apache/tools/ant/types/ResourceFactory.java @@ -66,7 +66,8 @@ public interface ResourceFactory { * Query a resource (file, zipentry, ...) by name * * @param Name relative path of the resource about which - * information is sought + * information is sought. Expects "/" to be used as the + * directory separator. * @return instance of Resource; the exists attribute of Resource * will tell whether the sought resource exists */ diff --git a/src/main/org/apache/tools/ant/types/ZipScanner.java b/src/main/org/apache/tools/ant/types/ZipScanner.java index 46eaa5100..f47538670 100644 --- a/src/main/org/apache/tools/ant/types/ZipScanner.java +++ b/src/main/org/apache/tools/ant/types/ZipScanner.java @@ -214,9 +214,6 @@ public class ZipScanner extends DirectoryScanner { return new Resource("", true, Long.MAX_VALUE, true); } - // Zip-Entries always use forward slashes - name = name.replace(File.separatorChar, '/'); - // first check if the archive needs to be scanned again scanme(); if (myentries.containsKey(name)) { diff --git a/src/main/org/apache/tools/ant/util/SourceSelector.java b/src/main/org/apache/tools/ant/util/SourceSelector.java index 78d967013..9f00be7d6 100644 --- a/src/main/org/apache/tools/ant/util/SourceSelector.java +++ b/src/main/org/apache/tools/ant/util/SourceSelector.java @@ -59,6 +59,7 @@ import org.apache.tools.ant.taskdefs.condition.Os; import org.apache.tools.ant.types.Resource; import org.apache.tools.ant.types.ResourceFactory; +import java.io.File; import java.util.Vector; /** @@ -111,14 +112,16 @@ public class SourceSelector { } String[] targetnames = - mapper.mapFileName(source[counter].getName()); + mapper.mapFileName(source[counter].getName() + .replace('/', File.separatorChar)); if (targetnames != null) { boolean added = false; targetList.setLength(0); for (int ctarget = 0; !added && ctarget < targetnames.length; ctarget++) { Resource atarget = - targets.getResource(targetnames[ctarget]); + targets.getResource(targetnames[ctarget] + .replace(File.separatorChar, '/')); // if the target does not exist, or exists and // is older than the source, then we want to // add the resource to what needs to be copied |