Allow to umount VFS.

This commit is contained in:
2020-09-01 11:54:16 +01:00
parent b1fcf40945
commit b1dd940d00
8 changed files with 723 additions and 939 deletions

View File

@@ -1,7 +1,40 @@
using System;
using System.Threading.Tasks;
namespace RomRepoMgr.Core.Filesystem
{
public class Vfs
public class Vfs : IDisposable
{
Fuse _fuse;
public static bool IsAvailable => Winfsp.IsAvailable || Fuse.IsAvailable;
public void Dispose() => _fuse?.Dispose();
public event EventHandler<System.EventArgs> Umounted;
public void MountTo(string result)
{
if(Fuse.IsAvailable)
{
_fuse = new Fuse
{
MountPoint = result
};
Task.Run(() =>
{
_fuse.Start();
Umounted?.Invoke(this, System.EventArgs.Empty);
});
}
}
public void Umount()
{
_fuse?.Umount();
_fuse = null;
}
}
}