From 6edab0c55e111f7a535cf85697b55fa88ea08b60 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 25 Aug 2024 23:54:12 +0300 Subject: [PATCH] Use ReadAllLinesAsync and async main --- DepotDownloader/Program.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index ae44b765..52213262 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -13,12 +13,7 @@ namespace DepotDownloader { class Program { - static int Main(string[] args) - => MainAsync(args).GetAwaiter().GetResult(); - - internal static readonly char[] newLineCharacters = ['\n', '\r']; - - static async Task MainAsync(string[] args) + static async Task Main(string[] args) { if (args.Length == 0) { @@ -71,15 +66,19 @@ namespace DepotDownloader try { - var fileListData = await File.ReadAllTextAsync(fileList); - var files = fileListData.Split(newLineCharacters, StringSplitOptions.RemoveEmptyEntries); - ContentDownloader.Config.UsingFileList = true; ContentDownloader.Config.FilesToDownload = new HashSet(StringComparer.OrdinalIgnoreCase); ContentDownloader.Config.FilesToDownloadRegex = []; + var files = await File.ReadAllLinesAsync(fileList); + foreach (var fileEntry in files) { + if (string.IsNullOrWhiteSpace(fileEntry)) + { + continue; + } + if (fileEntry.StartsWith(RegexPrefix)) { var rgx = new Regex(fileEntry[RegexPrefix.Length..], RegexOptions.Compiled | RegexOptions.IgnoreCase);