Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qt/utils: support full path in get_dir_entries #14528

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions rpcs3/rpcs3qt/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,22 +753,14 @@ bool main_window::InstallPackages(QStringList file_paths, bool from_boot)
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);
const QStringList dir_file_paths = gui::utils::get_dir_entries(dir, {}, true);

if (dir_file_infos.empty())
if (dir_file_paths.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);
}

Expand Down Expand Up @@ -848,7 +840,7 @@ bool main_window::InstallPackages(QStringList file_paths, bool from_boot)
const auto install_filetype = [&installed_rap_and_edat_count, &file_paths](const std::string extension)
{
const QString pattern = QString(".*\\.%1").arg(QString::fromStdString(extension));
for (const auto& file : file_paths.filter(QRegularExpression(pattern, QRegularExpression::PatternOption::CaseInsensitiveOption)))
for (const QString& file : file_paths.filter(QRegularExpression(pattern, QRegularExpression::PatternOption::CaseInsensitiveOption)))
{
const QFileInfo file_info(file);
const std::string filename = sstr(file_info.fileName());
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/rpcs3qt/qt_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ namespace gui
return icon;
}

QStringList get_dir_entries(const QDir& dir, const QStringList& name_filters)
QStringList get_dir_entries(const QDir& dir, const QStringList& name_filters, bool full_path)
{
QFileInfoList entries = dir.entryInfoList(name_filters, QDir::Files);
QStringList res;
for (const QFileInfo &entry : entries)
for (const QFileInfo& entry : entries)
{
res.append(entry.baseName());
res.append(full_path ? entry.absoluteFilePath() : entry.baseName());
}
return res;
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/rpcs3qt/qt_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace gui
QIcon get_colorized_icon(const QIcon& old_icon, const QColor& old_color, const std::map<QIcon::Mode, QColor>& new_colors, bool use_special_masks = false, bool colorize_all = false);

// Returns a list of all base names of files in dir whose complete file names contain one of the given name_filters
QStringList get_dir_entries(const QDir& dir, const QStringList& name_filters);
QStringList get_dir_entries(const QDir& dir, const QStringList& name_filters, bool full_path = false);

// Returns the color specified by its color_role for the QLabels with object_name
QColor get_label_color(const QString& object_name, QPalette::ColorRole color_role = QPalette::WindowText);
Expand Down