45 lines
811 B
C
45 lines
811 B
C
#include "../../include/error.h"
|
|
#include "../../include/util.h"
|
|
#include "../../include/ctx.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
|
|
char *lm_ctx_temp_dir(lm_ctx_t *ctx, char *dir){
|
|
if(NULL == dir){
|
|
lm_error_set(LM_ERR_ArgNULL);
|
|
return false;
|
|
}
|
|
|
|
if(NULL == ctx->temp){
|
|
lm_error_set(LM_ERR_CtxTempNULL);
|
|
return false;
|
|
}
|
|
|
|
char td[strlen(ctx->temp)+strlen(dir)+10];
|
|
join(td, ctx->temp, dir);
|
|
|
|
if(!mkdir_ifnot(td, 0755)){
|
|
lm_error_set(LM_ERR_CtxTempFailMkdir);
|
|
return NULL;
|
|
}
|
|
|
|
return strdup(td);
|
|
}
|
|
|
|
bool lm_ctx_temp_clear(lm_ctx_t *ctx) {
|
|
if(NULL == ctx->temp){
|
|
lm_error_set(LM_ERR_CtxTempNULL);
|
|
return false;
|
|
}
|
|
|
|
rmrf(ctx->temp);
|
|
|
|
if(!mkdir_ifnot(ctx->temp, 0755)){
|
|
lm_error_set(LM_ERR_CtxTempFailMkdir);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|