From fe0d934bfc656aeb70df5d1510d83b697fe0bb76 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Sat, 13 Apr 2019 21:20:25 +0100 Subject: [PATCH] FileDetails SHA1 --- Facepunch.Steamworks.Test/Client/AppTest.cs | 3 +++ Facepunch.Steamworks/Redux/Apps.cs | 18 +++++++++--------- .../Redux/Structs/FileDetails.cs | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Facepunch.Steamworks.Test/Client/AppTest.cs b/Facepunch.Steamworks.Test/Client/AppTest.cs index 4959c21..9423cd9 100644 --- a/Facepunch.Steamworks.Test/Client/AppTest.cs +++ b/Facepunch.Steamworks.Test/Client/AppTest.cs @@ -66,7 +66,10 @@ namespace Steamworks { 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}" ); } } diff --git a/Facepunch.Steamworks/Redux/Apps.cs b/Facepunch.Steamworks/Redux/Apps.cs index b5c59e7..270a0e9 100644 --- a/Facepunch.Steamworks/Redux/Apps.cs +++ b/Facepunch.Steamworks/Redux/Apps.cs @@ -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 @@ namespace Steamworks /// public static async Task 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" ); + { + 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" ) ) ) }; } diff --git a/Facepunch.Steamworks/Redux/Structs/FileDetails.cs b/Facepunch.Steamworks/Redux/Structs/FileDetails.cs index b08eb76..a2d7f5f 100644 --- a/Facepunch.Steamworks/Redux/Structs/FileDetails.cs +++ b/Facepunch.Steamworks/Redux/Structs/FileDetails.cs @@ -8,8 +8,9 @@ namespace Steamworks { public struct FileDetails { + public bool Found; public ulong SizeInBytes; public string Sha1; - public ulong BytesTotal; + public uint Flags; } } \ No newline at end of file