Browse Source

Merge e3c69f8fff into 5c172a3e49

pull/187/merge
EraserKing 10 years ago
parent
commit
c51b122f24
1 changed files with 45 additions and 0 deletions
  1. +45
    -0
      shadowsocks-csharp/Controller/PolipoRunner.cs

+ 45
- 0
shadowsocks-csharp/Controller/PolipoRunner.cs View File

@@ -20,6 +20,32 @@ namespace Shadowsocks.Controller
static PolipoRunner()
{
temppath = Path.GetTempPath();
string[] commandLineArgs = Environment.GetCommandLineArgs();
for (int i = 0; i < commandLineArgs.Length; i++)
{
string commandLineArg = commandLineArgs[i];
if (commandLineArg.ToLower() == "/SameFolderForPolipo".ToLower())
{
temppath = Environment.CurrentDirectory;
}
if (commandLineArg.ToLower() == "/PolipoFolder".ToLower())
{
if (i == commandLineArgs.Length - 1)
{
System.Windows.Forms.MessageBox.Show("Polipo folder not specified.", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
throw new Exception("Polipo folder not specified");
}
else if (!IsDirectoryValid(commandLineArgs[i + 1]))
{
System.Windows.Forms.MessageBox.Show("Polipo folder not valid.", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
throw new Exception("Polipo folder not valid");
}
else
{
temppath = commandLineArgs[i + 1];
}
}
}
try
{
FileManager.UncompressFile(temppath + "/ss_polipo.exe", Resources.polipo_exe);
@@ -122,5 +148,24 @@ namespace Shadowsocks.Controller
}
throw new Exception("No free port found.");
}
public static bool IsDirectoryValid(string path)
{
try
{
if (new DirectoryInfo(path).Exists == true)
{
return true;
}
else
{
return false;
}
}
catch (Exception e)
{
return false;
}
}
}
}

Loading…
Cancel
Save