Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FileNotFoundError: [WinError 3] The system cannot find the #92

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions ConvertToUTF8.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import sublime, sublime_plugin
import sys
import os
is_python2 = False
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')
is_python2 = True
ST3 = False
plugin_loaded()
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 @@ -182,7 +183,7 @@ def init_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)
os.makedirs(TMP_DIR)

def setup_views():
clean_temp_folder()
Expand All @@ -200,6 +201,12 @@ def setup_views():
threading.Thread(target=lambda: detect(view, file_name, cnt)).start()

def plugin_loaded():
global CACHE_ROOT
if is_python2:
CACHE_ROOT = os.path.join(sublime.packages_path(), 'User')
else:
CACHE_ROOT = os.path.join(sublime.cache_path(), 'ConvertToUTF8')

init_settings()
setup_views()

Expand Down