From 1dae16ac57583c201fad547b90a6d77c6fc7cba4 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 12 Sep 2019 09:41:37 -0700 Subject: [PATCH] Added some extra platform errors --- BeefLibs/corlib/src/System/IO/Shell.bf | 21 +++++++++++++++++++-- BeefLibs/corlib/src/System/Platform.bf | 7 +++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/BeefLibs/corlib/src/System/IO/Shell.bf b/BeefLibs/corlib/src/System/IO/Shell.bf index adba06c0..1c230313 100644 --- a/BeefLibs/corlib/src/System/IO/Shell.bf +++ b/BeefLibs/corlib/src/System/IO/Shell.bf @@ -72,7 +72,22 @@ namespace System.IO } } - public static Result 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 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)); diff --git a/BeefLibs/corlib/src/System/Platform.bf b/BeefLibs/corlib/src/System/Platform.bf index 6836db17..54ebdd16 100644 --- a/BeefLibs/corlib/src/System/Platform.bf +++ b/BeefLibs/corlib/src/System/Platform.bf @@ -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,