diff options
author | 8 <NotZed@Ximian.com> | 2001-10-28 21:04:54 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2001-10-28 21:04:54 +0800 |
commit | cf90bb5d3354ed745a7e0fd1ceb13ea8c28a8b58 (patch) | |
tree | c24f50381f66e008afe6ac697086716a32dfdaee /libibex/ibex_block.c | |
parent | f5ea3c70d073c60adfd8a013569e13cbab902157 (diff) | |
download | gsoc2013-evolution-cf90bb5d3354ed745a7e0fd1ceb13ea8c28a8b58.tar gsoc2013-evolution-cf90bb5d3354ed745a7e0fd1ceb13ea8c28a8b58.tar.gz gsoc2013-evolution-cf90bb5d3354ed745a7e0fd1ceb13ea8c28a8b58.tar.bz2 gsoc2013-evolution-cf90bb5d3354ed745a7e0fd1ceb13ea8c28a8b58.tar.lz gsoc2013-evolution-cf90bb5d3354ed745a7e0fd1ceb13ea8c28a8b58.tar.xz gsoc2013-evolution-cf90bb5d3354ed745a7e0fd1ceb13ea8c28a8b58.tar.zst gsoc2013-evolution-cf90bb5d3354ed745a7e0fd1ceb13ea8c28a8b58.zip |
New api entry to move an ibex file in an atomic way.
2001-10-28 <NotZed@Ximian.com>
* ibex_block.c (ibex_move): New api entry to move an ibex file in
an atomic way.
svn path=/trunk/; revision=14293
Diffstat (limited to 'libibex/ibex_block.c')
-rw-r--r-- | libibex/ibex_block.c | 24 |
1 files changed, 24 insertions, 0 deletions
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: |