mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 11:14:45 +00:00
Update winfsp-netcore to .NET 5.
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text;
|
||||
using Mono.Fuse.NETStandard;
|
||||
using Mono.Unix.Native;
|
||||
@@ -12,6 +13,8 @@ using RomRepoMgr.Database.Models;
|
||||
namespace RomRepoMgr.Core.Filesystem
|
||||
{
|
||||
// TODO: Last handle goes negative
|
||||
[SupportedOSPlatform("Linux")]
|
||||
[SupportedOSPlatform("macOS")]
|
||||
public sealed class Fuse : FileSystem
|
||||
{
|
||||
readonly ConcurrentDictionary<long, List<DirectoryEntry>> _directoryCache;
|
||||
|
||||
@@ -41,7 +41,9 @@ namespace RomRepoMgr.Core.Filesystem
|
||||
_lastHandle = 0;
|
||||
}
|
||||
|
||||
public static bool IsAvailable => Winfsp.IsAvailable || Fuse.IsAvailable;
|
||||
public static bool IsAvailable => OperatingSystem.IsMacOS() ||
|
||||
OperatingSystem.IsLinux() ? Fuse.IsAvailable
|
||||
: OperatingSystem.IsWindows() && Winfsp.IsAvailable;
|
||||
|
||||
public void Dispose() => Umount();
|
||||
|
||||
@@ -49,7 +51,7 @@ namespace RomRepoMgr.Core.Filesystem
|
||||
|
||||
public void MountTo(string mountPoint)
|
||||
{
|
||||
if(Fuse.IsAvailable)
|
||||
if((OperatingSystem.IsMacOS() || OperatingSystem.IsLinux()) && Fuse.IsAvailable)
|
||||
{
|
||||
_fuse = new Fuse(this)
|
||||
{
|
||||
@@ -63,7 +65,7 @@ namespace RomRepoMgr.Core.Filesystem
|
||||
CleanUp();
|
||||
});
|
||||
}
|
||||
else if(Winfsp.IsAvailable)
|
||||
else if(OperatingSystem.IsWindows() && Winfsp.IsAvailable)
|
||||
{
|
||||
_winfsp = new Winfsp(this);
|
||||
bool ret = _winfsp.Mount(mountPoint);
|
||||
@@ -80,10 +82,17 @@ namespace RomRepoMgr.Core.Filesystem
|
||||
|
||||
public void Umount()
|
||||
{
|
||||
_fuse?.Umount();
|
||||
_fuse = null;
|
||||
_winfsp?.Umount();
|
||||
_winfsp = null;
|
||||
if(OperatingSystem.IsMacOS() || OperatingSystem.IsLinux())
|
||||
{
|
||||
_fuse?.Umount();
|
||||
_fuse = null;
|
||||
}
|
||||
|
||||
if(OperatingSystem.IsWindows())
|
||||
{
|
||||
_winfsp?.Umount();
|
||||
_winfsp = null;
|
||||
}
|
||||
|
||||
CleanUp();
|
||||
}
|
||||
@@ -112,7 +121,7 @@ namespace RomRepoMgr.Core.Filesystem
|
||||
}
|
||||
|
||||
internal string[] SplitPath(string path) =>
|
||||
path.Split(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "\\" : "/",
|
||||
path.Split(OperatingSystem.IsWindows() ? "\\" : "/",
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
void FillRootDirectoryCache()
|
||||
@@ -125,7 +134,7 @@ namespace RomRepoMgr.Core.Filesystem
|
||||
{
|
||||
string name;
|
||||
|
||||
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
if(OperatingSystem.IsWindows())
|
||||
{
|
||||
name = set.Name.Replace('/', '∕').Replace('<', '\uFF1C').Replace('>', '\uFF1E').
|
||||
Replace(':', '\uFF1A').Replace('"', '\u2033').Replace('\\', '\').Replace('|', '|').
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Security.AccessControl;
|
||||
using Fsp;
|
||||
using Fsp.Interop;
|
||||
@@ -12,6 +13,7 @@ using FileInfo = Fsp.Interop.FileInfo;
|
||||
|
||||
namespace RomRepoMgr.Core.Filesystem
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class Winfsp : FileSystemBase
|
||||
{
|
||||
readonly Vfs _vfs;
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Aaru.CommonTypes.Interop
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
if(!OperatingSystem.IsWindows())
|
||||
return Environment.UserName == "root";
|
||||
|
||||
bool isAdmin;
|
||||
|
||||
@@ -116,11 +116,11 @@ namespace RomRepoMgr.Settings
|
||||
#if !NETSTANDARD2_0
|
||||
|
||||
// In case of Windows settings will be saved in the registry: HKLM/SOFTWARE/Claunia.com/RomRepoMgr
|
||||
case PlatformID.Win32NT when RuntimeInformation.IsOSPlatform(OSPlatform.Windows):
|
||||
case PlatformID.Win32S when RuntimeInformation.IsOSPlatform(OSPlatform.Windows):
|
||||
case PlatformID.Win32Windows when RuntimeInformation.IsOSPlatform(OSPlatform.Windows):
|
||||
case PlatformID.WinCE when RuntimeInformation.IsOSPlatform(OSPlatform.Windows):
|
||||
case PlatformID.WindowsPhone when RuntimeInformation.IsOSPlatform(OSPlatform.Windows):
|
||||
case PlatformID.Win32NT when OperatingSystem.IsWindows():
|
||||
case PlatformID.Win32S when OperatingSystem.IsWindows():
|
||||
case PlatformID.Win32Windows when OperatingSystem.IsWindows():
|
||||
case PlatformID.WinCE when OperatingSystem.IsWindows():
|
||||
case PlatformID.WindowsPhone when OperatingSystem.IsWindows():
|
||||
{
|
||||
RegistryKey parentKey = Registry.CurrentUser.OpenSubKey("SOFTWARE")?.OpenSubKey("Claunia.com");
|
||||
|
||||
@@ -235,11 +235,11 @@ namespace RomRepoMgr.Settings
|
||||
#if !NETSTANDARD2_0
|
||||
|
||||
// In case of Windows settings will be saved in the registry: HKLM/SOFTWARE/Claunia.com/RomRepoMgr
|
||||
case PlatformID.Win32NT when RuntimeInformation.IsOSPlatform(OSPlatform.Windows):
|
||||
case PlatformID.Win32S when RuntimeInformation.IsOSPlatform(OSPlatform.Windows):
|
||||
case PlatformID.Win32Windows when RuntimeInformation.IsOSPlatform(OSPlatform.Windows):
|
||||
case PlatformID.WinCE when RuntimeInformation.IsOSPlatform(OSPlatform.Windows):
|
||||
case PlatformID.WindowsPhone when RuntimeInformation.IsOSPlatform(OSPlatform.Windows):
|
||||
case PlatformID.Win32NT when OperatingSystem.IsWindows():
|
||||
case PlatformID.Win32S when OperatingSystem.IsWindows():
|
||||
case PlatformID.Win32Windows when OperatingSystem.IsWindows():
|
||||
case PlatformID.WinCE when OperatingSystem.IsWindows():
|
||||
case PlatformID.WindowsPhone when OperatingSystem.IsWindows():
|
||||
{
|
||||
RegistryKey parentKey = Registry.CurrentUser.OpenSubKey("SOFTWARE", true)?.
|
||||
CreateSubKey("Claunia.com");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<RootNamespace>winfsp_netcore</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user