diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/scm/AntStarTeamCheckOut.java b/src/main/org/apache/tools/ant/taskdefs/optional/scm/AntStarTeamCheckOut.java index 9fe068d72..db1b5986a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/scm/AntStarTeamCheckOut.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/scm/AntStarTeamCheckOut.java @@ -660,9 +660,16 @@ public class AntStarTeamCheckOut extends org.apache.tools.ant.Task String dirName = v.getDefaultPath(); // Settle on "/" as the default path separator for this purpose only. dirName = dirName.replace('\\', '/'); - // Take the StarTeam folder name furthest down in the hierarchy. - dirName = dirName.substring(dirName.lastIndexOf("/", dirName.length() - 2) + 1, dirName.length() - 1); - + // Take the StarTeam folder name furthest down in the hierarchy. + int endDirIndex = dirName.length(); + // If it ends with separator then strip it off + if (dirName.endsWith("/")) + { + // This should be the SunOS and Linux case + endDirIndex--; + } + dirName = dirName.substring(dirName.lastIndexOf("/", dirName.length() - 2) + 1, endDirIndex); + // Replace the projectName in the file's absolute path to the viewName. // This eventually makes the target of a checkout operation equal to: // targetFolder + dirName + [subfolders] + itemName