Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,15 @@ public File getDir() {
* @return a subdirectory
*/
public File getDir(String subDir) {
return createDirectory(getPath().resolve(subDir)).toFile();
return getPath(subDir).toFile();
}

private Path getPath() {
/**
* Return the path to be used for application specific temp files.
* @return the application temp path
* @since 4.1.0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't make 4.1.0 because we're already at RC. We can consider it for 4.2.0.

*/
public Path getPath() {
if (this.path == null) {
this.pathLock.lock();
try {
Expand All @@ -135,6 +140,16 @@ private Path getPath() {
return path;
}

/**
* Return the path of a subdirectory of the application temp.
* @param subDir the subdirectory name
* @return the subdirectory path
* @since 4.1.0
*/
public Path getPath(String subDir) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should add this. The user can do temp.path().resolve(...) directly.

return createDirectory(getPath().resolve(subDir));
}

private Path createDirectory(Path path) {
try {
FileSystem fileSystem = path.getFileSystem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ void getSubDir() {
assertThat(temp.getDir("abc")).isEqualTo(new File(temp.getDir(), "abc"));
}

@Test
void getPathReturnsSamePathAsGetDir() {
ApplicationTemp temp = new ApplicationTemp();
assertThat(temp.getPath()).isEqualTo(temp.getDir().toPath());
}

@Test
void getPathSubDir() {
ApplicationTemp temp = new ApplicationTemp();
assertThat(temp.getPath("abc")).isEqualTo(temp.getPath().resolve("abc"));
}

@Test
void posixPermissions() throws IOException {
ApplicationTemp temp = new ApplicationTemp();
Expand Down