diff --git a/io-test/mkdir.c b/io-test/mkdir.c new file mode 100644 index 0000000..ea43964 --- /dev/null +++ b/io-test/mkdir.c @@ -0,0 +1,21 @@ +#include + +int main(int argc, const char **argv) +{ + if (argc < 2) { + return -1; + } + + const char *path = argv[1]; + + b_directory *dir; + b_result result = b_directory_open( + NULL, B_RV_PATH(path), B_DIRECTORY_OPEN_CREATE_INTERMEDIATE, &dir); + if (b_result_is_error(result)) { + b_throw(result); + return -1; + } + + b_directory_release(dir); + return 0; +} diff --git a/io-test/streams.c b/io-test/streams.c index ab904b5..019a570 100644 --- a/io-test/streams.c +++ b/io-test/streams.c @@ -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); diff --git a/io-test/tree.c b/io-test/tree.c index 717faad..d1c7ee1 100644 --- a/io-test/tree.c +++ b/io-test/tree.c @@ -13,11 +13,10 @@ int main(int argc, const char **argv) b_directory *dir = NULL; b_path *path = b_path_create_from_cstr(argv[1]); - b_status status = b_directory_open(B_DIRECTORY_ROOT, path, &dir); + b_result result = b_directory_open(B_DIRECTORY_ROOT, path, 0, &dir); - if (!B_OK(status)) { - printf("cannot open %s\n", b_path_ptr(path)); - printf("%s\n", b_status_to_string(status)); + if (b_result_is_error(result)) { + b_throw(result); return -1; }