Index: Pvcs.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java,v
retrieving revision 1.2
diff -u -r1.2 Pvcs.java
--- Pvcs.java	2001/07/13 13:57:40	1.2
+++ Pvcs.java	2001/08/22 04:30:29
@@ -60,6 +60,7 @@
 import java.io.*;
 import java.util.Enumeration;
 import java.util.Vector;
+import java.util.Hashtable;
 import java.text.*;
 import java.util.Random;
 import org.apache.tools.ant.BuildException;
@@ -85,6 +86,13 @@
  * update those files that have a modification time (in PVCS) that is newer 
  * than the existing workfile.
  *
+ * <b>22-08-2001</b> <p>Paths are not handled properly
+ * and it results to fail to create directries.
+ * <p>"Pcli -z -aw -pr/repos" returns paths in double-quotes or
+ * building stops if it fails on operation.  Therefore, it is not
+ * necessary to varify the returned list and can be passed to
+ * get command.  Creating directries is optimized.
+ *
  * @author Thomas Christensen <tchristensen@nordija.com>
  * @author Don Jeffery <donj@apogeenet.com>
  */
@@ -106,16 +114,10 @@
     private static final String PCLI_EXE = "pcli";
 
     /**
-     * Constant for the PCLI listversionedfiles recursive i a format "get" understands
-     */
-    private static final String PCLI_LVF_ARGS = "lvf -z -aw";
-
-    /**
      * Constant for the thing to execute
      */
     private static final String GET_EXE = "get";
 
-
     protected int runCmd(Commandline cmd, ExecuteStreamHandler out) {
         try {
             Project aProj = getProject();
@@ -182,11 +184,9 @@
         }
 
         File tmp = null;
-        File tmp2 = null;
         try {
             Random rand = new Random(System.currentTimeMillis());
             tmp = new File("pvcs_ant_"+rand.nextLong()+".log");
-            tmp2 = new File("pvcs_ant_"+rand.nextLong()+".log");
             log("Executing " + commandLine.toString(), Project.MSG_VERBOSE);
             result = runCmd(commandLine, new PumpStreamHandler(new FileOutputStream(tmp), new LogOutputStream(this,Project.MSG_WARN)));
             if ( result != 0 && !ignorerc) {
@@ -201,9 +201,6 @@
             log("Creating folders", Project.MSG_INFO);
             createFolders(tmp);
 
-            // Massage PCLI lvf output transforming '\' to '/' so get command works appropriately
-            massagePCLI(tmp, tmp2);
-
             // Launch get on output captured from PCLI lvf
             commandLine.clearArgs();
             commandLine.setExecutable(getExecutable(GET_EXE));
@@ -224,7 +221,7 @@
                 commandLine.createArgument().setValue("-U");
             }
 
-            commandLine.createArgument().setValue("@"+tmp2.getAbsolutePath());
+            commandLine.createArgument().setValue("@"+tmp.getAbsolutePath());
             log("Getting files", Project.MSG_INFO);
             log("Executing " + commandLine.toString(), Project.MSG_VERBOSE);
             result = runCmd(commandLine, new LogStreamHandler(this,Project.MSG_INFO, Project.MSG_WARN));
@@ -246,9 +243,6 @@
             if (tmp != null) {
                 tmp.delete();
             }
-            if (tmp2 != null) {
-                tmp2.delete();
-            }
         }
     }
 
@@ -258,52 +252,34 @@
     private void createFolders(File file) throws IOException, ParseException {
         BufferedReader in = new BufferedReader(new FileReader(file));
         MessageFormat mf = new MessageFormat("{0}-arc({1})");
-        String line = in.readLine();
-        while(line != null) {
+        String line;
+        Hashtable dirs = new Hashtable();
+
+        // Create directry lists.
+        while((line = in.readLine()) != null) {
             log("Considering \""+line+"\"", Project.MSG_VERBOSE);
-            if(line.startsWith("\"\\") || line.startsWith("\"/")) {
-                Object[] objs = mf.parse(line);
-                String f = (String)objs[1];
-                // Extract the name of the directory from the filename
-                int index = f.lastIndexOf(File.separator);
-                if (index > -1) {
-                    File dir = new File(f.substring(0, index));
-                    if(!dir.exists()) {
-                        log("Creating "+dir.getAbsolutePath(), Project.MSG_VERBOSE);
-                        if(dir.mkdirs()) {
-                            log("Created "+dir.getAbsolutePath(), Project.MSG_INFO);
-                        } else {
-                            log("Failed to create "+dir.getAbsolutePath(), Project.MSG_INFO);
-                        }
-                    } else {
-                        log(dir.getAbsolutePath() + " exists. Skipping", Project.MSG_VERBOSE);
-                    }
-                } else {
-                    log("File separator problem with " + line, 
-                        Project.MSG_WARN);
-                }
+            String f = (String)mf.parse(line)[1];
+            // Extract the name of the directory from the filename
+            int index = f.lastIndexOf(File.separator);
+
+            if (index > -1) {
+                f = f.substring(0, index);
+                dirs.put(f, f);
             } else {
-                log("Skipped \""+line+"\"", Project.MSG_VERBOSE);
+                log("File separator problem with " + line, Project.MSG_WARN);
             }
-            line = in.readLine();
         }
-    }
+        in.close();
 
-    /**
-     * Simple hack to handle the PVCS command-line tools botch when handling UNC notation.
-     */
-    private void massagePCLI(File in, File out) throws FileNotFoundException, IOException
-    {
-        BufferedReader inReader = new BufferedReader(new FileReader(in));
-        BufferedWriter outWriter = new BufferedWriter(new FileWriter(out));
-        String s = null;
-        while ((s = inReader.readLine()) != null) {
-            String sNormal = s.replace('\\', '/');
-            outWriter.write(sNormal);
-            outWriter.newLine();
+        Enumeration list = dirs.elements();
+
+        // Create directries.
+        while(list.hasMoreElements())
+        {
+            File dir = new File((String)list.nextElement());
+            if(dir.mkdirs())
+                log("Created "+dir.getAbsolutePath(), Project.MSG_INFO);
         }
-        inReader.close();
-        outWriter.close();
     }
 
     /**
