Add config tmp directory
This commit is contained in:
parent
ec465d2dc7
commit
411dcf5fda
|
@ -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:
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#include <stdexcept>
|
||||
|
||||
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<char*>(unique_directory_.data())) == nullptr) {
|
||||
throw std::logic_error("make unique directory failed");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue