File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
src/main/java/org/scijava/util Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -397,6 +397,30 @@ public static String limitPath(final String path, final int limit) {
397397 return new String (shortPathArray );
398398 }
399399
400+ /**
401+ * Creates a temporary directory.
402+ * <p>
403+ * Since there is no atomic operation to do that, we create a temporary file,
404+ * delete it and create a directory in its place. To avoid race conditions, we
405+ * use the optimistic approach: if the directory cannot be created, we try to
406+ * obtain a new temporary file rather than erroring out.
407+ * </p>
408+ * <p>
409+ * It is the caller's responsibility to make sure that the directory is
410+ * deleted; see {@link #deleteRecursively(File)}.
411+ * </p>
412+ *
413+ * @param prefix The prefix string to be used in generating the file's name;
414+ * see {@link File#createTempFile(String, String, File)}
415+ * @return An abstract pathname denoting a newly-created empty directory
416+ * @throws IOException
417+ */
418+ public static File createTemporaryDirectory (final String prefix )
419+ throws IOException
420+ {
421+ return createTemporaryDirectory (prefix , null , null );
422+ }
423+
400424 /**
401425 * Creates a temporary directory.
402426 * <p>
You can’t perform that action at this time.
0 commit comments