added macro try_void
This commit is contained in:
parent
6d959fe8f5
commit
e0f1941c82
@ -53,6 +53,8 @@ typedef struct Result_ {
|
|||||||
return VAR;\
|
return VAR;\
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define try_void(RSLT_CALL, DEFER_CODE) { try(__result_void, RSLT_CALL, DEFER_CODE) };
|
||||||
|
|
||||||
#define try_fatal(VAR, RSLT_CALL, DEFER_CODE) \
|
#define try_fatal(VAR, RSLT_CALL, DEFER_CODE) \
|
||||||
Result_ VAR = RSLT_CALL;\
|
Result_ VAR = RSLT_CALL;\
|
||||||
if(VAR.error){\
|
if(VAR.error){\
|
||||||
@ -60,3 +62,5 @@ typedef struct Result_ {
|
|||||||
DEFER_CODE;\
|
DEFER_CODE;\
|
||||||
Error_printAndExit(VAR.error);\
|
Error_printAndExit(VAR.error);\
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define try_fatal_void(RSLT_CALL, DEFER_CODE) { try_fatal(__result_void, RSLT_CALL, DEFER_CODE) };
|
||||||
|
|||||||
@ -27,7 +27,7 @@ Result(void) dir_create(cstr path){
|
|||||||
return RESULT_VOID;
|
return RESULT_VOID;
|
||||||
|
|
||||||
char* parentDir= str_copy(path_dirname(str_from_cstr((void*)path))).data;
|
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);
|
free(parentDir);
|
||||||
#if KFS_USE_WINDOWS_H
|
#if KFS_USE_WINDOWS_H
|
||||||
if(!CreateDirectory(path, NULL))
|
if(!CreateDirectory(path, NULL))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user