Make the previous portable mode as default
- change dir name to "ss_win_temp" to make things clear. - throw any exception caught when creating temp folder To workaround silly cleaning softwares and careless users. Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user