libfilezilla
process.hpp
Go to the documentation of this file.
1 #ifndef LIBFILEZILLA_PROCESS_HEADER
2 #define LIBFILEZILLA_PROCESS_HEADER
3 
4 #include "libfilezilla.hpp"
5 
10 #include <vector>
11 
12 #ifdef FZ_WINDOWS
13 #include "private/windows.hpp"
14 #endif
15 
16 namespace fz {
17 
25 class FZ_PUBLIC_SYMBOL process final
26 {
27 public:
28  process();
29  ~process();
30 
31  process(process const&) = delete;
32  process& operator=(process const&) = delete;
33 
45  bool spawn(native_string const& cmd, std::vector<native_string> const& args = std::vector<native_string>(), bool redirect_io = true);
46 
47  bool spawn(std::vector<native_string> const& command_with_args, bool redirect_io = true);
48 
49 #ifndef FZ_WINDOWS
50 
56  bool spawn(native_string const& cmd, std::vector<native_string> const& args, std::vector<int> const& extra_fds, bool redirect_io = true);
57 #endif
58 
65  void kill();
66 
75  int read(char* buffer, unsigned int len);
76 
84  bool write(char const* buffer, unsigned int len);
85 
86  inline bool write(std::string_view const& s) {
87  return write(s.data(), static_cast<unsigned int>(s.size()));
88  }
89 
90 #if FZ_WINDOWS
91 
94  HANDLE handle() const;
95 #endif
96 
97 private:
98  class impl;
99  impl* impl_;
100 };
101 
102 
111 bool FZ_PUBLIC_SYMBOL spawn_detached_process(std::vector<native_string> const& cmd_with_args);
112 
113 }
114 
115 #endif
fz::buffer
The buffer class is a simple buffer where data can be appended at the end and consumed at the front....
Definition: buffer.hpp:25
fz::spawn_detached_process
bool spawn_detached_process(std::vector< native_string > const &cmd_with_args)
Starts a detached process.
fz::socket_event_flag::write
@ write
fz::socket_event_flag::read
@ read
fz::native_string
std::wstring native_string
A string in the system's native character type and encoding. Note: This typedef changes depending on...
Definition: string.hpp:33
fz::process
The process class manages an asynchronous process with redirected IO.
Definition: process.hpp:25
libfilezilla.hpp
Sets some global macros and further includes string.hpp.
fz
The namespace used by libfilezilla.
Definition: apply.hpp:17