librazor/error.c
changeset 495 5196f8110473
parent 447 0a5e583393e1
child 499 c89e5edb8eae
     1.1 --- a/librazor/error.c	Tue Sep 09 15:27:12 2014 +0100
     1.2 +++ b/librazor/error.c	Tue Mar 06 12:39:15 2018 +0000
     1.3 @@ -20,6 +20,9 @@
     1.4  
     1.5  #ifdef MSWIN_API
     1.6  #include <windows.h>
     1.7 +#ifndef ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED
     1.8 +#define ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED	6832L
     1.9 +#endif
    1.10  #endif
    1.11  #include <stdlib.h>
    1.12  #include <string.h>
    1.13 @@ -129,12 +132,28 @@
    1.14  	if (object)
    1.15  		error->object = razor_utf16_to_utf8(object, -1);
    1.16  
    1.17 -	FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER|
    1.18 -		       FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
    1.19 -		       NULL, err, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
    1.20 -		       (LPWSTR)&buf, 0, NULL);
    1.21 -	error->str = razor_utf16_to_utf8(buf, -1);
    1.22 -	LocalFree(buf);
    1.23 +	switch(err) {
    1.24 +	case ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED:
    1.25 +		/*
    1.26 +		 * Attempting to include files in a transaction on a filesystem
    1.27 +		 * that doesn't support them (only NTFS?) produces this error
    1.28 +		 * for which the default text isn't very informative. Try and
    1.29 +		 * give more useful information.
    1.30 +		 */
    1.31 +		error->str = strdup("Not allowed (perhaps the filesystem "
    1.32 +				    "doesn't support transactions)");
    1.33 +		break;
    1.34 +	default:
    1.35 +		FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER|
    1.36 +			       FORMAT_MESSAGE_FROM_SYSTEM|
    1.37 +			       FORMAT_MESSAGE_IGNORE_INSERTS,
    1.38 +			       NULL, err,
    1.39 +			       MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
    1.40 +			       (LPWSTR)&buf, 0, NULL);
    1.41 +		error->str = razor_utf16_to_utf8(buf, -1);
    1.42 +		LocalFree(buf);
    1.43 +		break;
    1.44 +	}
    1.45  
    1.46  	return error;
    1.47  }