From cadd487c75c0876ec15388f55577cbac97d2df2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 28 Dec 2022 21:20:49 +0100 Subject: [PATCH] Use switch statement in `AttemptHardLink()` --- osu.Game/IO/HardLinkHelper.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/osu.Game/IO/HardLinkHelper.cs b/osu.Game/IO/HardLinkHelper.cs index c8fc6d9f49..d6ca11a68f 100644 --- a/osu.Game/IO/HardLinkHelper.cs +++ b/osu.Game/IO/HardLinkHelper.cs @@ -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).