43 lines
No EOL
1.1 KiB
C#
43 lines
No EOL
1.1 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Text;
|
|
using Directory = TeaBox.Directory;
|
|
|
|
/// <summary>
|
|
/// Utility to manipulate Cygwin
|
|
/// </summary>
|
|
internal static class Cygwin
|
|
{
|
|
public const string CygwinExePath = @"C:\Cygwin";
|
|
|
|
public static string ConvertToCygPath(string pathToConvert)
|
|
{
|
|
if (!Directory.Exists(CygwinExePath))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
var process = new Process
|
|
{
|
|
StartInfo = new ProcessStartInfo
|
|
{
|
|
FileName = Path.Combine(CygwinExePath, "bin", "cygpath.exe"),
|
|
Arguments = $"-u \"{pathToConvert}\"",
|
|
UseShellExecute = false,
|
|
RedirectStandardOutput = true,
|
|
CreateNoWindow = false
|
|
}
|
|
};
|
|
|
|
process.Start();
|
|
|
|
var builder = new StringBuilder();
|
|
while (!process.StandardOutput.EndOfStream)
|
|
{
|
|
builder.Append(process.StandardOutput.ReadToEnd().TrimEnd(Environment.NewLine.ToCharArray()));
|
|
}
|
|
|
|
return builder.ToString();
|
|
}
|
|
} |