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