1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-24 02:49:54 +08:00

Use switch statement in AttemptHardLink()

This commit is contained in:
Bartłomiej Dach
2022-12-28 21:20:49 +01:00
Unverified
parent 2c346eae0d
commit cadd487c75
+9 -6
View File
@@ -56,14 +56,17 @@ namespace osu.Game.IO
public static bool AttemptHardLink(string testDestinationPath, string testSourcePath)
{
bool isHardLinkAvailable = false;
switch (RuntimeInfo.OS)
{
case RuntimeInfo.Platform.Windows:
return CreateHardLink(testDestinationPath, testSourcePath, IntPtr.Zero);
if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows)
isHardLinkAvailable = CreateHardLink(testDestinationPath, testSourcePath, IntPtr.Zero);
else if (RuntimeInfo.OS == RuntimeInfo.Platform.Linux)
isHardLinkAvailable = link(testSourcePath, testDestinationPath) == 0;
case RuntimeInfo.Platform.Linux:
return link(testSourcePath, testDestinationPath) == 0;
return isHardLinkAvailable;
default:
return false;
}
}
// For future use (to detect if a file is a hard link with other references existing on disk).