mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
C#: Some re-factoring of NugetPackages and logic for file downloading.
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
using Semmle.Util;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Net.Http;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Xml;
|
||||
using Semmle.Util;
|
||||
|
||||
namespace Semmle.Autobuild.Shared
|
||||
{
|
||||
@@ -283,17 +281,8 @@ namespace Semmle.Autobuild.Shared
|
||||
|
||||
public string EnvironmentExpandEnvironmentVariables(string s) => Environment.ExpandEnvironmentVariables(s);
|
||||
|
||||
private static async Task DownloadFileAsync(string address, string filename)
|
||||
{
|
||||
using var httpClient = new HttpClient();
|
||||
using var request = new HttpRequestMessage(HttpMethod.Get, address);
|
||||
using var contentStream = await (await httpClient.SendAsync(request)).Content.ReadAsStreamAsync();
|
||||
using var stream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None, 4096, true);
|
||||
await contentStream.CopyToAsync(stream);
|
||||
}
|
||||
|
||||
public void DownloadFile(string address, string fileName) =>
|
||||
DownloadFileAsync(address, fileName).Wait();
|
||||
FileUtils.DownloadFile(address, fileName);
|
||||
|
||||
public IDiagnosticsWriter CreateDiagnosticsWriter(string filename) => new DiagnosticsStream(filename);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user