Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions duke-core/src/main/java/no/priv/garshol/duke/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

import no.priv.garshol.duke.DukeException;

Expand Down Expand Up @@ -37,17 +38,7 @@ public static File createTempDirectory(String prefix) {
File temp = null;

try {
temp = File.createTempFile(prefix != null ? prefix : "temp", Long.toString(System.nanoTime()));

if (!(temp.delete())) {
throw new IOException("Could not delete temp file: "
+ temp.getAbsolutePath());
}

if (!(temp.mkdir())) {
throw new IOException("Could not create temp directory: "
+ temp.getAbsolutePath());
}
temp = Files.createTempDirectory(prefix != null ? prefix : "temp" + Long.toString(System.nanoTime())).toFile();
} catch (IOException e) {
throw new DukeException("Unable to create temporary directory with prefix " + prefix, e);
}
Expand Down