ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r608996 - in /ant/core/branches/ANT_17_BRANCH/src: main/org/apache/tools/ant/taskdefs/ main/org/apache/tools/ant/taskdefs/compilers/ main/org/apache/tools/ant/taskdefs/cvslib/ main/org/apache/tools/ant/taskdefs/optional/ main/org/apache/too...
Date Fri, 04 Jan 2008 20:46:29 GMT
Author: jkf
Date: Fri Jan  4 12:46:26 2008
New Revision: 608996

URL: http://svn.apache.org/viewvc?rev=608996&view=rev
Log:
manual merge of r608939 

Modified:
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Execute.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Replace.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/TempFile.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Zip.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/FileUtils.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
    ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java
    ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java
    ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java
    ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Execute.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Execute.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Execute.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Execute.java Fri
Jan  4 12:46:26 2008
@@ -1190,8 +1190,7 @@
          */
         private File createCommandFile(String[] cmd, String[] env)
             throws IOException {
-            File script = FILE_UTILS.createTempFile("ANT", ".COM", null);
-            script.deleteOnExit();
+            File script = FILE_UTILS.createTempFile("ANT", ".COM", null, true, true);
             PrintWriter out = null;
             try {
                 out = new PrintWriter(new FileWriter(script));

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java Fri
Jan  4 12:46:26 2008
@@ -341,7 +341,7 @@
             fcv = new Vector(1);
             fcv.add(fc);
         }
-        File tmpFile = FILE_UTILS.createTempFileName("fixcrlf", "", null, true);
+        File tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null, true, false);
         try {
             FILE_UTILS.copyFile(srcFile, tmpFile, null, fcv, false, false,
                 encoding, outputEncoding == null ? encoding : outputEncoding,

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Javadoc.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Javadoc.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Javadoc.java Fri
Jan  4 12:46:26 2008
@@ -1694,8 +1694,7 @@
              * if requested.
              */
             if (useExternalFile) {
-                tmpList = FILE_UTILS.createTempFile("javadoc", "", null);
-                tmpList.deleteOnExit();
+                tmpList = FILE_UTILS.createTempFile("javadoc", "", null, true, true);
                 toExecute.createArgument()
                     .setValue("@" + tmpList.getAbsolutePath());
                 srcListWriter = new PrintWriter(
@@ -1882,8 +1881,7 @@
         PrintWriter optionsListWriter = null;
         try {
             optionsTmpFile = FILE_UTILS.createTempFile(
-                "javadocOptions", "", null);
-            optionsTmpFile.deleteOnExit();
+                "javadocOptions", "", null, true, true);
             String[] listOpt = toExecute.getArguments();
             toExecute.clearArgs();
             toExecute.createArgument().setValue(

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Replace.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Replace.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Replace.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Replace.java Fri
Jan  4 12:46:26 2008
@@ -600,7 +600,7 @@
             in = new FileInput(src);
 
             temp = FILE_UTILS.createTempFile("rep", ".tmp",
-                    src.getParentFile());
+                    src.getParentFile(), false, true);
             out = new FileOutput(temp);
 
             int repCountStart = replaceCount;

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/TempFile.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/TempFile.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/TempFile.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/TempFile.java Fri
Jan  4 12:46:26 2008
@@ -158,10 +158,10 @@
         File tfile;
         if (createFile) {
             tfile = FILE_UTILS.createTempFile(prefix, suffix, destDir,
-                    deleteOnExit);
+                    deleteOnExit, true);
         } else {
-            tfile = FILE_UTILS.createTempFileName(prefix, suffix, destDir,
-                    deleteOnExit);
+            tfile = FILE_UTILS.createTempFile(prefix, suffix, destDir,
+                    deleteOnExit, false);
         }
 
         getProject().setNewProperty(property, tfile.toString());

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Zip.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Zip.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Zip.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Zip.java Fri Jan
 4 12:46:26 2008
@@ -580,8 +580,7 @@
     /** rename the zip file. */
     private File renameFile() {
         File renamedFile = FILE_UTILS.createTempFile(
-            "zip", ".tmp", zipFile.getParentFile());
-        renamedFile.deleteOnExit();
+            "zip", ".tmp", zipFile.getParentFile(), true, true);
         try {
             FILE_UTILS.rename(zipFile, renamedFile);
         } catch (SecurityException e) {

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
Fri Jan  4 12:46:26 2008
@@ -466,8 +466,7 @@
                 PrintWriter out = null;
                 try {
                     tmpFile = FILE_UTILS.createTempFile(
-                        "files", "", getJavac().getTempdir());
-                    tmpFile.deleteOnExit();
+                        "files", "", getJavac().getTempdir(), true, true);
                     out = new PrintWriter(new FileWriter(tmpFile));
                     for (int i = firstFileName; i < args.length; i++) {
                         if (quoteFiles && args[i].indexOf(" ") > -1) {

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
Fri Jan  4 12:46:26 2008
@@ -224,8 +224,7 @@
         setCommand("");
         File tmpFile = null;
         try {
-            tmpFile = FILE_UTILS.createTempFile("cvstagdiff", ".log", null);
-            tmpFile.deleteOnExit();
+            tmpFile = FILE_UTILS.createTempFile("cvstagdiff", ".log", null, true, true);
             setOutput(tmpFile);
 
             // run the cvs command

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
Fri Jan  4 12:46:26 2008
@@ -177,8 +177,7 @@
      */
     protected File createListFile(Vector files)
         throws IOException {
-        File listFile = FILE_UTILS.createTempFile("ant", "", null);
-        listFile.deleteOnExit();
+        File listFile = FILE_UTILS.createTempFile("ant", "", null, true, true);
 
         PrintWriter writer = new PrintWriter(new FileOutputStream(listFile));
 
@@ -314,8 +313,7 @@
                 exec.setDir(baseDir);
 
                 if (!doVerbose) {
-                    outFile = FILE_UTILS.createTempFile("ant", "", null);
-                    outFile.deleteOnExit();
+                    outFile = FILE_UTILS.createTempFile("ant", "", null, true, true);
                     exec.setOutput(outFile);
                 }
 

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
Fri Jan  4 12:46:26 2008
@@ -323,8 +323,7 @@
      */
     protected void doReplace(File f, int options)
          throws IOException {
-        File temp = FILE_UTILS.createTempFile("replace", ".txt", null);
-        temp.deleteOnExit();
+        File temp = FILE_UTILS.createTempFile("replace", ".txt", null, true, true);
 
         Reader r = null;
         Writer w = null;

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java
Fri Jan  4 12:46:26 2008
@@ -346,7 +346,7 @@
             //afterwards
             FileOutputStream fos = null;
 
-            temporaryCommandFile = FILE_UTILS.createTempFile("cmd", ".txt", null);
+            temporaryCommandFile = FILE_UTILS.createTempFile("cmd", ".txt", null, false,
true);
             owner.log("Using response file " + temporaryCommandFile, Project.MSG_VERBOSE);
 
             try {

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
Fri Jan  4 12:46:26 2008
@@ -1130,7 +1130,7 @@
     private File createTempPropertiesFile(String prefix) {
         File propsFile =
             FILE_UTILS.createTempFile(prefix, ".properties",
-                tmpDir != null ? tmpDir : getProject().getBaseDir(), true);
+                tmpDir != null ? tmpDir : getProject().getBaseDir(), true, true);
         return propsFile;
     }
 

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
Fri Jan  4 12:46:26 2008
@@ -1827,9 +1827,9 @@
         FTPFile [] theFiles = null;
         final int maxIterations = 1000;
         for (int counter = 1; counter < maxIterations; counter++) {
-            File localFile = FILE_UTILS.createTempFileName(
+            File localFile = FILE_UTILS.createTempFile(
             	"ant" + Integer.toString(counter), ".tmp",
-                null, false);
+                null, false, false);
             String fileName = localFile.getName();
             boolean found = false;
             try {

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
Fri Jan  4 12:46:26 2008
@@ -413,7 +413,7 @@
 
         // rename the resource, thus breaking the link:
         File temp = FILE_UTILS.createTempFile("symlink", ".tmp",
-                                              canfil.getParentFile());
+                                              canfil.getParentFile(), false, true);
         try {
             try {
                 FILE_UTILS.rename(canfil, temp);

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java
Fri Jan  4 12:46:26 2008
@@ -448,13 +448,12 @@
                 // How to handle non-file-Resources? I copy temporarily the
                 // resource to a file and use the file-implementation.
                 FileUtils fu = FileUtils.getFileUtils();
-                File tmpFile = fu.createTempFile("modified-", ".tmp", null);
+                File tmpFile = fu.createTempFile("modified-", ".tmp", null, true, true);
                 Resource tmpResource = new FileResource(tmpFile);
                 ResourceUtils.copyResource(resource, tmpResource);
                 boolean isSelected = isSelected(tmpFile.getParentFile(),
                                                 tmpFile.getName(),
                                                 resource.toLongString());
-                tmpFile.delete();
                 return isSelected;
             } catch (UnsupportedOperationException uoe) {
                 log("The resource '"

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/FileUtils.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/FileUtils.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/FileUtils.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/FileUtils.java Fri
Jan  4 12:46:26 2008
@@ -784,21 +784,24 @@
     }
 
     /**
-     * Create a temporary file in a given directory.
+     * Create a File object for a temporary file in a given directory. Without
+     * actually creating the file.
      *
      * <p>The file denoted by the returned abstract pathname did not
      * exist before this method was invoked, any subsequent invocation
      * of this method will yield a different file name.</p>
-     *
-     * <p>As of ant 1.8 the file is actually created.</p>
+     * <p>
+     * The filename is prefixNNNNNsuffix where NNNN is a random number.
+     * </p>
      *
      * @param prefix prefix before the random number.
      * @param suffix file extension; include the '.'.
      * @param parentDir Directory to create the temporary file in;
      * java.io.tmpdir used if not specified.
      *
-     * @return a File reference to the new temporary file.
-     * @since Ant 1.5
+     * @return a File reference to the new, nonexistent temporary file.
+     * @deprecated since Ant 1.7.1
+     * @since Ant 1.7
      */
     public File createTempFile(String prefix, String suffix, File parentDir) {
         return createTempFile(prefix, suffix, parentDir, false);
@@ -811,28 +814,41 @@
      * exist before this method was invoked, any subsequent invocation
      * of this method will yield a different file name.</p>
      *
-     * <p>As of ant 1.8 the file is actually created.</p>
-     *
      * @param prefix prefix before the random number.
      * @param suffix file extension; include the '.'.
      * @param parentDir Directory to create the temporary file in;
      * java.io.tmpdir used if not specified.
      * @param deleteOnExit whether to set the tempfile for deletion on
      *        normal VM exit.
-     *
+     * @param createFile true if the file must actually be created. If false
+     * chances exist that a file with the same name is created in the time
+     * between invoking this method and the moment the file is actually created.
+     * If possible set to true.
      * @return a File reference to the new temporary file.
-     * @since Ant 1.7
+     * @since Ant 1.7.1
      */
     public File createTempFile(String prefix, String suffix, File parentDir,
-                               boolean deleteOnExit) {
+                               boolean deleteOnExit, boolean createFile) {
         File result = null;
         String parent = (parentDir == null)
                 ? System.getProperty("java.io.tmpdir")
                 : parentDir.getPath();
-        try {
-            result = File.createTempFile(prefix, suffix, new File(parent));
-        } catch (IOException e) {
-            throw new BuildException("Could not create tempfile in " + parent, e);
+
+        if (createFile) {
+            try {
+                result = File.createTempFile(prefix, suffix, new File(parent));
+            } catch (IOException e) {
+                throw new BuildException("Could not create tempfile in "
+                        + parent, e);
+            }
+        } else {
+            DecimalFormat fmt = new DecimalFormat("#####");
+            synchronized (rand) {
+                do {
+                    result = new File(parent, prefix
+                            + fmt.format(Math.abs(rand.nextInt())) + suffix);
+                } while (result.exists());
+            }
         }
         if (deleteOnExit) {
             result.deleteOnExit();
@@ -859,25 +875,12 @@
      *        normal VM exit.
      *
      * @return a File reference to the new, nonexistent temporary file.
-     * @since Ant 1.8
+     * @deprecated since Ant 1.7.1
+     * @since Ant 1.7
      */
-    public File createTempFileName(String prefix, String suffix,
+    public File createTempFile(String prefix, String suffix,
             File parentDir, boolean deleteOnExit) {
-        File result = null;
-        String parent = (parentDir == null) ? System
-                .getProperty("java.io.tmpdir") : parentDir.getPath();
-
-        DecimalFormat fmt = new DecimalFormat("#####");
-        synchronized (rand) {
-            do {
-                result = new File(parent, prefix
-                        + fmt.format(Math.abs(rand.nextInt())) + suffix);
-            } while (result.exists());
-        }
-        if (deleteOnExit) {
-            result.deleteOnExit();
-        }
-        return result;
+        return createTempFile(prefix, suffix, parentDir, deleteOnExit, false);
     }
 
     /**

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/JavaEnvUtils.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/JavaEnvUtils.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/JavaEnvUtils.java Fri
Jan  4 12:46:26 2008
@@ -440,7 +440,7 @@
      */
     public static File createVmsJavaOptionFile(String[] cmd)
             throws IOException {
-        File script = FILE_UTILS.createTempFile("ANT", ".JAVA_OPTS", null);
+        File script = FILE_UTILS.createTempFile("ANT", ".JAVA_OPTS", null, false, true);
         PrintWriter out = null;
         try {
             out = new PrintWriter(new BufferedWriter(new FileWriter(script)));

Modified: ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java
Fri Jan  4 12:46:26 2008
@@ -347,7 +347,7 @@
             return;
         }
         myBuild = new MonitoredBuild(new File(System.getProperty("root"), BUILD_FILE), "spawn");
-        logFile = FILE_UTILS.createTempFileName("spawn","log", project.getBaseDir(),false);
+        logFile = FILE_UTILS.createTempFile("spawn","log", project.getBaseDir(), false, false);
         // this is guaranteed by FileUtils#createTempFile
         assertTrue("log file not existing", !logFile.exists());
         // make the spawned process run 4 seconds

Modified: ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java
Fri Jan  4 12:46:26 2008
@@ -175,7 +175,7 @@
     }
 
     public void testSpawn() {
-        File logFile = FILE_UTILS.createTempFileName("spawn", "log", project.getBaseDir(),
false);
+        File logFile = FILE_UTILS.createTempFile("spawn", "log", project.getBaseDir(), false,
false);
         // this is guaranteed by FileUtils#createTempFile
         assertTrue("log file not existing", !logFile.exists());
         project.setProperty("logFile", logFile.getAbsolutePath());

Modified: ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java
Fri Jan  4 12:46:26 2008
@@ -390,7 +390,7 @@
      * configure() method of ModifiedSelector. This testcase tests that.
      */
     public void testCreatePropertiesCacheViaCustomSelector() {
-        File cachefile = FILE_UTILS.createTempFile("tmp-cache-", ".properties", null);
+        File cachefile = FILE_UTILS.createTempFile("tmp-cache-", ".properties", null, false,
true);
         try {
             // initialize test environment (called "bed")
             makeBed();

Modified: ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java?rev=608996&r1=608995&r2=608996&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
Fri Jan  4 12:46:26 2008
@@ -337,7 +337,7 @@
 
     public void testCreateTempFile() {
     	// null parent dir
-    	File tmp1 = FILE_UTILS.createTempFile("pre", ".suf", null, false);
+    	File tmp1 = FILE_UTILS.createTempFile("pre", ".suf", null, false, true);
     	String  tmploc = System.getProperty("java.io.tmpdir");
     	String name = tmp1.getName();
     	assertTrue("starts with pre", name.startsWith("pre"));
@@ -351,7 +351,7 @@
     	dir2.mkdir();
     	removeThis = dir2;
 
-    	File tmp2 = FILE_UTILS.createTempFile("pre", ".suf", dir2, true);
+    	File tmp2 = FILE_UTILS.createTempFile("pre", ".suf", dir2, true, true);
     	String name2 = tmp2.getName();
     	assertTrue("starts with pre", name2.startsWith("pre"));
     	assertTrue("ends with .suf", name2.endsWith(".suf"));
@@ -360,28 +360,24 @@
     			tmp2.getAbsolutePath());
     	tmp2.delete();
     	dir2.delete();
-    }
-    /**
-     * Test createTempFileName
-     */
-    public void testCreateTempFileName() {
+
         File parent = new File((new File("/tmp")).getAbsolutePath());
-        File tmp1 = FILE_UTILS.createTempFileName("pre", ".suf", parent, false);
+        tmp1 = FILE_UTILS.createTempFile("pre", ".suf", parent, false, false);
         assertTrue("new file", !tmp1.exists());
 
-        String name = tmp1.getName();
+        name = tmp1.getName();
         assertTrue("starts with pre", name.startsWith("pre"));
         assertTrue("ends with .suf", name.endsWith(".suf"));
         assertEquals("is inside parent dir",
                      parent.getAbsolutePath(),
                      tmp1.getParent());
 
-        File tmp2 = FILE_UTILS.createTempFileName("pre", ".suf", parent, false);
+        tmp2 = FILE_UTILS.createTempFile("pre", ".suf", parent, false, false);
         assertTrue("files are different",
                    !tmp1.getAbsolutePath().equals(tmp2.getAbsolutePath()));
 
         // null parent dir
-        File tmp3 = FILE_UTILS.createTempFileName("pre", ".suf", null, false);
+        File tmp3 = FILE_UTILS.createTempFile("pre", ".suf", null, false);
         String  tmploc = System.getProperty("java.io.tmpdir");
         assertEquals((new File(tmploc, tmp3.getName())).getAbsolutePath(),
                      tmp3.getAbsolutePath());



Mime
View raw message