1.1 --- a/librazor/atomic-none.c Thu Feb 09 20:42:08 2012 +0000
1.2 +++ b/librazor/atomic-none.c Fri Mar 23 20:23:36 2012 +0000
1.3 @@ -59,9 +59,9 @@
1.4 RAZOR_EXPORT void
1.5 razor_atomic_destroy(struct razor_atomic *atomic)
1.6 {
1.7 - free(atomic->error_path);
1.8 - free(atomic->error_str);
1.9 - free(atomic->error_msg);
1.10 + if (atomic->error)
1.11 + razor_error_free(atomic->error);
1.12 +
1.13 free(atomic);
1.14 }
1.15
1.16 @@ -97,13 +97,13 @@
1.17
1.18 if (stat(buffer, &buf) == 0) {
1.19 if (!S_ISDIR(buf.st_mode)) {
1.20 - razor_atomic_set_error_str(atomic, buffer,
1.21 - "Not a directory");
1.22 + atomic->error = razor_error_new_str(buffer,
1.23 + "Not a directory");
1.24 return -1;
1.25 }
1.26 } else if (mkdir(buffer, 0777) < 0) {
1.27 - razor_atomic_set_error_str(atomic, buffer,
1.28 - strerror(errno));
1.29 + atomic->error = razor_error_new_str(buffer,
1.30 + strerror(errno));
1.31 return -1;
1.32 }
1.33 }
1.34 @@ -133,16 +133,16 @@
1.35 DeleteFileW(buf)) &&
1.36 !RemoveDirectoryW(buf) &&
1.37 GetLastError() != ERROR_DIR_NOT_EMPTY)
1.38 - razor_atomic_set_error_mswin(atomic, buf, err);
1.39 + atomic->error = razor_error_new_mswin(buf, err);
1.40 }
1.41
1.42 free(buf);
1.43 #else
1.44 if (remove(path))
1.45 - razor_atomic_set_error_str(atomic, path, strerror(errno));
1.46 + atomic->error = razor_error_new_str(path, strerror(errno));
1.47 #endif
1.48
1.49 - return !!atomic->error_str;
1.50 + return razor_atomic_in_error_state(atomic);
1.51 }
1.52
1.53 RAZOR_EXPORT int
1.54 @@ -170,16 +170,16 @@
1.55 (void)RemoveDirectoryW(newbuf);
1.56
1.57 if (!MoveFileExW(oldbuf, newbuf, flags))
1.58 - razor_atomic_set_error_mswin(atomic, newbuf, GetLastError());
1.59 + atomic->error = razor_error_new_mswin(newbuf, GetLastError());
1.60
1.61 free(newbuf);
1.62 free(oldbuf);
1.63 #else
1.64 if (rename(oldpath, newpath))
1.65 - razor_atomic_set_error_str(atomic, newpath, strerror(errno));
1.66 + atomic->error = razor_error_new_str(newpath, strerror(errno));
1.67 #endif
1.68
1.69 - return !!atomic->error_str;
1.70 + return razor_atomic_in_error_state(atomic);
1.71 }
1.72
1.73 RAZOR_EXPORT int
1.74 @@ -193,12 +193,12 @@
1.75 return 0;
1.76
1.77 if (errno != EEXIST) {
1.78 - razor_atomic_set_error_str(atomic, dirname, strerror(errno));
1.79 + atomic->error = razor_error_new_str(dirname, strerror(errno));
1.80 return -1;
1.81 }
1.82
1.83 if (chmod(dirname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
1.84 - razor_atomic_set_error_str(atomic, dirname, strerror(errno));
1.85 + atomic->error = razor_error_new_str(dirname, strerror(errno));
1.86 return -1;
1.87 }
1.88
1.89 @@ -214,14 +214,15 @@
1.90
1.91 #if HAVE_SYMLINK
1.92 if (symlink(target, path) < 0) {
1.93 - razor_atomic_set_error_str(atomic, NULL, strerror(errno));
1.94 + atomic->error = razor_error_new_str(path, strerror(errno));
1.95 return -1;
1.96 }
1.97
1.98 return 0;
1.99 #else
1.100 - razor_atomic_set_error_str(atomic, NULL, "Symbolic links not supported "
1.101 - "on this platform");
1.102 + atomic->error = razor_error_new_str(NULL,
1.103 + "Symbolic links not supported "
1.104 + "on this platform");
1.105
1.106 return -1;
1.107 #endif
1.108 @@ -236,12 +237,11 @@
1.109 if (razor_atomic_in_error_state(atomic))
1.110 return -1;
1.111
1.112 - atomic->error_path = strdup(filename);
1.113 - fd = open(atomic->error_path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
1.114 + fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
1.115 mode & (S_IRWXU | S_IRWXG | S_IRWXO));
1.116
1.117 if (fd == -1)
1.118 - razor_atomic_set_error_str(atomic, NULL, strerror(errno));
1.119 + atomic->error = razor_error_new_str(filename, strerror(errno));
1.120
1.121 return fd;
1.122 }