test: io: update i/o api usage re: b_error

This commit is contained in:
2025-07-28 22:22:14 +01:00
parent 0ab1855105
commit ad4eba6cc1
3 changed files with 28 additions and 9 deletions

View File

@@ -7,18 +7,17 @@ int main(int argc, const char **argv)
{
b_file *dest;
b_path *path = b_path_create_from_cstr("data.txt");
b_status status = b_file_open(
b_result result = b_file_open(
NULL, path, B_FILE_WRITE_ONLY | B_FILE_CREATE, &dest);
if (!B_OK(status)) {
fprintf(stderr, "cannot open file (%s)\n",
b_status_to_string(status));
if (b_result_is_error(result)) {
b_throw(result);
return -1;
}
size_t nr_read = 0;
b_stream *dest_stream;
b_stream_pipeline *pipeline;
status = b_file_open_stream(dest, &dest_stream);
b_status status = b_file_open_stream(dest, &dest_stream);
b_stream_pipeline_create(1024, &pipeline);
b_stream_read_all_bytes_s(b_stdin, dest_stream, pipeline, &nr_read);