1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-21 21:33:54 +00:00

Use custom type for deleter.

This commit is contained in:
Thomas Harte 2024-10-15 21:49:42 -04:00
parent 131ab00304
commit f3e18da416

View File

@ -444,7 +444,12 @@ std::string final_path_component(const std::string &path) {
Executes @c command and returns its STDOUT.
*/
std::string system_get(const char *command) {
std::unique_ptr<FILE, decltype((pclose))> pipe(popen(command, "r"), pclose);
struct pcloser {
void operator()(FILE *file) {
pclose(dir);
}
};
std::unique_ptr<FILE, pcloser> pipe(popen(command, "r"));
if(!pipe) return "";
std::string result;