From 21eb88b560f2395f35fcfae3be3c65fcababeb36 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 27 Mar 2003 13:14:31 +0000 Subject: [PATCH] Add a forwardslash attribute to Submitted by: Zdenek Wagner git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274322 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 5 +++++ docs/manual/CoreTasks/apply.html | 10 +++++++++- .../apache/tools/ant/taskdefs/ExecuteOn.java | 19 ++++++++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 2c8a045a7..98e8e0fd5 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -179,6 +179,11 @@ Other changes: * New task that synchronizes two directory trees. +* has new forwardslash attribute that can force filenames to + use forward slashes (/) as file separators even on platforms with a + different separator. This is useful if you want to run certain + ported Unix tools. + Changes from Ant 1.5.2 to Ant 1.5.3 =================================== diff --git a/docs/manual/CoreTasks/apply.html b/docs/manual/CoreTasks/apply.html index 92d845a0d..78e025cf2 100644 --- a/docs/manual/CoreTasks/apply.html +++ b/docs/manual/CoreTasks/apply.html @@ -57,6 +57,14 @@ one mapper.

the dest attribute for target files). No, default is false + + forwardslash + whether the absolute file names should be passed + with forward slashes even if the operating system requires other + file separator. The option is ignored if the system file separator + is a forward slash. + No, default is false + os list of Operating Systems on which the command may be @@ -220,7 +228,7 @@ of all files separated by spaces.

.o, replacing TARGETFILE with the absolute filename of the .o and SOURCEFILE with the absolute name of the .c file.

-

Copyright © 2000-2002 Apache Software Foundation. All rights +


Copyright © 2000-2003 Apache Software Foundation. All rights Reserved.

diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java index 2cc3cc207..4ee472c22 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -83,6 +83,7 @@ public class ExecuteOn extends ExecTask { protected Vector filesets = new Vector(); private boolean relative = false; private boolean parallel = false; + private boolean forwardSlash = false; protected String type = "file"; protected Commandline.Marker srcFilePos = null; private boolean skipEmpty = false; @@ -144,6 +145,14 @@ public class ExecuteOn extends ExecTask { this.destDir = destDir; } + /** + * The source and target file names on Windows and OS/2 must use + * forward slash as file separator. + */ + public void setForwardslash(boolean forwardSlash) { + this.forwardSlash = forwardSlash; + } + /** * Marker that indicates where the name of the source file should * be put on the command line. @@ -284,6 +293,7 @@ public class ExecuteOn extends ExecTask { * @param baseDir filenames are relative to this dir */ protected String[] getCommandline(String[] srcFiles, File[] baseDirs) { + final char fileSeparator = File.separatorChar; Vector targets = new Vector(); if (targetFilePos != null) { Hashtable addedFiles = new Hashtable(); @@ -297,6 +307,9 @@ public class ExecuteOn extends ExecTask { } else { name = subTargets[j]; } + if (forwardSlash && fileSeparator != '/') { + name = name.replace(fileSeparator, '/'); + } if (!addedFiles.contains(name)) { targets.addElement(name); addedFiles.put(name, name); @@ -380,6 +393,10 @@ public class ExecuteOn extends ExecTask { } else { result[srcIndex + i] = srcFiles[i]; } + if (forwardSlash && fileSeparator != '/') { + result[srcIndex + i] = + result[srcIndex + i].replace(fileSeparator, '/'); + } } return result; }