From cf90bb5d3354ed745a7e0fd1ceb13ea8c28a8b58 Mon Sep 17 00:00:00 2001 From: 8 Date: Sun, 28 Oct 2001 13:04:54 +0000 Subject: New api entry to move an ibex file in an atomic way. 2001-10-28 * ibex_block.c (ibex_move): New api entry to move an ibex file in an atomic way. svn path=/trunk/; revision=14293 --- libibex/ibex_block.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'libibex/ibex_block.c') diff --git a/libibex/ibex_block.c b/libibex/ibex_block.c index 7ce4e7934b..3c96885f4f 100644 --- a/libibex/ibex_block.c +++ b/libibex/ibex_block.c @@ -491,6 +491,30 @@ int ibex_close (ibex *ib) return ret; } +/* rename/move the ibex file */ +int ibex_move(ibex *ib, const char *newname) +{ + int ret = -1; + + IBEX_LOCK(ib); + + if (ib->blocks) + close_backend(ib); + + if (rename(ib->name, newname) == -1) + goto error; + + g_free(ib->name); + ib->name = g_strdup(newname); + ret = 0; + +error: + IBEX_UNLOCK(ib); + + return ret; +} + + /** * ibex_unindex: * @ib: -- cgit v1.2.3