diff options
-rwxr-xr-x | make/scripts/runtest.sh | 6 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/IOUtil.java | 28 |
2 files changed, 29 insertions, 5 deletions
diff --git a/make/scripts/runtest.sh b/make/scripts/runtest.sh index 5239ce4..9326412 100755 --- a/make/scripts/runtest.sh +++ b/make/scripts/runtest.sh @@ -30,7 +30,7 @@ rm -f $LOG #D_ARGS="-Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true" #D_ARGS="-Djogamp.debug.TraceLock" #D_ARGS="-Djogamp.debug.JARUtil" -#D_ARGS="-Djogamp.debug.TempFileCache" +D_ARGS="-Djogamp.debug.TempFileCache" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.JARUtil" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.gluegen.UseTempJarCache=false" #D_ARGS="-Djogamp.debug.JNILibLoader" @@ -51,7 +51,7 @@ function onetest() { #onetest com.jogamp.common.GlueGenVersion 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestVersionInfo 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestIteratorIndexCORE 2>&1 | tee -a $LOG -onetest com.jogamp.common.util.locks.TestRecursiveLock01 2>&1 | tee -a $LOG +#onetest com.jogamp.common.util.locks.TestRecursiveLock01 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestArrayHashSet01 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.IntIntHashMapTest 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.IntObjectHashMapTest 2>&1 | tee -a $LOG @@ -63,4 +63,4 @@ onetest com.jogamp.common.util.locks.TestRecursiveLock01 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestPlatform01 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestIOUtil01 2>&1 | tee -a $LOG -#onetest com.jogamp.common.util.TestTempJarCache 2>&1 | tee -a $LOG +onetest com.jogamp.common.util.TestTempJarCache 2>&1 | tee -a $LOG diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index faa3c20..f9a34f0 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -47,6 +47,7 @@ import jogamp.common.os.android.StaticContext; import android.content.Context; import com.jogamp.common.nio.Buffers; +import com.jogamp.common.os.AndroidVersion; import com.jogamp.common.os.MachineDescription; import com.jogamp.common.os.Platform; @@ -446,6 +447,10 @@ public class IOUtil { } /** + * Utilizing {@link File#createTempFile(String, String, File)} using + * {@link #getTempRoot()} as the directory parameter, ie. location + * of the root temp folder. + * * @see File#createTempFile(String, String) * @see File#createTempFile(String, String, File) * @see #getTempRoot() @@ -463,10 +468,29 @@ public class IOUtil { return File.createTempFile( prefix, suffix, getTempRoot() ); } + /** + * On standard Java, the folder specified by <code>java.io.tempdir</code> + * is returned. + * <p> + * On Android a <code>temp</code> folder relative to the applications local folder + * (see {@link Context#getDir(String, int)}) is returned, if + * the Android application/activity has registered it's Application Context + * via {@link StaticContext#setContext(Context)}. + * This allows using the temp folder w/o the need for <code>sdcard</code> + * access, which would be the <code>java.io.tempdir</code> location on Android! + * </p> + * <p> + * The purpose of this <code>wrapper</code> is to allow unique code to be used + * for both platforms w/o the need to handle extra permissions. + * </p> + * + * @see StaticContext#setContext(Context) + * @see Context#getDir(String, int) + */ public static File getTempRoot() throws SecurityException { - if(Platform.OS_TYPE == Platform.OSType.ANDROID) { + if(AndroidVersion.isAvailable) { final Context ctx = StaticContext.getContext(); if(null != ctx) { final File tmpRoot = ctx.getDir("temp", Context.MODE_WORLD_READABLE); @@ -479,7 +503,7 @@ public class IOUtil { final String tmpRootName = System.getProperty("java.io.tmpdir"); final File tmpRoot = new File(tmpRootName); if(DEBUG) { - System.err.println("IOUtil.getTempRoot("+Platform.OS_TYPE+"): temp dir: "+tmpRoot.getAbsolutePath()); + System.err.println("IOUtil.getTempRoot(isAndroid: "+AndroidVersion.isAvailable+"): temp dir: "+tmpRoot.getAbsolutePath()); } return tmpRoot; } |