From: J. Ali Harlow Date: Mon, 12 Jan 2009 18:53:02 +0000 (+0000) Subject: Cope with the non-atomic behaviour of rename on MS-Windows X-Git-Tag: 0.1~32 X-Git-Url: http://project.juiblex.co.uk/git/?a=commitdiff_plain;h=8b55f549e4c9c2cf51e08b51bebc6050cc9de7e6;p=razor2.git%2F.git Cope with the non-atomic behaviour of rename on MS-Windows and add some error checking to razor_set_commit. --- 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; }