From 8b55f549e4c9c2cf51e08b51bebc6050cc9de7e6 Mon Sep 17 00:00:00 2001 From: J. Ali Harlow Date: Mon, 12 Jan 2009 18:53:02 +0000 Subject: [PATCH] Cope with the non-atomic behaviour of rename on MS-Windows and add some error checking to razor_set_commit. --- librazor/root.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/librazor/root.c b/librazor/root.c index 32d01c8..13bfceb 100644 --- a/librazor/root.c +++ b/librazor/root.c @@ -275,14 +275,22 @@ razor_root_update(struct razor_root *root, struct razor_set *next) RAZOR_EXPORT int razor_root_commit(struct razor_root *root) { + int retval; assert (root != NULL); /* Make it so. */ - rename(root->new_path, root->path); - printf("renamed %s to %s\n", root->new_path, root->path); - razor_set_destroy(root->system); close(root->fd); +#ifdef MSWIN_API + /* Rename is not atomic under MS-Windows */ + remove(root->path); +#endif + retval = rename(root->new_path, root->path); + if (retval) + perror(root->path); + else + printf("renamed %s to %s\n", root->new_path, root->path); + razor_set_destroy(root->system); free(root); - return 0; + return retval; } -- 1.7.1