2025-06-27 21:54:23 +01:00
|
|
|
#include <blue/core/stream.h>
|
|
|
|
|
#include <blue/io/file.h>
|
|
|
|
|
#include <blue/io/path.h>
|
2025-08-09 19:57:42 +01:00
|
|
|
#include <blue/ds/string.h>
|
2025-06-27 21:54:23 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
int main(int argc, const char **argv)
|
|
|
|
|
{
|
|
|
|
|
if (argc < 2) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *path_cstr = argv[1];
|
|
|
|
|
b_path *path = b_path_create_from_cstr(path_cstr);
|
|
|
|
|
|
|
|
|
|
b_file *file = NULL;
|
2025-07-28 22:23:57 +01:00
|
|
|
b_result result = b_file_open(NULL, path, B_FILE_READ_ONLY, &file);
|
|
|
|
|
if (b_result_is_error(result)) {
|
|
|
|
|
b_throw(result);
|
2025-06-27 21:54:23 +01:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
b_stream *src_stream, *dest_stream;
|
|
|
|
|
|
|
|
|
|
b_file_open_stream(file, &src_stream);
|
|
|
|
|
|
|
|
|
|
b_string *str = b_string_create();
|
|
|
|
|
b_stream_pipeline *pipeline;
|
2025-07-28 22:23:57 +01:00
|
|
|
b_status status = b_string_open_stream(str, &dest_stream);
|
2025-06-27 21:54:23 +01:00
|
|
|
|
|
|
|
|
b_stream_pipeline_create(1024, &pipeline);
|
|
|
|
|
|
|
|
|
|
size_t nr_read;
|
|
|
|
|
b_stream_read_all_bytes_s(src_stream, dest_stream, pipeline, &nr_read);
|
|
|
|
|
|
|
|
|
|
printf("%s\n", b_string_ptr(str));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|