diff -r d0aa9e0a6d04 -r 8cbc438cc298 librazor/atomic-none.c --- a/librazor/atomic-none.c Thu Feb 09 20:42:08 2012 +0000 +++ b/librazor/atomic-none.c Thu Feb 16 17:33:47 2012 +0000 @@ -59,9 +59,9 @@ RAZOR_EXPORT void razor_atomic_destroy(struct razor_atomic *atomic) { - free(atomic->error_path); - free(atomic->error_str); - free(atomic->error_msg); + if (atomic->error) + razor_error_free(atomic->error); + free(atomic); } @@ -97,13 +97,13 @@ if (stat(buffer, &buf) == 0) { if (!S_ISDIR(buf.st_mode)) { - razor_atomic_set_error_str(atomic, buffer, - "Not a directory"); + atomic->error = razor_error_new_str(buffer, + "Not a directory"); return -1; } } else if (mkdir(buffer, 0777) < 0) { - razor_atomic_set_error_str(atomic, buffer, - strerror(errno)); + atomic->error = razor_error_new_str(buffer, + strerror(errno)); return -1; } } @@ -133,16 +133,16 @@ DeleteFileW(buf)) && !RemoveDirectoryW(buf) && GetLastError() != ERROR_DIR_NOT_EMPTY) - razor_atomic_set_error_mswin(atomic, buf, err); + atomic->error = razor_error_new_mswin(buf, err); } free(buf); #else if (remove(path)) - razor_atomic_set_error_str(atomic, path, strerror(errno)); + atomic->error = razor_error_new_str(path, strerror(errno)); #endif - return !!atomic->error_str; + return razor_atomic_in_error_state(atomic); } RAZOR_EXPORT int @@ -170,16 +170,16 @@ (void)RemoveDirectoryW(newbuf); if (!MoveFileExW(oldbuf, newbuf, flags)) - razor_atomic_set_error_mswin(atomic, newbuf, GetLastError()); + atomic->error = razor_error_new_mswin(newbuf, GetLastError()); free(newbuf); free(oldbuf); #else if (rename(oldpath, newpath)) - razor_atomic_set_error_str(atomic, newpath, strerror(errno)); + atomic->error = razor_error_new_str(newpath, strerror(errno)); #endif - return !!atomic->error_str; + return razor_atomic_in_error_state(atomic); } RAZOR_EXPORT int @@ -193,12 +193,12 @@ return 0; if (errno != EEXIST) { - razor_atomic_set_error_str(atomic, dirname, strerror(errno)); + atomic->error = razor_error_new_str(dirname, strerror(errno)); return -1; } if (chmod(dirname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) { - razor_atomic_set_error_str(atomic, dirname, strerror(errno)); + atomic->error = razor_error_new_str(dirname, strerror(errno)); return -1; } @@ -214,14 +214,15 @@ #if HAVE_SYMLINK if (symlink(target, path) < 0) { - razor_atomic_set_error_str(atomic, NULL, strerror(errno)); + atomic->error = razor_error_new_str(path, strerror(errno)); return -1; } return 0; #else - razor_atomic_set_error_str(atomic, NULL, "Symbolic links not supported " - "on this platform"); + atomic->error = razor_error_new_str(NULL, + "Symbolic links not supported " + "on this platform"); return -1; #endif @@ -236,12 +237,11 @@ if (razor_atomic_in_error_state(atomic)) return -1; - atomic->error_path = strdup(filename); - fd = open(atomic->error_path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, + fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode & (S_IRWXU | S_IRWXG | S_IRWXO)); if (fd == -1) - razor_atomic_set_error_str(atomic, NULL, strerror(errno)); + atomic->error = razor_error_new_str(filename, strerror(errno)); return fd; }