and add some error checking to razor_set_commit.
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;
}