bodewig     2003/02/17 04:59:24

  Modified:    src/main/org/apache/tools/ant/types Resource.java
                        ResourceFactory.java ZipScanner.java
               src/main/org/apache/tools/ant/util SourceSelector.java
  Log:
  Tighten up contract for resource names.
  
  Revision  Changes    Path
  1.4       +16 -0     ant/src/main/org/apache/tools/ant/types/Resource.java
  
  Index: Resource.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/Resource.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Resource.java     10 Feb 2003 14:14:31 -0000      1.3
  +++ Resource.java     17 Feb 2003 12:59:23 -0000      1.4
  @@ -79,6 +79,9 @@
        * 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 @@
   
       /**
        * 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 @@
        * <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;
       }
  
  
  
  1.4       +2 -1      
ant/src/main/org/apache/tools/ant/types/ResourceFactory.java
  
  Index: ResourceFactory.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/types/ResourceFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ResourceFactory.java      10 Feb 2003 14:14:31 -0000      1.3
  +++ ResourceFactory.java      17 Feb 2003 12:59:23 -0000      1.4
  @@ -66,7 +66,8 @@
        * 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
        */
  
  
  
  1.16      +0 -3      ant/src/main/org/apache/tools/ant/types/ZipScanner.java
  
  Index: ZipScanner.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/ZipScanner.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ZipScanner.java   12 Feb 2003 09:05:04 -0000      1.15
  +++ ZipScanner.java   17 Feb 2003 12:59:23 -0000      1.16
  @@ -214,9 +214,6 @@
               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)) {
  
  
  
  1.5       +5 -2      
ant/src/main/org/apache/tools/ant/util/SourceSelector.java
  
  Index: SourceSelector.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/util/SourceSelector.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SourceSelector.java       10 Feb 2003 14:14:38 -0000      1.4
  +++ SourceSelector.java       17 Feb 2003 12:59:24 -0000      1.5
  @@ -59,6 +59,7 @@
   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 @@
               }
   
               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
  
  
  

Reply via email to