Files
bluelib/test/cat.c

33 lines
668 B
C
Raw Normal View History

2025-06-27 21:54:23 +01:00
#include <blue/core/stream.h>
2025-10-24 12:51:54 +01:00
#include <blue/core/stringstream.h>
#include <blue/ds/string.h>
2025-06-27 21:54:23 +01:00
#include <blue/io/file.h>
#include <blue/io/path.h>
#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);
2025-10-24 12:51:54 +01:00
b_file *src = NULL;
b_result result = b_file_open(NULL, path, B_FILE_READ_ONLY, &src);
2025-07-28 22:23:57 +01:00
if (b_result_is_error(result)) {
b_throw(result);
2025-06-27 21:54:23 +01:00
return -1;
}
2025-10-24 12:51:54 +01:00
b_stream_buffer *buf = b_stream_buffer_create_dynamic(1024);
2025-06-27 21:54:23 +01:00
size_t nr_read;
2025-10-24 12:51:54 +01:00
b_stream_read_all_bytes_s(src, b_stdout, buf, &nr_read);
b_stream_buffer_unref(buf);
2025-06-27 21:54:23 +01:00
return 0;
}