Skip to content

Commit 5301f93

Browse files
craftablescienceozxybox
authored andcommitted
feat: change archive excludes/includes to apply to contents of archives, not VPK files
1 parent f0f6677 commit 5301f93

File tree

2 files changed

+25
-33
lines changed

2 files changed

+25
-33
lines changed

src/create.cpp

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -67,36 +67,18 @@ auto createFromRoot( std::string_view root_, std::string_view indexLocation, boo
6767
auto pathRel{ std::filesystem::relative( path, root ).string() };
6868
sourcepp::string::normalizeSlashes( pathRel );
6969

70-
if ( path.ends_with( ".vpk" ) ) {
71-
static const std::regex numberedVpkRegex { R"(.*_[0-9][0-9][0-9]\.vpk)", std::regex::ECMAScript | std::regex::icase | std::regex::optimize };
72-
73-
if ( skipArchives || std::regex_match( pathRel, numberedVpkRegex ) ) {
74-
continue;
75-
}
76-
77-
if ( !archiveExclusionREs.empty() && matchPath( pathRel, archiveExclusionREs ) ) {
78-
continue;
79-
}
80-
81-
if ( !archiveInclusionREs.empty() && !matchPath( pathRel, archiveInclusionREs ) ) {
82-
continue;
83-
}
84-
70+
if ( ( !fileExclusionREs.empty() && matchPath( pathRel, fileExclusionREs ) ) || ( !fileInclusionREs.empty() && !matchPath( pathRel, fileInclusionREs ) ) ) {
71+
// File is either excluded or not included
72+
continue;
73+
}
8574

86-
if ( enterVPK( writer, path, pathRel, fileExclusionREs, fileInclusionREs, count ) ) {
75+
if ( !skipArchives && path.ends_with( ".vpk" ) ) {
76+
if ( enterVPK( writer, path, pathRel, archiveExclusionREs, archiveInclusionREs, count ) ) {
8777
Log_Info( "Processed VPK at `{}`", path );
8878
continue;
8979
}
9080

9181
Log_Warn( "Unable to open VPK at `{}`. Treating as a regular file...", path );
92-
} else {
93-
if ( !fileExclusionREs.empty() && matchPath( pathRel, fileExclusionREs ) ) {
94-
continue;
95-
}
96-
97-
if ( !fileInclusionREs.empty() && !matchPath( pathRel, fileInclusionREs ) ) {
98-
continue;
99-
}
10082
}
10183

10284
// open file
@@ -196,7 +178,7 @@ auto createFromSteamDepotConfigs( const std::string& configPath, const std::vect
196178
continue;
197179
}
198180

199-
const auto createFromSteamDepotConfig{ [ &configPath, &indexLocation, skipArchives, &fileExcludes, &contentRoot, &fileIncludes, &archiveExcludes, &archiveIncludes ]( const KV1Element& depotBuildConfig ) {
181+
const auto createFromSteamDepotConfig{ [ &configPath, &indexLocation, skipArchives, &fileExcludes, &fileIncludes, &archiveExcludes, &archiveIncludes, &contentRoot ]( const KV1Element& depotBuildConfig ) {
200182
std::vector<std::string> exclusionRegexes;
201183
exclusionRegexes.insert( exclusionRegexes.end(), fileExcludes.begin(), fileExcludes.end() );
202184
for ( int i = 0; i < depotBuildConfig.getChildCount( "FileExclusion" ); i++ ) {

src/main.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ auto main( int argc, char* argv[] ) -> int {
7575
params.add_parameter( fileIncludes, "--include" )
7676
.help( "RegExp pattern(s) to include files when creating the index. If not present, all files not matching an exclusion will be included.")
7777
.metavar( "included" );
78-
params.add_parameter( archiveExcludes, "--exclude-archives", "-E" )
79-
.help( "RegExp pattern(s) to exclude VPKs when creating the index. Ignored if `--steam-depot-config` is present." )
80-
.metavar( "excluded-archives" )
78+
params.add_parameter( archiveExcludes, "--archive-exclude", "-E" )
79+
.help( "RegExp pattern(s) to exclude files inside VPKs when creating the index." )
80+
.metavar( "archive-excluded" )
8181
.minargs( 1 );
82-
params.add_parameter( archiveIncludes, "--include-archives" )
83-
.help( "RegExp pattern(s) to include VPKs when creating the index. If not present, all VPKs not matching an exclusion will be included." )
84-
.metavar( "included-archives" );
82+
params.add_parameter( archiveIncludes, "--archive-include" )
83+
.help( "RegExp pattern(s) to include files inside VPKs when creating the index. If not present, all files inside VPKs not matching an exclusion will be included." )
84+
.metavar( "archive-included" );
8585
params.add_parameter( steamDepotConfig, "--steam-depot-config" )
8686
.help( "Use a Steam depot configuration file to include/exclude content. Pair this option with `--steam-depot-ids`." )
8787
.metavar( "steam-depot-config" )
@@ -142,6 +142,16 @@ auto main( int argc, char* argv[] ) -> int {
142142
fileExcludes.emplace_back( ".*\\.log" );
143143
fileExcludes.emplace_back( ".*verifier_index\\.rsv" );
144144

145+
// if we're reading the contents of archives, numbered VPKs should not be considered
146+
if (! skipArchives ) {
147+
fileExcludes.emplace_back( R"(.*_[0-9][0-9][0-9]\.vpk)" );
148+
} else {
149+
if (! archiveExcludes.empty() )
150+
Log_Warn( "The current action doesn't support `--archive-exclude`, it will be ignored." );
151+
if (! archiveIncludes.empty() )
152+
Log_Warn( "The current action doesn't support `--archive-include`, it will be ignored." );
153+
}
154+
145155
// create from a steam depot config
146156
if ( !steamDepotConfig.empty() || !steamDepotIDs.empty() ) {
147157
if ( steamDepotConfig.empty() && !steamDepotIDs.empty() ) {
@@ -166,9 +176,9 @@ auto main( int argc, char* argv[] ) -> int {
166176
if (! fileIncludes.empty() )
167177
Log_Warn( "The current action doesn't support `--include`, it will be ignored." );
168178
if (! archiveExcludes.empty() )
169-
Log_Warn( "The current action doesn't support `--exclude-archives`, it will be ignored." );
179+
Log_Warn( "The current action doesn't support `--archive-exclude`, it will be ignored." );
170180
if (! archiveIncludes.empty() )
171-
Log_Warn( "The current action doesn't support `--include-archives`, it will be ignored." );
181+
Log_Warn( "The current action doesn't support `--archive-include`, it will be ignored." );
172182
if (! steamDepotConfig.empty() )
173183
Log_Warn( "The current action doesn't support `--steam-depot-config`, it will be ignored." );
174184
if (! steamDepotIDs.empty() )

0 commit comments

Comments
 (0)