mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 11:14:45 +00:00
Detect if FUSE is available before allowing to use it for VFS.
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Mono.Fuse.NETStandard;
|
||||
using Mono.Unix.Native;
|
||||
using RomRepoMgr.Database;
|
||||
@@ -40,6 +41,46 @@ namespace RomRepoMgr.Core.Filesystem
|
||||
Name = "romrepombgrfs";
|
||||
}
|
||||
|
||||
public static bool IsAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
IntPtr fuse = dlopen("libfuse.so.2", 2);
|
||||
|
||||
if(fuse == IntPtr.Zero)
|
||||
return false;
|
||||
|
||||
dlclose(fuse);
|
||||
|
||||
IntPtr helper = dlopen("libMonoFuseHelper.so", 2);
|
||||
|
||||
if(helper == IntPtr.Zero)
|
||||
{
|
||||
helper = dlopen("./libMonoFuseHelper.so", 2);
|
||||
|
||||
if(helper == IntPtr.Zero)
|
||||
return false;
|
||||
}
|
||||
|
||||
dlclose(helper);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libdl")]
|
||||
static extern IntPtr dlopen(string filename, int flags);
|
||||
|
||||
[DllImport("libdl")]
|
||||
static extern int dlclose(IntPtr handle);
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if(!disposing)
|
||||
|
||||
@@ -101,6 +101,8 @@ namespace RomRepoMgr.ViewModels
|
||||
set => this.RaiseAndSetIfChanged(ref _selectedRomSet, value);
|
||||
}
|
||||
|
||||
public bool IsVfsAvailable => Fuse.IsAvailable;
|
||||
|
||||
internal async void ExecuteSettingsCommand()
|
||||
{
|
||||
var dialog = new SettingsDialog();
|
||||
@@ -288,9 +290,6 @@ namespace RomRepoMgr.ViewModels
|
||||
|
||||
async void ExecuteMountCommand()
|
||||
{
|
||||
// TODO: Detect if Windows or *NIX
|
||||
// TODO: Detect if libraries are available
|
||||
|
||||
var dlgOpen = new OpenFolderDialog
|
||||
{
|
||||
Title = "Select mount point..."
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<Separator />
|
||||
<MenuItem Header="E_xit" IsVisible="{Binding !NativeMenuSupported}" Command="{Binding ExitCommand}" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="File_system">
|
||||
<MenuItem Header="File_system" IsEnabled="{Binding IsVfsAvailable}">
|
||||
<MenuItem Header="_Mount" Command="{Binding MountCommand}" /> <Separator />
|
||||
</MenuItem>
|
||||
<MenuItem Header="_ROMs">
|
||||
|
||||
Reference in New Issue
Block a user