Added -dir option to DepotDownloader for specifying an alternate install directory.

pull/8/head
Scott Ehlert 15 years ago
parent 1c181a351b
commit 0fc89f465a

@ -13,23 +13,28 @@ namespace DepotDownloader
{ {
static class ContentDownloader static class ContentDownloader
{ {
const string DOWNLOAD_DIR = "depots"; const string DEFAULT_DIR = "depots";
static Steam3Session steam3; static Steam3Session steam3;
static bool CreateDirectories( int depotId, int depotVersion, out string downloadDir ) static bool CreateDirectories( int depotId, int depotVersion, ref string installDir )
{ {
downloadDir = null;
try try
{ {
Directory.CreateDirectory( DOWNLOAD_DIR ); if ( installDir == null || installDir.Equals( "" ) )
{
Directory.CreateDirectory( DEFAULT_DIR );
string depotPath = Path.Combine( DOWNLOAD_DIR, depotId.ToString() ); string depotPath = Path.Combine( DEFAULT_DIR, depotId.ToString() );
Directory.CreateDirectory( depotPath ); Directory.CreateDirectory( depotPath );
downloadDir = Path.Combine( depotPath, depotVersion.ToString() ); installDir = Path.Combine( depotPath, depotVersion.ToString() );
Directory.CreateDirectory( downloadDir ); Directory.CreateDirectory( installDir );
}
else
{
Directory.CreateDirectory( installDir );
}
} }
catch catch
{ {
@ -39,12 +44,11 @@ namespace DepotDownloader
return true; return true;
} }
public static void Download( int depotId, int depotVersion, int cellId, string username, string password, bool onlyManifest, string[] fileList ) public static void Download( int depotId, int depotVersion, int cellId, string username, string password, bool onlyManifest, string installDir, string[] fileList )
{ {
string downloadDir; if ( !CreateDirectories( depotId, depotVersion, ref installDir ) )
if ( !CreateDirectories( depotId, depotVersion, out downloadDir ) )
{ {
Console.WriteLine( "Error: Unable to create download directories!" ); Console.WriteLine( "Error: Unable to create install directories!" );
return; return;
} }
@ -67,8 +71,8 @@ namespace DepotDownloader
credentials = GetCredentials( ( uint )depotId, username, password ); credentials = GetCredentials( ( uint )depotId, username, password );
} }
string manifestFile = Path.Combine( downloadDir, "manifest.bin" ); string manifestFile = Path.Combine( installDir, "manifest.bin" );
string txtManifest = Path.Combine( downloadDir, "manifest.txt" ); string txtManifest = Path.Combine( installDir, "manifest.txt" );
ContentServerClient csClient = new ContentServerClient(); ContentServerClient csClient = new ContentServerClient();
@ -128,7 +132,7 @@ namespace DepotDownloader
{ {
var dirEntry = manifest.Nodes[ x ]; var dirEntry = manifest.Nodes[ x ];
string downloadPath = Path.Combine( downloadDir, dirEntry.FullName ); string downloadPath = Path.Combine( installDir, dirEntry.FullName );
if ( onlyManifest ) if ( onlyManifest )
{ {

@ -102,10 +102,11 @@ namespace DepotDownloader
string username = GetStringParameter( args, "-username" ); string username = GetStringParameter( args, "-username" );
string password = GetStringParameter( args, "-password" ); string password = GetStringParameter( args, "-password" );
string installDir = GetStringParameter( args, "-dir" );
if ( !bGameserver ) if ( !bGameserver )
{ {
ContentDownloader.Download( depotId, depotVersion, cellId, username, password, !bDebot, files ); ContentDownloader.Download( depotId, depotVersion, cellId, username, password, !bDebot, installDir, files );
} }
else else
{ {
@ -123,7 +124,7 @@ namespace DepotDownloader
string depotName = CDRManager.GetDepotName( currentDepotId ); string depotName = CDRManager.GetDepotName( currentDepotId );
Console.WriteLine( "Downloading \"{0}\" version {1} ...", depotName, depotVersion ); Console.WriteLine( "Downloading \"{0}\" version {1} ...", depotName, depotVersion );
ContentDownloader.Download( currentDepotId, depotVersion, cellId, username, password, false, files ); ContentDownloader.Download( currentDepotId, depotVersion, cellId, username, password, false, installDir, files );
} }
} }
} }
@ -176,6 +177,7 @@ namespace DepotDownloader
Console.WriteLine( "\t-cellid #\t\t\t- the CellID of the content server to download from." ); Console.WriteLine( "\t-cellid #\t\t\t- the CellID of the content server to download from." );
Console.WriteLine( "\t-username user\t\t\t- the username of the account to login to for restricted content." ); Console.WriteLine( "\t-username user\t\t\t- the username of the account to login to for restricted content." );
Console.WriteLine( "\t-password pass\t\t\t- the password of the account to login to for restricted content." ); Console.WriteLine( "\t-password pass\t\t\t- the password of the account to login to for restricted content." );
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.\n" ); 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.\n" );
} }
} }

Loading…
Cancel
Save