Skip to content

Commit

Permalink
Open file/folder is now cross platform
Browse files Browse the repository at this point in the history
  • Loading branch information
rmcrackan committed Aug 2, 2022
1 parent 0df4dfd commit a47866b
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Source/AppScaffolding/AppScaffolding.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
2 changes: 1 addition & 1 deletion Source/AudibleUtilities/AudibleUtilities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AudibleApi" Version="4.6.1.1" />
<PackageReference Include="AudibleApi" Version="4.6.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Source/DataLayer/DataLayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion Source/FileManager/FileManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
27 changes: 0 additions & 27 deletions Source/LibationAvalonia/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,6 @@ public class App : Application
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private async void GoToLogs_Tapped(object sender, Avalonia.Interactivity.RoutedE

try
{
App.GoToFolder(dir.ShortPathName);
Go.To.Folder(dir.ShortPathName);
}
catch
{
Expand Down
2 changes: 1 addition & 1 deletion Source/LibationAvalonia/Dialogs/SettingsDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async void SaveButton_Clicked(object sender, Avalonia.Interactivity.Route

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async void ProductsDisplay_LiberateClicked(object sender, LibraryBook lib
// 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);
Expand Down

0 comments on commit a47866b

Please sign in to comment.