feat: add file_stream and subprocess_windows

This commit is contained in:
CJ van den Berg 2024-06-07 22:09:46 +02:00
parent 0baeda5d16
commit 895d3dfb9e
11 changed files with 600 additions and 14 deletions

View file

@ -0,0 +1,26 @@
#pragma once
#include <stdint.h> // NOLINT
#if defined(_WIN32)
// NOLINTBEGIN(modernize-use-trailing-return-type)
#ifdef __cplusplus
extern "C" {
#endif
struct thespian_file_stream_handle;
struct thespian_file_stream_handle *thespian_file_stream_create(const char *tag,
void *handle);
int thespian_file_stream_start_read(struct thespian_file_stream_handle *);
int thespian_file_stream_start_write(struct thespian_file_stream_handle *,
const char *, size_t);
int thespian_file_stream_cancel(struct thespian_file_stream_handle *);
void thespian_file_stream_destroy(struct thespian_file_stream_handle *);
#ifdef __cplusplus
}
#endif
// NOLINTEND(modernize-use-trailing-return-type)
#endif

View file

@ -1,8 +1,9 @@
#pragma once
#if !defined(_WIN32)
#include <memory>
#include <string_view>
#include <vector>
namespace thespian {
@ -30,3 +31,5 @@ struct file_descriptor {
};
} // namespace thespian
#endif

View file

@ -0,0 +1,34 @@
#pragma once
#if defined(_WIN32)
#include <memory>
#include <string_view>
namespace thespian {
struct file_stream_impl;
using file_stream_dtor = void (*)(file_stream_impl *);
using file_stream_ref = std::unique_ptr<file_stream_impl, file_stream_dtor>;
struct file_stream {
static auto create(std::string_view tag, void *handle) -> file_stream;
auto start_read() -> void;
auto start_write(std::string_view data) -> void;
auto cancel() -> void;
static void start_read(file_stream_impl *);
static void start_write(file_stream_impl *, std::string_view data);
static void cancel(file_stream_impl *);
static void destroy(file_stream_impl *);
//->("stream", tag, "read_complete")
//->("stream", tag, "read_error", int err, string message)
//->("stream", tag, "write_complete", int bytes_written)
//->("stream", tag, "write_error", int err, string message)
file_stream_ref ref;
};
} // namespace thespian
#endif