diff --git a/README.md b/README.md index 6675ca4..d3d17bd 100644 --- a/README.md +++ b/README.md @@ -89,11 +89,6 @@ if you want to deactivate all, please clear all textboxes. Please visit [Servers] for more information. -#### Portable Mode - -If you want to put all temporary files into shadowsocks/temp folder instead of -system temp folder, create a `shadowsocks_portable_mode.txt` into shadowsocks folder. - #### Develop [Visual Studio 2015] & [.NET Framework 4.6.2 Developer Pack] are required. diff --git a/shadowsocks-csharp/Controller/Service/PrivoxyRunner.cs b/shadowsocks-csharp/Controller/Service/PrivoxyRunner.cs index 970473b..061215e 100644 --- a/shadowsocks-csharp/Controller/Service/PrivoxyRunner.cs +++ b/shadowsocks-csharp/Controller/Service/PrivoxyRunner.cs @@ -121,21 +121,13 @@ namespace Shadowsocks.Controller { try { - if (Utils.IsPortableMode()) - { - /* - * Under PortableMode, we could identify it by the path of ss_privoxy.exe. - */ - var path = process.MainModule.FileName; + /* + * Under PortableMode, we could identify it by the path of ss_privoxy.exe. + */ + var path = process.MainModule.FileName; - return Utils.GetTempPath("ss_privoxy.exe").Equals(path); - } - else - { - var cmd = process.GetCommandLine(); + return Utils.GetTempPath("ss_privoxy.exe").Equals(path); - return cmd.Contains(_uniqueConfigFile); - } } catch (Exception ex) { diff --git a/shadowsocks-csharp/Util/Util.cs b/shadowsocks-csharp/Util/Util.cs index f733193..e428568 100755 --- a/shadowsocks-csharp/Util/Util.cs +++ b/shadowsocks-csharp/Util/Util.cs @@ -25,43 +25,26 @@ namespace Shadowsocks.Util public static class Utils { - private static bool? _portableMode; - private static string TempPath = null; - - public static bool IsPortableMode() - { - if (!_portableMode.HasValue) - { - _portableMode = File.Exists(Path.Combine(Application.StartupPath, "shadowsocks_portable_mode.txt")); - } - - return _portableMode.Value; - } + private static string _tempPath = null; // return path to store temporary files public static string GetTempPath() { - if (TempPath == null) + if (_tempPath == null) { - if (IsPortableMode()) - try - { - Directory.CreateDirectory(Path.Combine(Application.StartupPath, "temp")); - } - catch (Exception e) - { - TempPath = Path.GetTempPath(); - Logging.LogUsefulException(e); - } - finally - { - // don't use "/", it will fail when we call explorer /select xxx/temp\xxx.log - TempPath = Path.Combine(Application.StartupPath, "temp"); - } - else - TempPath = Path.GetTempPath(); + try + { + Directory.CreateDirectory(Path.Combine(Application.StartupPath, "ss_win_temp")); + // don't use "/", it will fail when we call explorer /select xxx/ss_win_temp\xxx.log + _tempPath = Path.Combine(Application.StartupPath, "ss_win_temp"); + } + catch (Exception e) + { + Logging.Error(e); + throw; + } } - return TempPath; + return _tempPath; } // return a full path with filename combined which pointed to the temporary directory