CLI - install multiple pkgs from folder (#14516)

This commit is contained in:
nkarl7 2023-08-20 17:51:24 +02:00 committed by GitHub
parent eb978a74f2
commit 78f2d44a0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -743,11 +743,37 @@ bool main_window::InstallPackages(QStringList file_paths, bool from_boot)
m_gui_settings->SetValue(gui::fd_install_pkg, file_info.path()); m_gui_settings->SetValue(gui::fd_install_pkg, file_info.path());
} }
if (file_paths.count() == 1 && file_paths.front().endsWith(".pkg", Qt::CaseInsensitive)) if (file_paths.count() == 1)
{ {
const QString file_path = file_paths.front(); const QString file_path = file_paths.front();
const QFileInfo file_info(file_path); const QFileInfo file_info(file_path);
if (file_info.isDir())
{
gui_log.notice("PKG: Trying to install packages from dir: '%s'", file_path);
const QDir dir(file_path);
const auto dir_file_infos = dir.entryInfoList(QDir::Files);
if (dir_file_infos.empty())
{
gui_log.notice("PKG: Could not find any files in dir: '%s'", file_path);
return true;
}
const auto dir_file_infos_count = dir_file_infos.count();
QList<QString> dir_file_paths(dir_file_infos_count);
for (int i = 0; i < dir_file_infos_count; i++)
{
dir_file_paths[i] = dir_file_infos[i].absoluteFilePath();
}
return InstallPackages(dir_file_paths, from_boot);
}
if (file_info.suffix().compare("pkg", Qt::CaseInsensitive) == 0)
{
compat::package_info info = game_compatibility::GetPkgInfo(file_path, m_game_list_frame ? m_game_list_frame->GetGameCompatibility() : nullptr); compat::package_info info = game_compatibility::GetPkgInfo(file_path, m_game_list_frame ? m_game_list_frame->GetGameCompatibility() : nullptr);
if (!info.is_valid) if (!info.is_valid)
@ -814,6 +840,7 @@ bool main_window::InstallPackages(QStringList file_paths, bool from_boot)
return true; return true;
} }
} }
}
// Install rap files if available // Install rap files if available
int installed_rap_and_edat_count = 0; int installed_rap_and_edat_count = 0;