Skip to content
Merged
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: 7 additions & 6 deletions src/main/java/org/perlonjava/runtime/perlmodule/FileTemp.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ private static RuntimeList createTempFile(String template, String suffix, boolea
String namePrefix;

if (prefix.isEmpty()) {
// No directory specified, use temp dir
dir = Paths.get(getTempDir());
// Template is only trailing X's (e.g. "XXXXXX") with no path: Perl creates
// the file in the current working directory, not File::Spec->tmpdir.
dir = Paths.get(System.getProperty("user.dir"));
namePrefix = "";
} else if (prefix.endsWith("/") || prefix.endsWith("\\")) {
// Prefix is a directory path with trailing separator
Expand All @@ -221,7 +222,8 @@ private static RuntimeList createTempFile(String template, String suffix, boolea
templatePath.getFileName().toString() : "";

if (dir == null) {
dir = Paths.get(getTempDir());
// Relative name prefix only (e.g. "fooXXXXXX"): parent is cwd, not tmpdir.
dir = Paths.get(System.getProperty("user.dir"));
}
}

Expand Down Expand Up @@ -301,8 +303,7 @@ private static Path createTempDir(String template) {
String namePrefix;

if (prefix.isEmpty()) {
// No directory specified, use temp dir
parentDir = Paths.get(getTempDir());
parentDir = Paths.get(System.getProperty("user.dir"));
namePrefix = "";
} else if (prefix.endsWith("/") || prefix.endsWith("\\")) {
// Prefix is a directory path with trailing separator
Expand All @@ -316,7 +317,7 @@ private static Path createTempDir(String template) {
templatePath.getFileName().toString() : "";

if (parentDir == null) {
parentDir = Paths.get(getTempDir());
parentDir = Paths.get(System.getProperty("user.dir"));
}
}

Expand Down
Loading