Open file/folder is now cross platform

This commit is contained in:
Robert McRackan 2022-08-02 12:56:52 -04:00
parent 0df4dfdef5
commit a47866b6f7
8 changed files with 7 additions and 34 deletions

View File

@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>8.3.4.1</Version>
<Version>8.3.5.1</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Octokit" Version="1.0.1" />

View File

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AudibleApi" Version="4.6.1.1" />
<PackageReference Include="AudibleApi" Version="4.6.2.1" />
</ItemGroup>
<ItemGroup>

View File

@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dinah.Core" Version="5.0.0.1" />
<PackageReference Include="Dinah.Core" Version="5.1.0.1" />
<PackageReference Include="Dinah.EntityFrameworkCore" Version="5.0.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.7">
<PrivateAssets>all</PrivateAssets>

View File

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dinah.Core" Version="5.0.0.1" />
<PackageReference Include="Dinah.Core" Version="5.1.0.1" />
<PackageReference Include="Polly" Version="7.2.3" />
</ItemGroup>

View File

@ -29,33 +29,6 @@ namespace LibationAvalonia
public static Stream OpenAsset(string assetRelativePath)
=> AssetLoader.Open(new Uri(AssetUriBase, assetRelativePath));
public static bool GoToFile(string path)
=> AppScaffolding.LibationScaffolding.IsWindows ? Go.To.File(path)
: GoToFolder(path is null ? string.Empty : Path.GetDirectoryName(path));
public static bool GoToFolder(string path)
{
if (AppScaffolding.LibationScaffolding.IsWindows)
return Go.To.Folder(path);
else if (AppScaffolding.LibationScaffolding.IsLinux)
{
var startInfo = new System.Diagnostics.ProcessStartInfo()
{
FileName = "/bin/xdg-open",
Arguments = path is null ? string.Empty : $"\"{path}\"",
UseShellExecute = false, //Import in Linux environments
CreateNoWindow = false,
RedirectStandardOutput = true,
RedirectStandardError = true
};
System.Diagnostics.Process.Start(startInfo);
return true;
}
//Don't know how to do this for mac yet
else return true;
}
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);

View File

@ -52,7 +52,7 @@ namespace LibationAvalonia.Dialogs
try
{
App.GoToFolder(dir.ShortPathName);
Go.To.Folder(dir.ShortPathName);
}
catch
{

View File

@ -45,7 +45,7 @@ namespace LibationAvalonia.Dialogs
public void OpenLogFolderButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
{
App.GoToFolder(((LongPath)Configuration.Instance.LibationFiles).ShortPathName);
Go.To.Folder(((LongPath)Configuration.Instance.LibationFiles).ShortPathName);
}
public async void EditFolderTemplateButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)

View File

@ -36,7 +36,7 @@ namespace LibationAvalonia.Views
// liberated: open explorer to file
var filePath = AudibleFileStorage.Audio.GetPath(libraryBook.Book.AudibleProductId);
if (!App.GoToFile(filePath?.ShortPathName))
if (!Go.To.File(filePath?.ShortPathName))
{
var suffix = string.IsNullOrWhiteSpace(filePath) ? "" : $":\r\n{filePath}";
await MessageBox.Show($"File not found" + suffix);