diff --git a/RomRepoMgr.Core/Filesystem/Vfs.cs b/RomRepoMgr.Core/Filesystem/Vfs.cs index 9c84cc1..b563739 100644 --- a/RomRepoMgr.Core/Filesystem/Vfs.cs +++ b/RomRepoMgr.Core/Filesystem/Vfs.cs @@ -5,7 +5,8 @@ namespace RomRepoMgr.Core.Filesystem { public class Vfs : IDisposable { - Fuse _fuse; + Fuse _fuse; + Winfsp _winfsp; public static bool IsAvailable => Winfsp.IsAvailable || Fuse.IsAvailable; @@ -13,13 +14,13 @@ namespace RomRepoMgr.Core.Filesystem public event EventHandler Umounted; - public void MountTo(string result) + public void MountTo(string mountPoint) { if(Fuse.IsAvailable) { _fuse = new Fuse { - MountPoint = result + MountPoint = mountPoint }; Task.Run(() => @@ -29,12 +30,29 @@ namespace RomRepoMgr.Core.Filesystem Umounted?.Invoke(this, System.EventArgs.Empty); }); } + else if(Winfsp.IsAvailable) + { + _winfsp = new Winfsp(); + bool ret = _winfsp.Mount(mountPoint); + + if(ret) + return; + + _winfsp = null; + Umounted?.Invoke(this, System.EventArgs.Empty); + } + else + Umounted?.Invoke(this, System.EventArgs.Empty); } public void Umount() { _fuse?.Umount(); _fuse = null; + _winfsp?.Umount(); + _winfsp = null; + + Umounted?.Invoke(this, System.EventArgs.Empty); } } } \ No newline at end of file diff --git a/RomRepoMgr.Core/Filesystem/Winfsp.cs b/RomRepoMgr.Core/Filesystem/Winfsp.cs index fb6db7e..abdd4f1 100644 --- a/RomRepoMgr.Core/Filesystem/Winfsp.cs +++ b/RomRepoMgr.Core/Filesystem/Winfsp.cs @@ -1,10 +1,13 @@ using System; using Fsp; +using Fsp.Interop; namespace RomRepoMgr.Core.Filesystem { public class Winfsp : FileSystemBase { + FileSystemHost _host; + public static bool IsAvailable { get @@ -24,5 +27,27 @@ namespace RomRepoMgr.Core.Filesystem } } } + + internal bool Mount(string mountPoint) + { + _host = new FileSystemHost(this); + int ret = _host.Mount(mountPoint); + + if(ret == STATUS_SUCCESS) + return true; + + _host = null; + + return false; + } + + internal void Umount() => _host?.Unmount(); + + public override int SetVolumeLabel(string VolumeLabel, out VolumeInfo VolumeInfo) + { + VolumeInfo = default; + + return STATUS_MEDIA_WRITE_PROTECTED; + } } } \ No newline at end of file