1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2024-11-23 17:42:46 +01:00
TweetDuck/lib/TweetLib.Browser.CEF/Utils/CefUtils.cs

42 lines
1009 B
C#

using System.IO;
using System.Text.RegularExpressions;
using TweetLib.Utils.Collections;
namespace TweetLib.Browser.CEF.Utils {
public static class CefUtils {
public static string GetCacheFolder(string storagePath) {
return Path.Combine(storagePath, "Cache");
}
public static CommandLineArgs ParseCommandLineArguments(string? argumentString) {
CommandLineArgs args = new CommandLineArgs();
if (string.IsNullOrWhiteSpace(argumentString)) {
return args;
}
foreach (Match match in Regex.Matches(argumentString, @"([^=\s]+(?:=(?:\S*""[^""]*?""\S*|\S*))?)")) {
string matchValue = match.Value;
int indexEquals = matchValue.IndexOf('=');
string key, value;
if (indexEquals == -1) {
key = matchValue.TrimStart('-');
value = "1";
}
else {
key = matchValue[..indexEquals].TrimStart('-');
value = matchValue[(indexEquals + 1)..].Trim('"');
}
if (key.Length != 0) {
args.SetValue(key, value);
}
}
return args;
}
}
}