FileDetails SHA1

This commit is contained in:
Garry Newman 2019-04-13 21:20:25 +01:00
parent d9da40c0e8
commit fe0d934bfc
3 changed files with 14 additions and 10 deletions

View File

@ -66,7 +66,10 @@ public async Task GetFileDetails()
{
var fileinfo = await Apps.GetFileDetails( "hl2.exe" );
Console.WriteLine( $"fileinfo.Found: {fileinfo.Found}" );
Console.WriteLine( $"fileinfo.SizeInBytes: {fileinfo.SizeInBytes}" );
Console.WriteLine( $"fileinfo.Sha1: {fileinfo.Sha1}" );
Console.WriteLine( $"fileinfo.Flags: {fileinfo.Flags}" );
}
}

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@ -211,20 +212,19 @@ public static DownloadProgress DlcDownloadProgress( AppId appid )
/// </summary>
public static async Task<FileDetails> GetFileDetails( string filename )
{
var call = steamapps.GetFileDetails( filename );
var r = await steamapps.GetFileDetails( filename );
while ( !call.IsComplete() )
{
await Task.Delay( 1 );
}
var r = call.GetResult();
if ( !r.HasValue )
{
throw new System.Exception( "Something went wrong" );
}
return new FileDetails
{
SizeInBytes = r.Value.FileSize
Found = r.Value.Result == SteamNative.Result.OK,
SizeInBytes = r.Value.FileSize,
Flags = r.Value.Flags,
Sha1 = string.Join( "", r.Value.FileSHA.Select( x => x.ToString( "x" ) ) )
};
}

View File

@ -8,8 +8,9 @@ namespace Steamworks
{
public struct FileDetails
{
public bool Found;
public ulong SizeInBytes;
public string Sha1;
public ulong BytesTotal;
public uint Flags;
}
}