Mercurial > hg > th-libs
diff th_ioctx.c @ 695:a04b8fe158b9
Add helper function th_io_reopen().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 09 Mar 2020 19:05:58 +0200 |
parents | 49c818acbbbe |
children | 87e97ea5afd1 |
line wrap: on
line diff
--- a/th_ioctx.c Mon Mar 09 18:55:54 2020 +0200 +++ b/th_ioctx.c Mon Mar 09 19:05:58 2020 +0200 @@ -92,6 +92,19 @@ } +int th_io_reopen(th_ioctx *ctx, const char *mode) +{ + if (ctx == NULL) + return THERR_NULLPTR; + + thfclose(ctx); + + th_pstr_cpy(&ctx->mode, mode); + + return (ctx->status = thfopen(ctx)); +} + + void th_io_close(th_ioctx *ctx) { if (ctx != NULL)