Skip to content

Commit

Permalink
chore: add proper hresult for hard link errors
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-is-cute committed Aug 24, 2024
1 parent c164d8b commit e645703
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Util/FileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
}

0 comments on commit e645703

Please sign in to comment.