diff --git a/include/cppshell/shell.hpp b/include/cppshell/shell.hpp index 0ebdb17..a6ec195 100644 --- a/include/cppshell/shell.hpp +++ b/include/cppshell/shell.hpp @@ -10,7 +10,7 @@ namespace cppshell { class Shell { public: - Shell(const std::string& shell = "bash"); + Shell(const std::string& shell = "bash", const std::string& path_to_tmp_directory = "/tmp"); void Execute(const std::string& command); @@ -21,11 +21,9 @@ class Shell { } private: - void ExecuteImpl(const std::string& command, bool need_ignore_sigpipe); - void Destroy(); - void MakeUniqueDirectory(); + void MakeUniqueDirectory(const std::string& path_to_tmp_directory); void MakeFifoFile(); private: diff --git a/src/shell.cpp b/src/shell.cpp index 8fddfc3..5c531aa 100644 --- a/src/shell.cpp +++ b/src/shell.cpp @@ -15,8 +15,8 @@ #include namespace cppshell { -Shell::Shell(const std::string& shell) { - MakeUniqueDirectory(); +Shell::Shell(const std::string& shell, const std::string& path_to_tmp_directory) { + MakeUniqueDirectory(path_to_tmp_directory); MakeFifoFile(); int fds_exit_codes[2]; @@ -41,8 +41,8 @@ Shell::Shell(const std::string& shell) { } } -void Shell::MakeUniqueDirectory() { - unique_directory_ = "/tmp/cppshell_XXXXXX"; +void Shell::MakeUniqueDirectory(const std::string& path_to_tmp_directory) { + unique_directory_ = path_to_tmp_directory + "/cppshell_XXXXXX"; if (mkdtemp(const_cast(unique_directory_.data())) == nullptr) { throw std::logic_error("make unique directory failed"); }