From 8aa8798459398e44f16bc69815e49c88378c3980 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Thu, 30 Jun 2011 01:18:40 -0500 Subject: [PATCH] Added -app switch to download all depots associated with an app id. --- DepotDownloader/CDRManager.cs | 37 +++++++++++++++++++++++++++++++++++ DepotDownloader/Program.cs | 34 ++++++++++++++++++++++---------- 2 files changed, 61 insertions(+), 10 deletions(-) diff --git a/DepotDownloader/CDRManager.cs b/DepotDownloader/CDRManager.cs index e4809e7a..8e731c5b 100644 --- a/DepotDownloader/CDRManager.cs +++ b/DepotDownloader/CDRManager.cs @@ -54,6 +54,9 @@ namespace DepotDownloader [BlobField( FieldKey = CDRAppFilesystemFields.eFieldMountName )] public string Name { get; set; } + + [BlobField( FieldKey = CDRAppFilesystemFields.eFieldPlatform )] + public string Platform { get; set; } } static class CDRManager @@ -164,6 +167,40 @@ namespace DepotDownloader return null; } + public static List GetDepotIDsForApp( int appId, bool allPlatforms ) + { + List depotIDs = new List(); + + App appInfoBlob = GetAppBlob( appId ); + + if ( appInfoBlob == null ) + { + return null; + } + + PlatformID platform = Environment.OSVersion.Platform; + string platformStr = ""; + + if ( platform == PlatformID.Win32NT ) + platformStr = "windows"; + else if ( platform == PlatformID.MacOSX ) + platformStr = "macos"; + + foreach ( var blobField in appInfoBlob.FileSystems ) + { + string depotPlatform = blobField.Platform; + + if ( depotPlatform == null || + depotPlatform.Contains( platformStr ) || + allPlatforms ) + { + depotIDs.Add( blobField.AppID ); + } + } + + return depotIDs; + } + public static List GetDepotIDsForGameserver( string gameName, bool allPlatforms ) { List appIDs = new List(); diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index 1d1942c5..3c05cad0 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -25,29 +25,36 @@ namespace DepotDownloader bool bDebot = true; bool bGameserver = true; + bool bApp = true; int depotId = -1; string gameName = GetStringParameter( args, "-game" ); + if ( gameName == null ) { - depotId = GetIntParameter( args, "-depot" ); + depotId = GetIntParameter( args, "-app" ); bGameserver = false; if ( depotId == -1 ) { - depotId = GetIntParameter( args, "-manifest" ); - bDebot = false; - + depotId = GetIntParameter( args, "-depot" ); + bApp = false; if ( depotId == -1 ) { - Console.WriteLine( "Error: -game, -depot or -manifest not specified!" ); - return; + depotId = GetIntParameter( args, "-manifest" ); + bDebot = false; + + if ( depotId == -1 ) + { + Console.WriteLine( "Error: -game, -app, -depot or -manifest not specified!" ); + return; + } } } } int depotVersion = GetIntParameter( args, "-version" ); - if ( !bGameserver && depotVersion == -1 ) + if ( !bGameserver && !bApp && depotVersion == -1 ) { int latestVer = CDRManager.GetLatestDepotVersion( depotId ); @@ -106,13 +113,18 @@ namespace DepotDownloader bool bNoExclude = HasParameter( args, "-no-exclude" ); bool bAllPlatforms = HasParameter( args, "-all-platforms" ); - if ( !bGameserver ) + if ( !bGameserver && !bApp ) { ContentDownloader.Download( depotId, depotVersion, cellId, username, password, !bDebot, false, false, installDir, files ); } else { - List depotIDs = CDRManager.GetDepotIDsForGameserver( gameName, bAllPlatforms ); + List depotIDs; + + if ( bGameserver ) + depotIDs = CDRManager.GetDepotIDsForGameserver( gameName, bAllPlatforms ); + else + depotIDs = CDRManager.GetDepotIDsForApp( depotId, bAllPlatforms ); foreach ( int currentDepotId in depotIDs ) { @@ -176,6 +188,8 @@ namespace DepotDownloader Console.WriteLine( "\t OR" ); Console.WriteLine( "\t-manifest #\t\t\t- downloads a human readable manifest for the depot." ); Console.WriteLine( "\t OR" ); + Console.WriteLine( "\t-app #\t\t\t\t- the AppID to download." ); + Console.WriteLine( "\t OR" ); Console.WriteLine( "\t-game #\t\t\t\t- the HLDSUpdateTool game server to download." ); Console.WriteLine( "\t-version [# or \"latest\"]\t- the version of the depot to download.\n" ); @@ -186,7 +200,7 @@ namespace DepotDownloader Console.WriteLine( "\t-dir installdir\t\t\t- the directory in which to place downloaded files." ); Console.WriteLine( "\t-filelist filename.txt\t\t- a list of files to download (from the manifest). Can optionally use regex to download only certain files." ); Console.WriteLine( "\t-no-exclude\t\t\t- don't exclude any files when downloading depots with the -game parameter." ); - Console.WriteLine( "\t-all-platforms\t\t\t- downloads all platform-specific depots when -game is used.\n" ); + Console.WriteLine( "\t-all-platforms\t\t\t- downloads all platform-specific depots when -game or -app is used.\n" ); } } }