aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-30 20:43:41 +0200
committerSven Gothel <[email protected]>2011-09-30 20:43:41 +0200
commit774b7196b6d3a7787e37703fa161e565afa380e0 (patch)
tree854b2317506c9809712e43d9166e8ffe259e2acb /src/java/com
parent16bae378d3ff39d624cab44712c47b099c491934 (diff)
IOUtil's getTempRoot()'s Fix chicken-egg problem ; Adding proper API doc
IOUtil's getTempRoot(): - Fix chicken-egg problem w/ Platform init, using Android.isavailable;
Diffstat (limited to 'src/java/com')
-rw-r--r--src/java/com/jogamp/common/util/IOUtil.java28
1 files changed, 26 insertions, 2 deletions
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;
}