1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Added some extra platform errors

This commit is contained in:
Brian Fiete 2019-09-12 09:41:37 -07:00
parent 84f03abcc7
commit 1dae16ac57
2 changed files with 24 additions and 4 deletions

View file

@ -72,7 +72,22 @@ namespace System.IO
}
}
public static Result<void> CreateShortcut(StringView linkPath, StringView targetPath, StringView arguments, StringView workingDirectory, StringView description)
public enum ShellError
{
case AccessDenied;
case UnknownError;
public this(Windows.COM_IUnknown.HResult result)
{
switch (result)
{
case .E_ACCESSDENIED: this = .AccessDenied;
default: this = .UnknownError;
}
}
}
public static Result<void, ShellError> CreateShortcut(StringView linkPath, StringView targetPath, StringView arguments, StringView workingDirectory, StringView description)
{
COM_IShellLink* shellLink = null;
COM_IPersistFile* persistFile = null;
@ -88,7 +103,9 @@ namespace System.IO
mixin TryHR(Windows.COM_IUnknown.HResult result)
{
if (result != .OK)
return .Err;
{
return .Err(ShellError(result));
}
}
TryHR!(Windows.COM_IUnknown.CoCreateInstance(ref COM_IShellLink.sCLSID, null, .INPROC_SERVER, ref COM_IShellLink.sIID, (void**)&shellLink));

View file

@ -30,7 +30,8 @@ namespace System
AccessError,
PartialData,
TempFileError,
Timeout
Timeout,
NotEmpty
};
public struct BfpCritSect {}
@ -242,7 +243,8 @@ namespace System
ShareError = (int)Result.ShareError,
AccessError = (int)Result.AccessError,
PartialData = (int)Result.PartialData,
InsufficientBuffer = (int)Result.InsufficientBuffer
InsufficientBuffer = (int)Result.InsufficientBuffer,
NotEmpty = (int)Result.NotEmpty
};
[StdCall, CLink]
@ -397,6 +399,7 @@ namespace System
Home,
System,
Desktop,
Desktop_Common,
AppData_Local,
AppData_LocalLow,
AppData_Roaming,