Exclude files listed in reslists/*/exclude.lst when using the -game parameter.

This functionality matches hldsupdatetool.
pull/8/head
Scott Ehlert 15 years ago
parent 16e33b2085
commit f11dd05096

@ -51,7 +51,60 @@ namespace DepotDownloader
return true;
}
public static void Download( int depotId, int depotVersion, int cellId, string username, string password, bool onlyManifest, string installDir, string[] fileList )
static string[] GetExcludeList( ContentServerClient.StorageSession session, Steam2Manifest manifest )
{
string[] excludeList = null;
for ( int x = 0 ; x < manifest.Nodes.Count ; ++x )
{
var dirEntry = manifest.Nodes[ x ];
if ( dirEntry.Name == "exclude.lst" &&
dirEntry.FullName.StartsWith( "reslists" + Path.DirectorySeparatorChar ) &&
( dirEntry.Attributes & Steam2Manifest.Node.Attribs.EncryptedFile ) == 0 )
{
string excludeFile = Encoding.UTF8.GetString( session.DownloadFile( dirEntry ) );
excludeList = excludeFile.Split( new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries );
break;
}
}
return excludeList;
}
static bool IsFileExcluded( string file, string[] excludeList )
{
if ( excludeList == null || file.Length < 1 )
return false;
foreach ( string e in excludeList )
{
int wildPos = e.IndexOf( "*" );
if ( wildPos == -1 )
{
if ( file.StartsWith( e ) )
return true;
continue;
}
if ( wildPos == 0 )
{
if ( e.Length == 1 || file.EndsWith( e.Substring( 1 ) ) )
return true;
continue;
}
string start = e.Substring( 0, wildPos );
string end = e.Substring( wildPos + 1, e.Length - wildPos - 1 );
if ( file.StartsWith( start ) && file.EndsWith( end ) )
return true;
}
return false;
}
public static void Download( int depotId, int depotVersion, int cellId, string username, string password, bool onlyManifest, bool gameServer, string installDir, string[] fileList )
{
if ( !CreateDirectories( depotId, depotVersion, ref installDir ) )
{
@ -134,6 +187,10 @@ namespace DepotDownloader
}
byte[] cryptKey = CDRManager.GetDepotEncryptionKey( depotId, depotVersion );
string[] excludeList = null;
if ( gameServer )
excludeList = GetExcludeList( session, manifest );
for ( int x = 0 ; x < manifest.Nodes.Count ; ++x )
{
@ -150,6 +207,9 @@ namespace DepotDownloader
continue;
}
if ( gameServer && IsFileExcluded( dirEntry.FullName, excludeList ) )
continue;
if ( fileList != null )
{
bool bMatched = false;

@ -106,7 +106,7 @@ namespace DepotDownloader
if ( !bGameserver )
{
ContentDownloader.Download( depotId, depotVersion, cellId, username, password, !bDebot, installDir, files );
ContentDownloader.Download( depotId, depotVersion, cellId, username, password, !bDebot, bGameserver, installDir, files );
}
else
{
@ -124,7 +124,7 @@ namespace DepotDownloader
string depotName = CDRManager.GetDepotName( currentDepotId );
Console.WriteLine( "Downloading \"{0}\" version {1} ...", depotName, depotVersion );
ContentDownloader.Download( currentDepotId, depotVersion, cellId, username, password, false, installDir, files );
ContentDownloader.Download( currentDepotId, depotVersion, cellId, username, password, false, bGameserver, installDir, files );
}
}
}

Loading…
Cancel
Save