commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r821292 - /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/File.java
Date Sat, 03 Oct 2009 11:06:33 GMT
Author: mturk
Date: Sat Oct  3 11:06:33 2009
New Revision: 821292

URL: http://svn.apache.org/viewvc?rev=821292&view=rev
Log:
Add Java part of tempdir API

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/File.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/File.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/File.java?rev=821292&r1=821291&r2=821292&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/File.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/File.java Sat
Oct  3 11:06:33 2009
@@ -58,6 +58,8 @@
                                         throws IOException, SecurityException;
     private static native int       attrg0(String pathname)
                                         throws IOException, SecurityException;
+    private static native String    tmpdir0(String pathname, String prefix)
+                                        throws IOException, SecurityException;
 
     // Cached FileType Enum integer value.
     private int fileType = -1;
@@ -444,6 +446,44 @@
     }
 
     /**
+     * Creates a new temporary directory with {@code prefix}.
+     * <p>
+     * </p>
+     * @param prefix The prefix for the new drectory.
+     * @return Newly created unique directory abstract path.
+     *
+     * @throws IOException in case of error.
+     * @throws SecurityException if Write access to the system temporary
+     *         directory is denied.
+     */
+    public File createTempDirectory(String prefix)
+        throws IOException, SecurityException
+    {
+        String dir = tmpdir0(null, prefix);
+        return new File(dir, FileType.DIR.valueOf());
+    }
+
+    /**
+     * Creates a new temporary directory with {@code prefix} inside
+     * directory specified by {@code path}.
+     * <p>
+     * </p>
+     * @param path Where to create a new drectory.
+     * @param prefix The prefix for the new drectory.
+     * @return Newly created unique directory abstract path.
+     *
+     * @throws IOException in case of error.
+     * @throws SecurityException if Write access to the directory specified
+     *         by {@code path} is denied.
+     */
+    public File createTempDirectory(File path, String prefix)
+        throws IOException, SecurityException
+    {
+        String dir = tmpdir0(path.getPath(), prefix);
+        return new File(dir, FileType.DIR.valueOf());
+    }
+
+    /**
      * Return target pathname of this abstract {@code File} instance.
      *
      * @return Pathname this {@code File} points to.



Mime
View raw message