Skip to content

Commit

Permalink
Merge pull request #4 from neon-nyan/pre-v0.0.1.0
Browse files Browse the repository at this point in the history
Pre v0.0.1.0 Improvements and Changes
  • Loading branch information
neon-nyan committed Oct 4, 2021
2 parents 3cca311 + 6306a63 commit dce68e3
Show file tree
Hide file tree
Showing 19 changed files with 933 additions and 269 deletions.
49 changes: 49 additions & 0 deletions BenchmarkLab/DownloadTool.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

namespace BenchmarkLab
{
public class DownloadTool
{
long bufflength = 262144;
HttpClient httpClient = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip });
Stream localStream;
Stream remoteStream;

public async Task<bool> Dunlud(string inp, string outp)
{
long ExistingLength = 0;
int byteSize;
localStream = new FileStream(outp, FileMode.Create, FileAccess.Write);

var request = new HttpRequestMessage { RequestUri = new Uri(inp) };
request.Headers.Range = new RangeHeaderValue(ExistingLength, null);

byte[] buffer = new byte[bufflength];

using (var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead))
{
Console.WriteLine($"{response.Content.Headers.ContentLength ?? 0}");
using (remoteStream = await response.Content.ReadAsStreamAsync())
{
while ((byteSize = await remoteStream.ReadAsync(buffer, 0, buffer.Length)) > 0)
{
await localStream.WriteAsync(buffer, 0, byteSize);
}
}
}

localStream.Dispose();
remoteStream.Dispose();

return true;
}
}
}
10 changes: 10 additions & 0 deletions BenchmarkLab/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using BenchmarkDotNet.Order;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Force.Crc32;

namespace BenchmarkLab
Expand All @@ -24,6 +26,13 @@ static void Main(string[] args)
Console.WriteLine(new Tool().Digits_FindCountWithPrec(12345678.87654));
*/

DownloadTool tool = new();
Task a = tool.Dunlud(
@"https://hk-bigfile-os-mihayo.akamaized.net/com.miHoYo.bh3oversea/StreamingAsb/5_1_0/android/HD/asb/Blocks_5_1.xmf",
@"C:\Users\neon-nyan\AppData\LocalLow\miHoYo\Honkai Impact 3\test.xmf");

Console.ReadLine();
/*
CRCTest a = new CRCTest();
byte[] data = File.ReadAllBytes(@"C:\Users\neon-nyan\Downloads\yoimiya_ayaka.png");
FileStream stream = new FileStream(@"C:\Users\neon-nyan\Downloads\yoimiya_ayaka.png", FileMode.Open, FileAccess.Read);
Expand All @@ -36,6 +45,7 @@ static void Main(string[] args)
Console.WriteLine(hash);
BenchmarkRunner.Run<CRCTest>();
*/
}
}

Expand Down
2 changes: 2 additions & 0 deletions Hi3HelperGUI/Classes/Data/Tools/ConverterTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class ConverterTool
(value & 0x000000FFU) << 24 | (value & 0x0000FF00U) << 8 |
(value & 0x00FF0000U) >> 8 | (value & 0xFF000000U) >> 24;

public static double GetPercentageNumber(double cur, double max, int round = 2) => Math.Round((100 * cur) / max, round);

public static ushort ToUInt16Big(ushort value) => (ushort)((value & 0xFFU) << 8 | (value & 0xFF00U) >> 8);

public static string BytesToMD5(byte[] stream) => BytesToHex(MD5.Create().ComputeHash(stream));
Expand Down
Loading

0 comments on commit dce68e3

Please sign in to comment.