aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-10-11 16:08:25 +0900
committerJean Chalard <jchalard@google.com>2012-10-11 17:53:06 +0900
commit66c90cd2ae49c49da8aeda5ab1d86bd9b76434c7 (patch)
tree1828bc63088749ed4e7fc7db0fa2cf3038427936 /java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
parent471252b9da20f4b1d7f55fd15a34d3642a564fcb (diff)
downloadlatinime-66c90cd2ae49c49da8aeda5ab1d86bd9b76434c7.tar.gz
latinime-66c90cd2ae49c49da8aeda5ab1d86bd9b76434c7.tar.xz
latinime-66c90cd2ae49c49da8aeda5ab1d86bd9b76434c7.zip
Put temporary files under a separate directory.
Bug: 7328003 Change-Id: Ibe5278ea209d149f87fd08785c77b17e3859948e
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,