From 47e3cd0fdbfd59165761cab3e96612240e1e03bd Mon Sep 17 00:00:00 2001 From: NotZed Date: Sun, 7 May 2000 08:49:41 +0000 Subject: New function, only write out the ibex if it has changed. 2000-05-07 NotZed * file.c (ibex_save): New function, only write out the ibex if it has changed. svn path=/trunk/; revision=2868 --- libibex/ChangeLog | 5 +++++ libibex/file.c | 16 ++++++++++++++++ libibex/ibex.h | 3 +++ 3 files changed, 24 insertions(+) (limited to 'libibex') diff --git a/libibex/ChangeLog b/libibex/ChangeLog index 016416574f..27661d3012 100644 --- a/libibex/ChangeLog +++ b/libibex/ChangeLog @@ -1,3 +1,8 @@ +2000-05-07 NotZed + + * file.c (ibex_save): New function, only write out the ibex if it + has changed. + 2000-05-07 * file.c (ibex_open): Also close the fd after we're done. diff --git a/libibex/file.c b/libibex/file.c index 462fbec3d4..c419360e26 100644 --- a/libibex/file.c +++ b/libibex/file.c @@ -346,6 +346,22 @@ lose: return -1; } +/** + * ibex_save: + * @ib: + * + * Only write out an ibex if it is dirty. + * + * Return value: Same as ibex_write. + **/ +int +ibex_save (ibex *ib) +{ + if (ib->dirty) + return ibex_write(ib); + return 0; +} + /** * ibex_close: Write out the ibex file (if it has changed) and free * the data associated with it. diff --git a/libibex/ibex.h b/libibex/ibex.h index 646853b120..03635e275d 100644 --- a/libibex/ibex.h +++ b/libibex/ibex.h @@ -41,6 +41,9 @@ ibex *ibex_open (char *file, int flags, int mode); /* Write the ibex to disk. */ int ibex_write (ibex *ib); +/* only save if ibex has changed. */ +int ibex_save (ibex *ib); + /* Write the ibex to disk if it has changed, and free all memory * associated with it. */ -- cgit