diff options
author | 2012-10-11 08:37:45 -0700 | |
---|---|---|
committer | 2012-10-11 08:37:45 -0700 | |
commit | c1a1937c0d079aec18cec992dc5010b409f8fcbd (patch) | |
tree | 61abe922ea489a7e1ff6aeb9e28b3bc7fb2e9692 /java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java | |
parent | 61155c708765068c7e3969deb9d07000a558b1ca (diff) | |
parent | 2220aeedfeeb796d627f2fd659c81256297f145e (diff) | |
download | latinime-c1a1937c0d079aec18cec992dc5010b409f8fcbd.tar.gz latinime-c1a1937c0d079aec18cec992dc5010b409f8fcbd.tar.xz latinime-c1a1937c0d079aec18cec992dc5010b409f8fcbd.zip |
am 2220aeed: Merge "Put temporary files under a separate directory." into jb-mr1-dev
* commit '2220aeedfeeb796d627f2fd659c81256297f145e':
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.java | 12 |
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, |