From 46006b4a44e52c914433331388f10b3721f17215 Mon Sep 17 00:00:00 2001 From: amaitland Date: Fri, 1 May 2020 11:03:30 +1000 Subject: [PATCH] Core - Add DependencyChecker.AssertPathAbsolute Issue #3102 --- CefSharp/DependencyChecker.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CefSharp/DependencyChecker.cs b/CefSharp/DependencyChecker.cs index 4c19e80eb1..6c9cd2375c 100644 --- a/CefSharp/DependencyChecker.cs +++ b/CefSharp/DependencyChecker.cs @@ -224,5 +224,24 @@ public static void AssertAllDependenciesPresent(string locale = null, string loc throw new Exception(builder.ToString()); } } + + /// + /// Throw exception if the path provided is non-asbolute + /// CEF now explicitly requires absolute paths + /// https://bitbucket.org/chromiumembedded/cef/issues/2916/not-persisting-in-local-stoage-when-using + /// + /// path + /// string to appear at the start of + /// the exception, e.g. CefSettings.BrowserSubProcessPath + public static void AssertPathAbsolute(string path, string settingName) + { + const string directorySeperator = "\\"; + + //IsPathRooted will return true for paths that start with a single slash, e.g. \programfiles + if (!Path.IsPathRooted(path) || Path.GetPathRoot(path).Equals(directorySeperator, StringComparison.Ordinal)) + { + throw new Exception(settingName + " now requires an absolute path, the path provided is non-absolute: " + path); + } + } } }