diff -r 6112bcc5d1cf -r 6ddbca7b9716 librazor/atomic-ktm.c --- a/librazor/atomic-ktm.c Sat Feb 11 23:50:26 2012 +0000 +++ b/librazor/atomic-ktm.c Mon Feb 20 19:31:07 2012 +0000 @@ -142,7 +142,7 @@ retval = !CommitTransaction(atomic->transaction); if (retval) { - atomic->error = razor_error_new_mswin(NULL, GetLastError()); + razor_set_error_mswin(&atomic->error, NULL, GetLastError()); RollbackTransaction(atomic->transaction); } @@ -210,15 +210,15 @@ if (err == ERROR_FILE_NOT_FOUND) { creating = 1; } else { - atomic->error = razor_error_new_mswin(buffer->str, - err); + razor_set_error_mswin(&atomic->error, + buffer->str, err); razor_wstr_destroy(buffer); return -1; } } else if (!(fa.dwFileAttributes& FILE_ATTRIBUTE_DIRECTORY)) { - atomic->error = razor_error_new_str(buffer->str, - "Not a directory"); + razor_set_error2(&atomic->error, buffer->str, + "Not a directory"); razor_wstr_destroy(buffer); return -1; } @@ -226,8 +226,9 @@ if (creating) { if (!CreateDirectoryTransactedW(NULL, buffer->str, NULL, atomic->transaction)) { - atomic->error = razor_error_new_mswin(buffer->str, - GetLastError()); + razor_set_error_mswin(&atomic->error, + buffer->str, + GetLastError()); razor_wstr_destroy(buffer); return -1; } @@ -287,7 +288,7 @@ * same path, this is likely to cause more problems than it solves. */ - atomic->error = razor_error_new_mswin(buf, err); + razor_set_error_mswin(&atomic->error, buf, err); free(buf); return -1; } @@ -315,7 +316,7 @@ if (!MoveFileTransactedW(oldbuf, newbuf, NULL, NULL, flags, atomic->transaction)) - atomic->error = razor_error_new_mswin(newbuf, GetLastError()); + razor_set_error_mswin(&atomic->error, newbuf, GetLastError()); free(newbuf); free(oldbuf); @@ -340,7 +341,7 @@ err = GetLastError(); if (err != ERROR_FILE_EXISTS && err != ERROR_ALREADY_EXISTS) { abort: - atomic->error = razor_error_new_mswin(buf, err); + razor_set_error_mswin(&atomic->error, buf, err); free(buf); return -1; } @@ -380,9 +381,8 @@ * and we don't always know that at the time when the * link is created, so it's a convienent lie for now. */ - atomic->error = razor_error_new_str(NULL, - "Symbolic links not supported " - "on this platform"); + razor_set_error(&atomic->error, NULL, + "Symbolic links not supported on this platform"); return -1; } @@ -401,7 +401,7 @@ files = realloc(atomic->files, (atomic->n_files+1) * sizeof(struct razor_atomic_file)); if (!files) { - atomic->error = razor_error_new_str(NULL, "Not enough memory"); + razor_set_error(&atomic->error, NULL, "Not enough memory"); return -1; } atomic->n_files++; @@ -428,8 +428,8 @@ NULL); if (files[i].h == INVALID_HANDLE_VALUE) { - atomic->error = razor_error_new_mswin(files[i].path, - GetLastError()); + razor_set_error_mswin(&atomic->error, files[i].path, + GetLastError()); free(files[i].path); atomic->n_files--; return -1; @@ -453,8 +453,9 @@ while(size) { if (!WriteFile(atomic->files[handle].h, data, size, &written, NULL)) { - atomic->error = razor_error_new_mswin(atomic->files[handle].path, - GetLastError()); + razor_set_error_mswin(&atomic->error, + atomic->files[handle].path, + GetLastError()); (void)CloseHandle(atomic->files[handle].h); free(atomic->files[handle].path); @@ -483,8 +484,9 @@ assert(atomic->files[handle].h != INVALID_HANDLE_VALUE); if (!CloseHandle(atomic->files[handle].h)) { - atomic->error = razor_error_new_mswin(atomic->files[handle].path, - GetLastError()); + razor_set_error_mswin(&atomic->error, + atomic->files[handle].path, + GetLastError()); free(atomic->files[handle].path); atomic->files[handle].path = NULL; atomic->files[handle].h = INVALID_HANDLE_VALUE; @@ -497,8 +499,9 @@ atomic->files[handle].h = h; if (atomic->files[handle].h == INVALID_HANDLE_VALUE) { - atomic->error = razor_error_new_mswin(atomic->files[handle].path, - GetLastError()); + razor_set_error_mswin(&atomic->error, + atomic->files[handle].path, + GetLastError()); free(atomic->files[handle].path); atomic->files[handle].path = NULL; return -1; @@ -517,8 +520,9 @@ assert(atomic->files[handle].h != INVALID_HANDLE_VALUE); if (!CloseHandle(atomic->files[handle].h)) - atomic->error = razor_error_new_mswin(atomic->files[handle].path, - GetLastError()); + razor_set_error_mswin(&atomic->error, + atomic->files[handle].path, + GetLastError()); free(atomic->files[handle].path); atomic->files[handle].path = NULL;