Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
Mossimos committed Sep 4, 2021
1 parent 4a75f26 commit e56003a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,58 @@ async ValueTask IPlatformService.AdminShellAsync(string shell, bool admin)
stream.Flush();
stream.Close();
}
using var p = new Process();
p.StartInfo.FileName = "/bin/bash";
p.StartInfo.Arguments = $"\"{file.FullName}\"";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Exited += (object? _, EventArgs _) =>
using (var p = new Process())
{
p.StartInfo.FileName = "/bin/bash";
p.StartInfo.Arguments = $"\"{file.FullName}\"";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Exited += (object? _, EventArgs _) =>
{
if (file.Exists)
file.Delete();
if (p.ExitCode != 0)
{
((IPlatformService)this).AdminShell(shell);
}
};
p.Start();
var ret = p.StandardOutput.ReadToEnd();
p.Kill();
if (file.Exists)
file.Delete();
if (p.ExitCode != 0)
{
((IPlatformService)this).AdminShell(shell);
}
};
p.Start();
var ret = p.StandardOutput.ReadToEnd();
p.Kill();
if (file.Exists)
file.Delete();
}
}
public string GetCommandLineArgs(Process process)
{
return string.Empty;
}

public const string xdg = "xdg-open";
public void OpenFolder(string dirPath)
{
if (IOPath.IsDirectory(dirPath))
{
IDesktopPlatformService.Instance.StartProcess(xdg, dirPath);
}
else
{
var path = new FileInfo(dirPath);
if (!string.IsNullOrWhiteSpace(path.DirectoryName))
IDesktopPlatformService.Instance.StartProcess(xdg, path.DirectoryName);
}
}

public const string kate = "kate";
public const string vi = "vi";
const string VSC = "code";

public string? GetFileName(TextReaderProvider provider)
public string? GetFileName(TextReaderProvider provider) => provider switch
{
return vi;
}
TextReaderProvider.VSCode => VSC,
TextReaderProvider.Notepad => kate,
_ => null,
};

public void SetSystemSessionEnding(Action action)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Application.UI.Resx;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Properties;
using System.Reactive;
Expand Down Expand Up @@ -56,7 +57,7 @@ public CommunityProxyPageViewModel()
//});
OpenCertificateDirCommand = ReactiveCommand.Create(() =>
{
DI.Get<IDesktopPlatformService>().OpenFolder(IOPath.AppDataDirectory + @$"\{ThisAssembly.AssemblyProduct}.Certificate.cer");
DI.Get<IDesktopPlatformService>().OpenFolder(Path.Combine(IOPath.AppDataDirectory, $"{ThisAssembly.AssemblyProduct}.Certificate.cer"));
});
ProxySettingsCommand = ReactiveCommand.Create(() =>
{
Expand Down

0 comments on commit e56003a

Please sign in to comment.