win32/coil/Process.h
Go to the documentation of this file.
1 // -*- C++ -*-
20 #ifndef COIL_PROCESS_H
21 #define COIL_PROCESS_H
22 
23 #include <windows.h>
24 #include <tchar.h>
25 #include <string>
26 #include <coil/stringutil.h>
27 
28 namespace coil
29 {
30 
57  int launch_shell(std::string command);
58 
59  int daemon(int nochdir, int noclose);
60 
61 
62  class Popen
63  {
64  FILE* m_fd;
65  public:
66  Popen(std::string cmd, std::string mode)
67  {
68  m_fd = _popen(cmd.c_str(), mode.c_str());
69  }
70  virtual ~Popen()
71  {
72  if (m_fd != 0)
73  {
74  _pclose(m_fd);
75  }
76  }
77  bool isEof()
78  {
79  if (feof(m_fd)) { return true; }
80  return false;
81  }
82  std::string getline()
83  {
84  if (m_fd == 0) { return ""; }
85  if (feof(m_fd)) { return ""; }
86  char str[512];
87  fgets(str, 512, m_fd);
88  std::string line(str);
89  return line;
90  }
91  };
92 }; // namespace coil
93 
94 inline FILE* popen(const char* cmd, const char* mode)
95 {
96  return _popen(cmd, mode);
97 }
98 
99 inline void pclose(FILE* fd)
100 {
101  _pclose(fd);
102 }
103 
104 #endif // COIL_PROCESS_H
int launch_shell(std::string command)
Launching a process.
virtual ~Popen()
int daemon(int nochdir, int noclose)
list cmd
Definition: omniwxs.py:88
std::string getline()
FILE * popen(const char *cmd, const char *mode)
Popen(std::string cmd, std::string mode)
void pclose(FILE *fd)
Common Object Interface Layer.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:25:59