aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2012-10-11 08:41:42 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-10-11 08:41:42 -0700
commitb0aa9606aede0466139567af63f18182a240ea8c (patch)
treed3c78194f52e6b5790dae5cf5ed9072d9de89e1d /java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
parentfa95e9048d3971c102a982b2d854ed82c4baafa8 (diff)
parent726e98b7378987b2cfe46ea5395692640b108e83 (diff)
downloadlatinime-b0aa9606aede0466139567af63f18182a240ea8c.tar.gz
latinime-b0aa9606aede0466139567af63f18182a240ea8c.tar.xz
latinime-b0aa9606aede0466139567af63f18182a240ea8c.zip
am 726e98b7: am c1a1937c: am 2220aeed: Merge "Put temporary files under a separate directory." into jb-mr1-dev
* commit '726e98b7378987b2cfe46ea5395692640b108e83': Put temporary files under a separate directory.
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java')
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
index 201a10187..c747dc673 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
@@ -164,6 +164,18 @@ final class BinaryDictionaryGetter {
}
/**
+ * Generates a unique temporary file name in the app cache directory.
+ *
+ * This is unique as long as it doesn't get called twice in the same millisecond by the same
+ * thread, which should be more than enough for our purposes.
+ */
+ public static String getTempFileName(String id, Context context) {
+ final String fileName = replaceFileNameDangerousCharacters(id);
+ return context.getCacheDir() + File.separator + fileName + "."
+ + Thread.currentThread().getId() + "." + System.currentTimeMillis();
+ }
+
+ /**
* Returns a file address from a resource, or null if it cannot be opened.
*/
private static AssetFileAddress loadFallbackResource(final Context context,