Skip to content

Commit

Permalink
[ST3] Using Sublime Text's cache directory (#90 and #92, thanks to @g…
Browse files Browse the repository at this point in the history
  • Loading branch information
seanliang committed Jan 24, 2019
1 parent 3c1af91 commit cddb6a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ConvertToUTF8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions messages.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 4 additions & 0 deletions messages/1.2.12.txt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit cddb6a9

Please sign in to comment.