holtdl 02/04/01 00:14:33
Modified: docs/manual/CoreTasks pathconvert.html
src/main/org/apache/tools/ant/taskdefs PathConvert.java
Log:
Allow 'dirsep' and 'pathsep' to contain multi-character values.
(Submitted by M. Kerkhoff, PR 6543)
Revision Changes Path
1.7 +4 -2 jakarta-ant/docs/manual/CoreTasks/pathconvert.html
Index: pathconvert.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/pathconvert.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- pathconvert.html 30 Mar 2002 21:37:40 -0000 1.6
+++ pathconvert.html 1 Apr 2002 08:14:33 -0000 1.7
@@ -43,14 +43,16 @@
<tr>
<td valign="top">dirsep</td>
<td valign="top">
- The character to use as the directory separator in the generated
paths.
+ The character(s) to use as the directory separator in the
+ generated paths.
</td>
<td valign="top" align="center">No, defaults to current JVM
<tt>File.separator</tt></td>
</tr>
<tr>
<td valign="top">pathsep</td>
<td valign="top">
- The character to use as the path element separator in the generated
paths.
+ The character(s) to use as the path-element separator in the
+ generated paths.
</td>
<td valign="top" align="center">No, defaults to current JVM
<tt>File.pathSeparator</tt></td>
</tr>
1.13 +22 -4
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/PathConvert.java
Index: PathConvert.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/PathConvert.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- PathConvert.java 30 Mar 2002 21:37:41 -0000 1.12
+++ PathConvert.java 1 Apr 2002 08:14:33 -0000 1.13
@@ -63,6 +63,7 @@
import org.apache.tools.ant.types.DirSet;
import org.apache.tools.ant.types.FileList;
+import java.util.StringTokenizer;
import java.util.Vector;
import java.io.File;
@@ -267,8 +268,10 @@
(osname.indexOf("netware") >= 0) );
// Determine the from/to char mappings for dir sep
- char fromDirSep = onWindows ? '\\' : '/';
- char toDirSep = dirSep.charAt(0);
+// char fromDirSep = onWindows ? '\\' : '/';
+// char toDirSep = dirSep.charAt(0);
+
+ String fromDirSep = onWindows ? "\\" : "/";
StringBuffer rslt = new StringBuffer( 100 );
@@ -280,15 +283,30 @@
elem = mapElement( elem ); // Apply the path prefix map
+
// Now convert the path and file separator characters from the
// current os to the target os.
- elem = elem.replace( fromDirSep, toDirSep );
+// elem = elem.replace( fromDirSep, toDirSep );
if( i != 0 ) {
rslt.append( pathSep );
}
- rslt.append( elem );
+// rslt.append( elem );
+
+ StringTokenizer stDirectory = new StringTokenizer(elem,
fromDirSep, true);
+ String token = null;
+
+ while ( stDirectory.hasMoreTokens() ) {
+ token = stDirectory.nextToken();
+
+ if (fromDirSep.equals(token)) {
+ rslt.append( dirSep );
+ }
+ else {
+ rslt.append( token );
+ }
+ }
}
// Place the result into the specified property
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>