Skip to content

Commit

Permalink
Suppress old cppcheck error
Browse files Browse the repository at this point in the history
  • Loading branch information
eschan145 committed Jan 8, 2025
1 parent eaba6e5 commit 28dd82a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
42 changes: 18 additions & 24 deletions src/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,32 +449,26 @@ DK_API const char* get_executables_in_folder(const char* folder_path) {
result.clear();

bool found_dir = false;

auto directory_it = std::filesystem::directory_iterator(folder_path);
auto dir_entry = std::find_if(
std::filesystem::begin(directory_it),
std::filesystem::end(directory_it),
[](const auto& entry) {
return entry.is_directory();
}
);

if (dir_entry != std::filesystem::end(directory_it)) {
auto subfiles_it = std::filesystem::directory_iterator(
dir_entry->path()
);
auto exe_file = std::find_if(
std::filesystem::begin(subfiles_it),
std::filesystem::end(subfiles_it),
[](const auto& sub_entry) {
return sub_entry.is_regular_file() &&
sub_entry.path().extension() == ".exe";
bool found_subfile = false;

for (const auto& entry :
std::filesystem::directory_iterator(folder_path)) {
// cppcheck-suppress useStlAlgorithm
if (entry.is_directory()) {
// If it's a directory, iterate over its subfiles
for (const auto& sub_entry :
std::filesystem::directory_iterator(entry.path())) {
if (sub_entry.is_regular_file() &&
sub_entry.path().extension() == ".exe") {
result += sub_entry.path().filename().string() + "\n";
found_subfile = true;
}
}
);

if (exe_file != std::filesystem::end(subfiles_it)) {
result += exe_file->path().filename().string() + "\n";
found_dir = true;
if (found_subfile)
found_dir = true;

break;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ Compile with g++ -shared -o api.dll api.cpp -Ofast -fPIC -shared
#include <vector>
#include <string>
#include <thread>
#include <algorithm>
#include <filesystem>
#include <sstream>

Expand Down

0 comments on commit 28dd82a

Please sign in to comment.