|
|
|
@ -73,13 +73,16 @@ namespace DepotDownloader
|
|
|
|
|
ContentServerClient csClient = new ContentServerClient();
|
|
|
|
|
|
|
|
|
|
csClient.Connect( contentServer );
|
|
|
|
|
csClient.EnterStorageMode( ( uint )cellId );
|
|
|
|
|
|
|
|
|
|
uint storageId = csClient.OpenStorage( ( uint )depotId, ( uint )depotVersion, credentials );
|
|
|
|
|
|
|
|
|
|
if ( storageId == uint.MaxValue )
|
|
|
|
|
ContentServerClient.StorageSession session = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
session = csClient.OpenStorage( ( uint )depotId, ( uint )depotVersion, ( uint )cellId );
|
|
|
|
|
}
|
|
|
|
|
catch ( Steam2Exception ex )
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine( "This depot requires valid user credentials and a license for this app" );
|
|
|
|
|
Console.WriteLine( "Unable to open storage: " + ex.Message );
|
|
|
|
|
|
|
|
|
|
if ( steam3 != null )
|
|
|
|
|
steam3.Disconnect();
|
|
|
|
@ -87,15 +90,19 @@ namespace DepotDownloader
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using ( session )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Console.Write( "Downloading depot manifest..." );
|
|
|
|
|
|
|
|
|
|
byte[] manifestData = csClient.DownloadManifest( storageId );
|
|
|
|
|
|
|
|
|
|
Manifest manifest = session.DownloadManifest();
|
|
|
|
|
byte[] manifestData = manifest.RawData;
|
|
|
|
|
|
|
|
|
|
File.WriteAllBytes( manifestFile, manifestData );
|
|
|
|
|
|
|
|
|
|
Console.WriteLine( " Done!" );
|
|
|
|
|
|
|
|
|
|
Manifest manifest = new Manifest( manifestData );
|
|
|
|
|
|
|
|
|
|
if ( onlyManifest )
|
|
|
|
|
File.Delete( txtManifest );
|
|
|
|
|
|
|
|
|
@ -115,9 +122,9 @@ namespace DepotDownloader
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( int x = 0 ; x < manifest.DirEntries.Count ; ++x )
|
|
|
|
|
for ( int x = 0 ; x < manifest.Nodes.Count ; ++x )
|
|
|
|
|
{
|
|
|
|
|
Manifest.DirectoryEntry dirEntry = manifest.DirEntries[ x ];
|
|
|
|
|
var dirEntry = manifest.Nodes[ x ];
|
|
|
|
|
|
|
|
|
|
string downloadPath = Path.Combine( downloadDir, dirEntry.FullName );
|
|
|
|
|
|
|
|
|
@ -177,17 +184,17 @@ namespace DepotDownloader
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float perc = ( ( float )x / ( float )manifest.DirEntries.Count ) * 100.0f;
|
|
|
|
|
float perc = ( ( float )x / ( float )manifest.Nodes.Count ) * 100.0f;
|
|
|
|
|
Console.WriteLine( " {0:0.00}%\t{1}", perc, dirEntry.FullName );
|
|
|
|
|
|
|
|
|
|
FileInfo fi = new FileInfo( downloadPath );
|
|
|
|
|
|
|
|
|
|
if ( fi.Exists && fi.Length == dirEntry.ItemSize )
|
|
|
|
|
if ( fi.Exists && fi.Length == dirEntry.SizeOrCount )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
ContentServerClient.File file = csClient.DownloadFile( storageId, dirEntry.FileID );
|
|
|
|
|
var file = session.DownloadFile( dirEntry, ContentServerClient.StorageSession.DownloadPriority.High );
|
|
|
|
|
|
|
|
|
|
if ( file.FileMode == 1 )
|
|
|
|
|
if ( file.Mode == ContentServerClient.StorageSession.File.FileMode.Compressed )
|
|
|
|
|
{
|
|
|
|
|
// file is compressed
|
|
|
|
|
using ( MemoryStream ms = new MemoryStream( file.Data ) )
|
|
|
|
@ -196,7 +203,7 @@ namespace DepotDownloader
|
|
|
|
|
// skip zlib header
|
|
|
|
|
ms.Seek( 2, SeekOrigin.Begin );
|
|
|
|
|
|
|
|
|
|
byte[] inflated = new byte[ dirEntry.ItemSize ];
|
|
|
|
|
byte[] inflated = new byte[ dirEntry.SizeOrCount ];
|
|
|
|
|
ds.Read( inflated, 0, inflated.Length );
|
|
|
|
|
|
|
|
|
|
file.Data = inflated;
|
|
|
|
@ -207,7 +214,7 @@ namespace DepotDownloader
|
|
|
|
|
Debug.Assert( false, string.Format(
|
|
|
|
|
"Got file with unexpected filemode!\n" +
|
|
|
|
|
"DepotID: {0}\nVersion: {1}\nFile: {2}\nMode: {3}\n",
|
|
|
|
|
depotId, depotVersion, dirEntry.FullName, file.FileMode
|
|
|
|
|
depotId, depotVersion, dirEntry.FullName, file.Mode
|
|
|
|
|
) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -216,9 +223,7 @@ namespace DepotDownloader
|
|
|
|
|
|
|
|
|
|
if ( onlyManifest )
|
|
|
|
|
File.WriteAllText( txtManifest, manifestBuilder.ToString() );
|
|
|
|
|
|
|
|
|
|
csClient.CloseStorage( storageId );
|
|
|
|
|
csClient.ExitStorageMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
csClient.Disconnect();
|
|
|
|
|
|
|
|
|
|