diff options
author | Sven Gothel <[email protected]> | 2011-09-30 14:47:05 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-09-30 14:47:05 +0200 |
commit | 16bae378d3ff39d624cab44712c47b099c491934 (patch) | |
tree | e612a9f5795156b124a1a38c9277b2a4c4ae686a /src/java/com | |
parent | 3b52b7adafeda64730fb0070ab16655aa706b254 (diff) |
IOUtil: Generalize w/ getTempRoot()
Diffstat (limited to 'src/java/com')
-rw-r--r-- | src/java/com/jogamp/common/util/IOUtil.java | 26 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/cache/TempFileCache.java | 6 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index 4038caf..faa3c20 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -448,6 +448,7 @@ public class IOUtil { /** * @see File#createTempFile(String, String) * @see File#createTempFile(String, String, File) + * @see #getTempRoot() * * @param prefix * @param suffix @@ -459,20 +460,27 @@ public class IOUtil { public static File createTempFile(String prefix, String suffix) throws IllegalArgumentException, IOException, SecurityException { + return File.createTempFile( prefix, suffix, getTempRoot() ); + } + + public static File getTempRoot() + throws SecurityException + { if(Platform.OS_TYPE == Platform.OSType.ANDROID) { - Context ctx = StaticContext.getContext(); + final Context ctx = StaticContext.getContext(); if(null != ctx) { - final File td = ctx.getDir("temp", Context.MODE_WORLD_READABLE); + final File tmpRoot = ctx.getDir("temp", Context.MODE_WORLD_READABLE); if(DEBUG) { - System.err.println("IOUtil.createTempFile(Android): ctx temp dir: "+td.getAbsolutePath()); + System.err.println("IOUtil.getTempRoot(Android): temp dir: "+tmpRoot.getAbsolutePath()); } - final File f = File.createTempFile( prefix, suffix, td ); - if(DEBUG) { - System.err.println("IOUtil.createTempFile(Android): temp file: "+f.getAbsolutePath()); - } - return f; + return tmpRoot; } } - return File.createTempFile( prefix, suffix ); + 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()); + } + return tmpRoot; } } diff --git a/src/java/com/jogamp/common/util/cache/TempFileCache.java b/src/java/com/jogamp/common/util/cache/TempFileCache.java index a4cb2f4..9c2556d 100644 --- a/src/java/com/jogamp/common/util/cache/TempFileCache.java +++ b/src/java/com/jogamp/common/util/cache/TempFileCache.java @@ -34,6 +34,8 @@ import java.io.IOException; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; +import com.jogamp.common.util.IOUtil; + import jogamp.common.Debug; public class TempFileCache { @@ -141,10 +143,8 @@ public class TempFileCache { } synchronized (System.out) { - // Get the name of the tmpbase directory. - String tmpBaseName = System.getProperty("java.io.tmpdir") + File.separator + tmpDirPrefix ; - tmpBaseDir = new File(tmpBaseName); + tmpBaseDir = new File(IOUtil.getTempRoot(), tmpDirPrefix); tmpRootPropValue = System.getProperty(tmpRootPropName); |