From cddb6a95516860812f3f21960f2a75116be5b056 Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 24 Jan 2019 11:31:55 +0800 Subject: [PATCH] [ST3] Using Sublime Text's cache directory (#90 and #92, thanks to @gh640 and @evandrocoan) --- ConvertToUTF8.py | 14 ++++++++------ messages.json | 1 + messages/1.2.12.txt | 4 ++++ 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 messages/1.2.12.txt diff --git a/ConvertToUTF8.py b/ConvertToUTF8.py index 25a9ba7..1776709 100644 --- a/ConvertToUTF8.py +++ b/ConvertToUTF8.py @@ -6,12 +6,10 @@ if sys.version_info < (3, 0): from chardet.universaldetector import UniversalDetector NONE_COMMAND = (None, None, 0) - CACHE_ROOT = os.path.join(sublime.packages_path(), 'User') ST3 = False else: from .chardet.universaldetector import UniversalDetector NONE_COMMAND = ('', None, 0) - CACHE_ROOT = os.path.join(sublime.cache_path(), 'ConvertToUTF8') ST3 = True import codecs import threading @@ -176,13 +174,17 @@ def clean_temp_folder(): os.unlink(tmp_file) def init_settings(): - global encoding_cache, TMP_DIR + global encoding_cache, TMP_DIR, CACHE_ROOT + if ST3: + CACHE_ROOT = os.path.join(sublime.cache_path(), 'ConvertToUTF8') + else: + CACHE_ROOT = os.path.join(sublime.packages_path(), 'User') + TMP_DIR = os.path.join(CACHE_ROOT, 'c2u_tmp') + if not os.path.exists(TMP_DIR): + os.makedirs(TMP_DIR) encoding_cache = EncodingCache() get_settings() sublime.load_settings('ConvertToUTF8.sublime-settings').add_on_change('get_settings', get_settings) - TMP_DIR = os.path.join(CACHE_ROOT, 'c2u_tmp') - if not os.path.exists(TMP_DIR): - os.mkdir(TMP_DIR) def setup_views(): clean_temp_folder() diff --git a/messages.json b/messages.json index 7fd3386..5fa178b 100644 --- a/messages.json +++ b/messages.json @@ -1,4 +1,5 @@ { + "1.2.12": "messages/1.2.12.txt", "1.2.11": "messages/1.2.11.txt", "1.2.10": "messages/1.2.10.txt", "1.2.9": "messages/1.2.9.txt", diff --git a/messages/1.2.12.txt b/messages/1.2.12.txt new file mode 100644 index 0000000..47b106e --- /dev/null +++ b/messages/1.2.12.txt @@ -0,0 +1,4 @@ +ConvertToUTF8 1.2.12 Changelog + +Enhancements +- [ST3] Using Sublime Text's cache directory (#90 and #92, thanks to @gh640 and @evandrocoan)