From 5a780c4bc03ebc2d2c06fbf8840789699b5ceca9 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 16 Apr 2019 21:57:55 +0100 Subject: [PATCH] GetFileDetailsAsync tweak --- Facepunch.Steamworks.Test/AppTest.cs | 7 +++---- Facepunch.Steamworks/SteamApps.cs | 9 +++------ Facepunch.Steamworks/Structs/FileDetails.cs | 1 - 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Facepunch.Steamworks.Test/AppTest.cs b/Facepunch.Steamworks.Test/AppTest.cs index a1eb515..6348e8a 100644 --- a/Facepunch.Steamworks.Test/AppTest.cs +++ b/Facepunch.Steamworks.Test/AppTest.cs @@ -89,10 +89,9 @@ namespace Steamworks { var fileinfo = await SteamApps.GetFileDetailsAsync( "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}" ); + Console.WriteLine( $"fileinfo.SizeInBytes: {fileinfo?.SizeInBytes}" ); + Console.WriteLine( $"fileinfo.Sha1: {fileinfo?.Sha1}" ); + Console.WriteLine( $"fileinfo.Flags: {fileinfo?.Flags}" ); } [TestMethod] diff --git a/Facepunch.Steamworks/SteamApps.cs b/Facepunch.Steamworks/SteamApps.cs index aef7fb9..c24869c 100644 --- a/Facepunch.Steamworks/SteamApps.cs +++ b/Facepunch.Steamworks/SteamApps.cs @@ -235,18 +235,15 @@ namespace Steamworks /// Asynchronously retrieves metadata details about a specific file in the depot manifest. /// Currently provides: /// - public static async Task GetFileDetailsAsync( string filename ) + public static async Task GetFileDetailsAsync( string filename ) { var r = await Internal.GetFileDetails( filename ); - if ( !r.HasValue ) - { - throw new System.Exception( "Something went wrong" ); - } + if ( !r.HasValue || r.Value.Result != Result.OK ) + return null; return new FileDetails { - Found = r.Value.Result == 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/Structs/FileDetails.cs b/Facepunch.Steamworks/Structs/FileDetails.cs index 1849e48..50bd8f7 100644 --- a/Facepunch.Steamworks/Structs/FileDetails.cs +++ b/Facepunch.Steamworks/Structs/FileDetails.cs @@ -8,7 +8,6 @@ namespace Steamworks.Data { public struct FileDetails { - public bool Found; public ulong SizeInBytes; public string Sha1; public uint Flags;