Fixed DepotDownloader to make use of the latest ContentServerClient changes.

--HG--
extra : convert_revision : svn%3A946a0da7-ebce-4904-9acb-2f1e67aed693%40238
pull/8/head
Ryan Stecker 15 years ago
parent 391dbd9b8a
commit 3a8fbb363c

@ -73,13 +73,16 @@ namespace DepotDownloader
ContentServerClient csClient = new ContentServerClient(); ContentServerClient csClient = new ContentServerClient();
csClient.Connect( contentServer ); 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 ) if ( steam3 != null )
steam3.Disconnect(); steam3.Disconnect();
@ -87,15 +90,19 @@ namespace DepotDownloader
return; return;
} }
using ( session )
{
Console.Write( "Downloading depot manifest..." ); Console.Write( "Downloading depot manifest..." );
byte[] manifestData = csClient.DownloadManifest( storageId );
Manifest manifest = session.DownloadManifest();
byte[] manifestData = manifest.RawData;
File.WriteAllBytes( manifestFile, manifestData ); File.WriteAllBytes( manifestFile, manifestData );
Console.WriteLine( " Done!" ); Console.WriteLine( " Done!" );
Manifest manifest = new Manifest( manifestData );
if ( onlyManifest ) if ( onlyManifest )
File.Delete( txtManifest ); 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 ); string downloadPath = Path.Combine( downloadDir, dirEntry.FullName );
@ -177,17 +184,17 @@ namespace DepotDownloader
continue; 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 ); Console.WriteLine( " {0:0.00}%\t{1}", perc, dirEntry.FullName );
FileInfo fi = new FileInfo( downloadPath ); FileInfo fi = new FileInfo( downloadPath );
if ( fi.Exists && fi.Length == dirEntry.ItemSize ) if ( fi.Exists && fi.Length == dirEntry.SizeOrCount )
continue; 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 // file is compressed
using ( MemoryStream ms = new MemoryStream( file.Data ) ) using ( MemoryStream ms = new MemoryStream( file.Data ) )
@ -196,7 +203,7 @@ namespace DepotDownloader
// skip zlib header // skip zlib header
ms.Seek( 2, SeekOrigin.Begin ); ms.Seek( 2, SeekOrigin.Begin );
byte[] inflated = new byte[ dirEntry.ItemSize ]; byte[] inflated = new byte[ dirEntry.SizeOrCount ];
ds.Read( inflated, 0, inflated.Length ); ds.Read( inflated, 0, inflated.Length );
file.Data = inflated; file.Data = inflated;
@ -207,7 +214,7 @@ namespace DepotDownloader
Debug.Assert( false, string.Format( Debug.Assert( false, string.Format(
"Got file with unexpected filemode!\n" + "Got file with unexpected filemode!\n" +
"DepotID: {0}\nVersion: {1}\nFile: {2}\nMode: {3}\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 ) if ( onlyManifest )
File.WriteAllText( txtManifest, manifestBuilder.ToString() ); File.WriteAllText( txtManifest, manifestBuilder.ToString() );
}
csClient.CloseStorage( storageId );
csClient.ExitStorageMode();
csClient.Disconnect(); csClient.Disconnect();

Loading…
Cancel
Save