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))