librazor/atomic-ktm.c
changeset 438 fab0b8a61dcb
parent 423 6112bcc5d1cf
child 441 cf499fd51df7
     1.1 --- a/librazor/atomic-ktm.c	Sat Feb 11 23:50:26 2012 +0000
     1.2 +++ b/librazor/atomic-ktm.c	Wed Aug 20 18:57:52 2014 +0100
     1.3 @@ -142,7 +142,7 @@
     1.4  	retval = !CommitTransaction(atomic->transaction);
     1.5  
     1.6  	if (retval) {
     1.7 -		atomic->error = razor_error_new_mswin(NULL, GetLastError());
     1.8 +		razor_set_error_mswin(&atomic->error, NULL, GetLastError());
     1.9  		RollbackTransaction(atomic->transaction);
    1.10  	}
    1.11  
    1.12 @@ -210,15 +210,15 @@
    1.13  				if (err == ERROR_FILE_NOT_FOUND) {
    1.14  					creating = 1;
    1.15  				} else {
    1.16 -					atomic->error = razor_error_new_mswin(buffer->str,
    1.17 -									      err);
    1.18 +					razor_set_error_mswin(&atomic->error,
    1.19 +							      buffer->str, err);
    1.20  					razor_wstr_destroy(buffer);
    1.21  					return -1;
    1.22  				}
    1.23  			} else if (!(fa.dwFileAttributes&
    1.24  				     FILE_ATTRIBUTE_DIRECTORY)) {
    1.25 -				atomic->error = razor_error_new_str(buffer->str,
    1.26 -								    "Not a directory");
    1.27 +				razor_set_error2(&atomic->error, buffer->str,
    1.28 +						 "Not a directory");
    1.29  				razor_wstr_destroy(buffer);
    1.30  				return -1;
    1.31  			}
    1.32 @@ -226,8 +226,9 @@
    1.33  		if (creating) {
    1.34  			if (!CreateDirectoryTransactedW(NULL, buffer->str, NULL,
    1.35  							atomic->transaction)) {
    1.36 -				atomic->error = razor_error_new_mswin(buffer->str,
    1.37 -								      GetLastError());
    1.38 +				razor_set_error_mswin(&atomic->error,
    1.39 +						      buffer->str,
    1.40 +						      GetLastError());
    1.41  				razor_wstr_destroy(buffer);
    1.42  				return -1;
    1.43  			}
    1.44 @@ -287,7 +288,7 @@
    1.45  	 * same path, this is likely to cause more problems than it solves.
    1.46  	 */
    1.47  
    1.48 -	atomic->error = razor_error_new_mswin(buf, err);
    1.49 +	razor_set_error_mswin(&atomic->error, buf, err);
    1.50  	free(buf);
    1.51  	return -1;
    1.52  }
    1.53 @@ -315,7 +316,7 @@
    1.54  
    1.55  	if (!MoveFileTransactedW(oldbuf, newbuf, NULL, NULL, flags,
    1.56  			         atomic->transaction))
    1.57 -		atomic->error = razor_error_new_mswin(newbuf, GetLastError());
    1.58 +		razor_set_error_mswin(&atomic->error, newbuf, GetLastError());
    1.59  
    1.60  	free(newbuf);
    1.61  	free(oldbuf);
    1.62 @@ -340,7 +341,7 @@
    1.63  		err = GetLastError();
    1.64  		if (err != ERROR_FILE_EXISTS && err != ERROR_ALREADY_EXISTS) {
    1.65  abort:
    1.66 -			atomic->error = razor_error_new_mswin(buf, err);
    1.67 +			razor_set_error_mswin(&atomic->error, buf, err);
    1.68  			free(buf);
    1.69  			return -1;
    1.70  		}
    1.71 @@ -380,9 +381,8 @@
    1.72  	 * and we don't always know that at the time when the
    1.73  	 * link is created, so it's a convienent lie for now.
    1.74  	 */
    1.75 -	atomic->error = razor_error_new_str(NULL,
    1.76 -					    "Symbolic links not supported "
    1.77 -					    "on this platform");
    1.78 +	razor_set_error(&atomic->error, NULL,
    1.79 +			"Symbolic links not supported on this platform");
    1.80  
    1.81  	return -1;
    1.82  }
    1.83 @@ -401,7 +401,7 @@
    1.84  	files = realloc(atomic->files,
    1.85  			(atomic->n_files+1) * sizeof(struct razor_atomic_file));
    1.86  	if (!files) {
    1.87 -		atomic->error = razor_error_new_str(NULL, "Not enough memory");
    1.88 +		razor_set_error(&atomic->error, NULL, "Not enough memory");
    1.89  		return -1;
    1.90  	}
    1.91  	atomic->n_files++;
    1.92 @@ -428,8 +428,8 @@
    1.93  					   NULL);
    1.94  
    1.95  	if (files[i].h == INVALID_HANDLE_VALUE) {
    1.96 -		atomic->error = razor_error_new_mswin(files[i].path,
    1.97 -						      GetLastError());
    1.98 +		razor_set_error_mswin(&atomic->error, files[i].path,
    1.99 +				      GetLastError());
   1.100  		free(files[i].path);
   1.101  		atomic->n_files--;
   1.102  		return -1;
   1.103 @@ -453,8 +453,9 @@
   1.104  	while(size) {
   1.105  		if (!WriteFile(atomic->files[handle].h, data, size, &written,
   1.106  			       NULL)) {
   1.107 -			atomic->error = razor_error_new_mswin(atomic->files[handle].path,
   1.108 -							      GetLastError());
   1.109 +			razor_set_error_mswin(&atomic->error,
   1.110 +					      atomic->files[handle].path,
   1.111 +					      GetLastError());
   1.112  
   1.113  			(void)CloseHandle(atomic->files[handle].h);
   1.114  			free(atomic->files[handle].path);
   1.115 @@ -483,8 +484,9 @@
   1.116  	assert(atomic->files[handle].h != INVALID_HANDLE_VALUE);
   1.117  
   1.118  	if (!CloseHandle(atomic->files[handle].h)) {
   1.119 -		atomic->error = razor_error_new_mswin(atomic->files[handle].path,
   1.120 -						      GetLastError());
   1.121 +		razor_set_error_mswin(&atomic->error,
   1.122 +				      atomic->files[handle].path,
   1.123 +				      GetLastError());
   1.124  		free(atomic->files[handle].path);
   1.125  		atomic->files[handle].path = NULL;
   1.126  		atomic->files[handle].h = INVALID_HANDLE_VALUE;
   1.127 @@ -497,8 +499,9 @@
   1.128  	atomic->files[handle].h = h;
   1.129  
   1.130  	if (atomic->files[handle].h == INVALID_HANDLE_VALUE) {
   1.131 -		atomic->error = razor_error_new_mswin(atomic->files[handle].path,
   1.132 -						      GetLastError());
   1.133 +		razor_set_error_mswin(&atomic->error,
   1.134 +				      atomic->files[handle].path,
   1.135 +				      GetLastError());
   1.136  		free(atomic->files[handle].path);
   1.137  		atomic->files[handle].path = NULL;
   1.138  		return -1;
   1.139 @@ -517,8 +520,9 @@
   1.140  	assert(atomic->files[handle].h != INVALID_HANDLE_VALUE);
   1.141  
   1.142  	if (!CloseHandle(atomic->files[handle].h))
   1.143 -		atomic->error = razor_error_new_mswin(atomic->files[handle].path,
   1.144 -						      GetLastError());
   1.145 +		razor_set_error_mswin(&atomic->error,
   1.146 +				      atomic->files[handle].path,
   1.147 +				      GetLastError());
   1.148  
   1.149  	free(atomic->files[handle].path);
   1.150  	atomic->files[handle].path = NULL;