From e0f1941c82fdf20d5c0e1dd38c228f1dc0caac99 Mon Sep 17 00:00:00 2001 From: Timerix Date: Mon, 4 Aug 2025 16:32:23 +0300 Subject: [PATCH] added macro try_void --- include/tlibc/errors.h | 4 ++++ src/filesystem/dir.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/tlibc/errors.h b/include/tlibc/errors.h index 1e42296..1928157 100755 --- a/include/tlibc/errors.h +++ b/include/tlibc/errors.h @@ -53,6 +53,8 @@ typedef struct Result_ { return VAR;\ }; +#define try_void(RSLT_CALL, DEFER_CODE) { try(__result_void, RSLT_CALL, DEFER_CODE) }; + #define try_fatal(VAR, RSLT_CALL, DEFER_CODE) \ Result_ VAR = RSLT_CALL;\ if(VAR.error){\ @@ -60,3 +62,5 @@ typedef struct Result_ { DEFER_CODE;\ Error_printAndExit(VAR.error);\ }; + +#define try_fatal_void(RSLT_CALL, DEFER_CODE) { try_fatal(__result_void, RSLT_CALL, DEFER_CODE) }; diff --git a/src/filesystem/dir.c b/src/filesystem/dir.c index 5b5a0e8..73ad5e1 100644 --- a/src/filesystem/dir.c +++ b/src/filesystem/dir.c @@ -27,7 +27,7 @@ Result(void) dir_create(cstr path){ return RESULT_VOID; char* parentDir= str_copy(path_dirname(str_from_cstr((void*)path))).data; - try(_1, dir_create(parentDir), free(parentDir)); + try_void(dir_create(parentDir), free(parentDir)); free(parentDir); #if KFS_USE_WINDOWS_H if(!CreateDirectory(path, NULL))