mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Rename and xmldoc hard link creation method
This commit is contained in:
parent
cadd487c75
commit
04d4b4a6ce
@ -65,7 +65,7 @@ namespace osu.Game.Database
|
||||
if (data is FileStream fs && preferHardLinks)
|
||||
{
|
||||
// attempt to do a fast hard link rather than copy.
|
||||
if (HardLinkHelper.AttemptHardLink(Storage.GetFullPath(file.GetStoragePath(), true), fs.Name))
|
||||
if (HardLinkHelper.TryCreateHardLink(Storage.GetFullPath(file.GetStoragePath(), true), fs.Name))
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace osu.Game.IO
|
||||
File.WriteAllText(testSourcePath, string.Empty);
|
||||
|
||||
// Test availability by creating an arbitrary hard link between the source and destination paths.
|
||||
return AttemptHardLink(testDestinationPath, testSourcePath);
|
||||
return TryCreateHardLink(testDestinationPath, testSourcePath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -54,15 +54,23 @@ namespace osu.Game.IO
|
||||
}
|
||||
}
|
||||
|
||||
public static bool AttemptHardLink(string testDestinationPath, string testSourcePath)
|
||||
/// <summary>
|
||||
/// Attempts to create a hard link from <paramref name="sourcePath"/> to <paramref name="destinationPath"/>,
|
||||
/// using platform-specific native methods.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Hard links are only available on Windows and Linux.
|
||||
/// </remarks>
|
||||
/// <returns>Whether the hard link was successfully created.</returns>
|
||||
public static bool TryCreateHardLink(string destinationPath, string sourcePath)
|
||||
{
|
||||
switch (RuntimeInfo.OS)
|
||||
{
|
||||
case RuntimeInfo.Platform.Windows:
|
||||
return CreateHardLink(testDestinationPath, testSourcePath, IntPtr.Zero);
|
||||
return CreateHardLink(destinationPath, sourcePath, IntPtr.Zero);
|
||||
|
||||
case RuntimeInfo.Platform.Linux:
|
||||
return link(testSourcePath, testDestinationPath) == 0;
|
||||
return link(sourcePath, destinationPath) == 0;
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user