Skip to content
Snippets Groups Projects
Commit d4ece746 authored by Simon Barner's avatar Simon Barner
Browse files

Add getTempDirPath() and getSystemTempDirPath()


Issue-Ref: 2443
Signed-off-by: default avatarSimon Barner <barner@fortiss.org>
parent b31c1849
No related branches found
No related tags found
1 merge request!32443 os architecture case distinctions
...@@ -13,6 +13,6 @@ PointUtils.java b21c92cc8e80ece9d87ede8a750f4de314379743 GREEN ...@@ -13,6 +13,6 @@ PointUtils.java b21c92cc8e80ece9d87ede8a750f4de314379743 GREEN
PointsUtils.java bad69811c59004948929f6a57edd5a79c0bf8643 GREEN PointsUtils.java bad69811c59004948929f6a57edd5a79c0bf8643 GREEN
RectangleLayoutUtils.java cdd61d162761da7f3e1d3512264135b9b0d564ff GREEN RectangleLayoutUtils.java cdd61d162761da7f3e1d3512264135b9b0d564ff GREEN
SnapToGridUtils.java 413785d7a8655db31a129b6f821e1d5f859aa726 GREEN SnapToGridUtils.java 413785d7a8655db31a129b6f821e1d5f859aa726 GREEN
SystemUtils.java 8546c23e43551a58f4aca273015c496546793611 YELLOW SystemUtils.java bd40519b5e286f274f47815ccc8d320fd65c2c0a YELLOW
VisualizationModelElementFactory.java 18e67450ee4cf4a03dc88a10becb0fb6ce4c1bad GREEN VisualizationModelElementFactory.java 18e67450ee4cf4a03dc88a10becb0fb6ce4c1bad GREEN
ZoomUtils.java a339613fde18281bed3b55b529a053d348545bc7 GREEN ZoomUtils.java a339613fde18281bed3b55b529a053d348545bc7 GREEN
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.utils; package org.fortiss.tooling.base.utils;
import static java.io.File.separator;
import static java.lang.System.getProperty;
import static java.util.UUID.randomUUID;
/** /**
* Utility functions that deal with the underlying system. * Utility functions that deal with the underlying system.
* *
...@@ -70,4 +74,33 @@ public class SystemUtils { ...@@ -70,4 +74,33 @@ public class SystemUtils {
} }
return ""; return "";
} }
/** Returns the path to the system's temporary directory. */
public static String getSystemTempDirPath() {
return getTempDirPath(false, null);
}
/**
* Returns the path to a directory in the system's temporary directory that follows the pattern<br>
* {@code <SYS_TEMP_DIR>[/UNIQUE_DIR][/SUB_DIR]}
*
* @param unique
* Flag if a unique sub-directory should be appended to the path of the system's
* temporary directory.
* @param subdir
* Sub-directory within system's temporary directory (may be {@code null}).
* @return Path to a directory in the system's temporary directory.
*/
public static String getTempDirPath(boolean unique, String subdir) {
String tmpDir = getProperty("java.io.tmpdir");
if(unique) {
tmpDir += separator + randomUUID();
}
if(subdir != null) {
tmpDir += separator + subdir;
}
return tmpDir;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment