Browse Source

Tighten up contract for resource names.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274099 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
dde5bb1250
4 changed files with 23 additions and 6 deletions
  1. +16
    -0
      src/main/org/apache/tools/ant/types/Resource.java
  2. +2
    -1
      src/main/org/apache/tools/ant/types/ResourceFactory.java
  3. +0
    -3
      src/main/org/apache/tools/ant/types/ZipScanner.java
  4. +5
    -2
      src/main/org/apache/tools/ant/util/SourceSelector.java

+ 16
- 0
src/main/org/apache/tools/ant/types/Resource.java View File

@@ -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
* &quot;/&quot; 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
* &quot;/&quot; 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
* &quot;/&quot; 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>&quot;/&quot; will be used as the directory separator.</p>
*/
public String getName() {
return name;
}

/**
* @param name relative path of the resource. Expects
* &quot;/&quot; to be used as the directory separator.
*/
public void setName(String name) {
this.name = name;
}


+ 2
- 1
src/main/org/apache/tools/ant/types/ResourceFactory.java View File

@@ -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 &quot;/&quot; to be used as the
* directory separator.
* @return instance of Resource; the exists attribute of Resource
* will tell whether the sought resource exists
*/


+ 0
- 3
src/main/org/apache/tools/ant/types/ZipScanner.java View File

@@ -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)) {


+ 5
- 2
src/main/org/apache/tools/ant/util/SourceSelector.java View File

@@ -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


Loading…
Cancel
Save