2025-06-27 21:54:10 +01:00
|
|
|
#include <blue/core/stream.h>
|
|
|
|
|
#include <blue/io/file.h>
|
|
|
|
|
#include <blue/io/path.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
int main(int argc, const char **argv)
|
|
|
|
|
{
|
|
|
|
|
b_file *dest;
|
|
|
|
|
b_path *path = b_path_create_from_cstr("data.txt");
|
2025-07-28 22:22:14 +01:00
|
|
|
b_result result = b_file_open(
|
2025-06-27 21:54:10 +01:00
|
|
|
NULL, path, B_FILE_WRITE_ONLY | B_FILE_CREATE, &dest);
|
2025-07-28 22:22:14 +01:00
|
|
|
if (b_result_is_error(result)) {
|
|
|
|
|
b_throw(result);
|
2025-06-27 21:54:10 +01:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t nr_read = 0;
|
2025-10-24 12:51:54 +01:00
|
|
|
b_stream_buffer *buf = b_stream_buffer_create_dynamic(1024);
|
|
|
|
|
b_stream_read_all_bytes_s(b_stdin, dest, buf, &nr_read);
|
2025-06-27 21:54:10 +01:00
|
|
|
|
|
|
|
|
printf("done. read %zu bytes total.\n", nr_read);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|