Skip to content

Commit 49212ee

Browse files
committed
And another stupid fix..
1 parent 01ba83c commit 49212ee

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/wadinfo.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@
22
#include <scrypto.hpp>
33

44
ff::WADInfo ff::get_info_from_wad(const std::string& wad_path) {
5-
const auto recv = [](const std::string&& cmd) -> std::string {
6-
std::array<char, 128> buffer{};
7-
std::string result{};
8-
std::unique_ptr<FILE, decltype(&pclose)> pipe{popen(cmd.c_str(), "r"), pclose};
9-
if (!pipe) {
10-
throw std::runtime_error{"popen() failed!"};
11-
}
12-
while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe.get()) != nullptr) {
13-
result += buffer.data();
14-
}
15-
return result;
16-
};
5+
const auto recv = [](const std::string& cmd) -> std::string {
6+
std::array<char, 256> buffer{};
7+
std::string result;
8+
9+
FILE* raw_pipe = popen(cmd.c_str(), "r");
10+
if (!raw_pipe) {
11+
throw std::runtime_error{"popen() failed"};
12+
}
13+
14+
std::unique_ptr<FILE, decltype(&pclose)> pipe(raw_pipe, pclose);
15+
16+
while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe.get()) != nullptr) {
17+
result.append(buffer.data());
18+
}
19+
20+
return result;
21+
};
1722

1823
const auto extract_value = [](const std::string& output, const std::string& name) -> std::string {
1924
std::stringstream ss{output};

0 commit comments

Comments
 (0)