Commit 28be289bc7656a4181b650b2ebffa2955ce4b900

Authored by Jordi Inglada
1 parent d4d2d23f
Exists in master

Remove the temporary file

Showing 1 changed file with 2 additions and 0 deletions   Show diff stats
include/cbutils.h
... ... @@ -43,6 +43,7 @@ std::vector<std::string> split(const std::string& str,
43 43 } //end ns string
44 44 // ----------------- System calls ----------------------------------------------
45 45 namespace system{
  46 +// Runs the command sending it to the OS and returns a string wit its output
46 47 std::string call(const std::string& command)
47 48 {
48 49 std::string tmp_filename{std::tmpnam(nullptr)};
... ... @@ -50,6 +51,7 @@ std::string call(const std::string& command)
50 51 std::system(command_redirect.str().c_str());
51 52 std::stringstream command_output;
52 53 command_output << std::ifstream(tmp_filename).rdbuf();
  54 + std::remove(tmp_filename.c_str());
53 55 return command_output.str();
54 56 }
55 57 } //end ns system
... ...