Skip to content

Commit

Permalink
fix: No files passing the exclusion/inclusion check
Browse files Browse the repository at this point in the history
  • Loading branch information
ENDERZOMBI102 committed Jul 30, 2024
1 parent c3b1b18 commit 0e09c1a
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ auto createFromRoot( std::string_view root_, std::string_view indexLocation, boo
return 1;
}

std::vector<std::regex> archiveExclusionREs = buildRegexCollection(archiveExcludes, "archive exclusion");
std::vector<std::regex> archiveInclusionREs = buildRegexCollection(archiveIncludes, "archive inclusion");
std::vector<std::regex> fileExclusionREs = buildRegexCollection(fileExcludes, "file exclusion");
std::vector<std::regex> fileInclusionREs = buildRegexCollection(fileIncludes, "file inclusion");
std::vector<std::regex> archiveExclusionREs = buildRegexCollection( archiveExcludes, "archive exclusion" );
std::vector<std::regex> archiveInclusionREs = buildRegexCollection( archiveIncludes, "archive inclusion" );
std::vector<std::regex> fileExclusionREs = buildRegexCollection( fileExcludes, "file exclusion" );
std::vector<std::regex> fileInclusionREs = buildRegexCollection( fileIncludes, "file inclusion" );

// We always pass some regexes in from main.cpp, so not need for an ugly check if we actually
// compiled anything - fileExclusionREs will always be non-empty.
Expand Down Expand Up @@ -74,12 +74,12 @@ auto createFromRoot( std::string_view root_, std::string_view indexLocation, boo
continue;
}

if ( !archiveExclusionREs.empty() && matchPath( pathRel, archiveExclusionREs ) ) {
continue;
}

if ( !archiveExclusionREs.empty() && !matchPath( pathRel, archiveInclusionREs ) ) {
continue;
// check if the path should be excluded, and if it is, also check if it has been forcibly included,
// this makes sure we don't hung up and include no files
if ( matchPath( pathRel, archiveExclusionREs ) ) {
if ( archiveInclusionREs.empty() || !matchPath( pathRel, archiveInclusionREs ) ) {
continue;
}
}

if ( enterVPK( writer, path, pathRel, fileExclusionREs, fileInclusionREs, count ) ) {
Expand All @@ -89,12 +89,10 @@ auto createFromRoot( std::string_view root_, std::string_view indexLocation, boo

Log_Warn( "Unable to open VPK at `{}`. Treating as a regular file...", path );
} else {
if ( !fileInclusionREs.empty() && matchPath( pathRel, fileExclusionREs ) ) {
continue;
}

if ( !fileExclusionREs.empty() && !matchPath( pathRel, fileInclusionREs ) ) {
continue;
if ( matchPath( pathRel, fileExclusionREs ) ) {
if ( fileInclusionREs.empty() || !matchPath( pathRel, fileInclusionREs ) ) {
continue;
}
}
}

Expand Down Expand Up @@ -302,7 +300,7 @@ static auto enterVPK( std::ofstream& writer, std::string_view vpkPath, std::stri
}

static auto buildRegexCollection( const std::vector<std::string>& regexStrings, std::string_view collectionType ) -> std::vector<std::regex> {
std::vector<std::regex> collection {};
std::vector<std::regex> collection{};

if ( !regexStrings.empty() ) {
Log_Info( "Compiling {} regexes...", collectionType );
Expand Down

0 comments on commit 0e09c1a

Please sign in to comment.