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 | |
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
-rw-r--r-- | libibex/ChangeLog | 5 | ||||
-rw-r--r-- | libibex/ibex.h | 3 | ||||
-rw-r--r-- | libibex/ibex_block.c | 24 |
3 files changed, 32 insertions, 0 deletions
diff --git a/libibex/ChangeLog b/libibex/ChangeLog index b91a747552..4f85c3845e 100644 --- a/libibex/ChangeLog +++ b/libibex/ChangeLog @@ -1,3 +1,8 @@ +2001-10-28 <NotZed@Ximian.com> + + * ibex_block.c (ibex_move): New api entry to move an ibex file in + an atomic way. + 2001-10-12 <NotZed@Ximian.com> * ibex_block.c (ibex_use): Added environmental variable diff --git a/libibex/ibex.h b/libibex/ibex.h index 59308deccb..aafa6e734c 100644 --- a/libibex/ibex.h +++ b/libibex/ibex.h @@ -43,6 +43,9 @@ int ibex_write (ibex *ib); /* only save if ibex has changed. */ int ibex_save (ibex *ib); +/* rename an ibex file to a new location */ +int ibex_move (ibex *ib, const char *newname); + /* Write the ibex to disk if it has changed, and free all memory * associated with it. */ 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: |