mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:03:13 +08:00
Check for hard link support in first run overlay
This commit is contained in:
parent
902dff15e3
commit
d8de99bbe4
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework;
|
||||
@ -54,6 +55,26 @@ namespace osu.Game.Database
|
||||
|
||||
public void UpdateStorage(string stablePath) => cachedStorage = new StableStorage(stablePath, gameHost as DesktopGameHost);
|
||||
|
||||
public bool CheckHardLinkAvailability()
|
||||
{
|
||||
if (RuntimeInfo.OS != RuntimeInfo.Platform.Windows)
|
||||
return false;
|
||||
|
||||
var stableStorage = GetCurrentStableStorage();
|
||||
|
||||
if (stableStorage == null || gameHost is not DesktopGameHost desktopGameHost)
|
||||
return false;
|
||||
|
||||
const string test_filename = "_hard_link_test";
|
||||
|
||||
desktopGameHost.Storage.Delete(test_filename);
|
||||
|
||||
string testExistingPath = stableStorage.GetFullPath(stableStorage.GetFiles(string.Empty).First());
|
||||
string testDestinationPath = desktopGameHost.Storage.GetFullPath(test_filename);
|
||||
|
||||
return RealmFileStore.CreateHardLink(testDestinationPath, testExistingPath, IntPtr.Zero);
|
||||
}
|
||||
|
||||
public virtual async Task<int> GetImportCount(StableContent content, CancellationToken cancellationToken)
|
||||
{
|
||||
var stableStorage = GetCurrentStableStorage();
|
||||
|
@ -94,7 +94,7 @@ namespace osu.Game.Database
|
||||
}
|
||||
|
||||
[DllImport("Kernel32.dll", CharSet = CharSet.Unicode)]
|
||||
private static extern bool CreateHardLink(
|
||||
public static extern bool CreateHardLink(
|
||||
string lpFileName,
|
||||
string lpExistingFileName,
|
||||
IntPtr lpSecurityAttributes
|
||||
|
@ -14,6 +14,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@ -105,6 +106,9 @@ namespace osu.Game.Overlays.FirstRunSetup
|
||||
toggleInteraction(true);
|
||||
stableLocatorTextBox.Current.Value = storage.GetFullPath(string.Empty);
|
||||
importButton.Enabled.Value = true;
|
||||
|
||||
bool available = legacyImportManager.CheckHardLinkAvailability();
|
||||
Logger.Log($"Hard link support is {available}");
|
||||
}
|
||||
|
||||
private void runImport()
|
||||
|
Loading…
Reference in New Issue
Block a user