1.1 --- a/librazor/root.c Mon Jan 12 17:54:13 2009 +0000
1.2 +++ b/librazor/root.c Wed Apr 29 17:00:01 2009 +0100
1.3 @@ -275,14 +275,22 @@
1.4 RAZOR_EXPORT int
1.5 razor_root_commit(struct razor_root *root)
1.6 {
1.7 + int retval;
1.8 assert (root != NULL);
1.9
1.10 /* Make it so. */
1.11 - rename(root->new_path, root->path);
1.12 - printf("renamed %s to %s\n", root->new_path, root->path);
1.13 + close(root->fd);
1.14 +#ifdef MSWIN_API
1.15 + /* Rename is not atomic under MS-Windows */
1.16 + remove(root->path);
1.17 +#endif
1.18 + retval = rename(root->new_path, root->path);
1.19 + if (retval)
1.20 + perror(root->path);
1.21 + else
1.22 + printf("renamed %s to %s\n", root->new_path, root->path);
1.23 razor_set_destroy(root->system);
1.24 - close(root->fd);
1.25 free(root);
1.26
1.27 - return 0;
1.28 + return retval;
1.29 }