diff --git a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/utils/.ratings b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/utils/.ratings index 83fd00a60c96f3105e2fb7a7b81b9ea414f481b1..1904c50db3a30ae1636472a0f54b391c8a8eda83 100644 --- a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/utils/.ratings +++ b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/utils/.ratings @@ -13,6 +13,6 @@ PointUtils.java b21c92cc8e80ece9d87ede8a750f4de314379743 GREEN PointsUtils.java bad69811c59004948929f6a57edd5a79c0bf8643 GREEN RectangleLayoutUtils.java cdd61d162761da7f3e1d3512264135b9b0d564ff GREEN SnapToGridUtils.java 413785d7a8655db31a129b6f821e1d5f859aa726 GREEN -SystemUtils.java 8546c23e43551a58f4aca273015c496546793611 YELLOW +SystemUtils.java bd40519b5e286f274f47815ccc8d320fd65c2c0a YELLOW VisualizationModelElementFactory.java 18e67450ee4cf4a03dc88a10becb0fb6ce4c1bad GREEN ZoomUtils.java a339613fde18281bed3b55b529a053d348545bc7 GREEN diff --git a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/utils/SystemUtils.java b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/utils/SystemUtils.java index 8546c23e43551a58f4aca273015c496546793611..bd40519b5e286f274f47815ccc8d320fd65c2c0a 100644 --- a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/utils/SystemUtils.java +++ b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/utils/SystemUtils.java @@ -15,6 +15,10 @@ +--------------------------------------------------------------------------*/ 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. * @@ -70,4 +74,33 @@ public class SystemUtils { } 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; + } }