From e645703f8c7d13528106760f3af6bd8ec3415cc4 Mon Sep 17 00:00:00 2001 From: Anna Date: Fri, 23 Aug 2024 21:17:20 -0400 Subject: [PATCH] chore: add proper hresult for hard link errors --- Util/FileHelper.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Util/FileHelper.cs b/Util/FileHelper.cs index 6cf270c..1bef210 100644 --- a/Util/FileHelper.cs +++ b/Util/FileHelper.cs @@ -115,10 +115,15 @@ internal static void CreateHardLink(string source, string destination) { } var error = Marshal.GetLastWin32Error(); + var hresult = unchecked((int) (0x80070000 | (error & 0xFFFF))); if (error == 1) { - throw new InvalidOperationException($"The file system does not support hard links ({source} -> {destination})"); + throw new InvalidOperationException($"The file system does not support hard links ({source} -> {destination})") { + HResult = hresult, + }; } - throw new IOException($"Failed to create hard link (0x{error:X}): {source} -> {destination}"); + throw new IOException($"Failed to create hard link (0x{error:X}): {source} -> {destination}") { + HResult = hresult, + }; } }