@@ -73,7 +73,7 @@ QString find_steam_datadir()
7373void find_installdirs_in_vdf (
7474 const QString& log_tag,
7575 const QString& vdf_path,
76- const QString& entry_pattern ,
76+ const std::vector< QString>& entry_patterns ,
7777 std::vector<QString>& installdirs)
7878{
7979 QFile vdf (vdf_path);
@@ -82,15 +82,21 @@ void find_installdirs_in_vdf(
8282
8383 Log::info (log_tag, LOGMSG (" Found `%1`" ).arg (vdf_path));
8484
85- const QRegularExpression entry_regex (entry_pattern);
85+ std::vector<QRegularExpression> entry_regexes;
86+ entry_regexes.reserve (entry_patterns.size ());
87+ for (const QString& pattern : entry_patterns)
88+ entry_regexes.emplace_back (pattern);
8689
8790 QTextStream stream (&vdf);
8891 while (!stream.atEnd ()) {
8992 const QString line = stream.readLine ();
90- const auto match = entry_regex.match (line);
91- if (match.hasMatch ()) {
92- QString path = match.captured (1 ) % QLatin1String (" /steamapps/" );
93- installdirs.emplace_back (std::move (path));
93+ for (const QRegularExpression& entry_regex : entry_regexes) {
94+ const auto match = entry_regex.match (line);
95+ if (match.hasMatch ()) {
96+ QString path = match.captured (1 ) % QLatin1String (" /steamapps/" );
97+ installdirs.emplace_back (std::move (path));
98+ break ;
99+ }
94100 }
95101 }
96102}
@@ -102,12 +108,17 @@ std::vector<QString> find_steam_installdirs(const QString& log_tag, const QStrin
102108 installdirs.emplace_back (steam_datadir + QLatin1String (" steamapps/" ));
103109
104110 const QString config_path = steam_datadir + QLatin1String (" config/config.vdf" );
105- const QString config_pattern = QStringLiteral (R""( "BaseInstallFolder_\d+"\s+"([^"]+)")"" );
111+ const std::vector<QString> config_pattern {
112+ QStringLiteral (R""( "BaseInstallFolder_\d+"\s+"([^"]+)")"" ),
113+ };
106114 find_installdirs_in_vdf (log_tag, config_path, config_pattern, installdirs);
107115
108116 const QString folderlist_path = installdirs.front () + QLatin1String (" libraryfolders.vdf" );
109- const QString folderlist_pattern = QStringLiteral (R""( "[1-7]"\s+"([^"]+)")"" );
110- find_installdirs_in_vdf (log_tag, folderlist_path, folderlist_pattern, installdirs);
117+ const std::vector<QString> folderlist_patterns {
118+ QStringLiteral (R""( "[1-7]"\s+"([^"]+)")"" ),
119+ QStringLiteral (R""( "path"\s+"([^"]+)")"" ),
120+ };
121+ find_installdirs_in_vdf (log_tag, folderlist_path, folderlist_patterns, installdirs);
111122
112123 VEC_REMOVE_DUPLICATES (installdirs);
113124 VEC_REMOVE_IF (installdirs, [](const QString& path) { return !QFileInfo::exists (path); });
0 commit comments