Fix bug with handling empty root in KTM version of make_dirs
authorJ. Ali Harlow <ali@juiblex.co.uk>
Tue Jun 05 11:07:53 2018 +0100 (2018-06-05)
changeset 4985a49f274ab2d
parent 497 6fbb686d919f
child 499 c89e5edb8eae
Fix bug with handling empty root in KTM version of make_dirs
librazor/atomic-ktm.c
librazor/razor-internal.h
     1.1 --- a/librazor/atomic-ktm.c	Tue Apr 24 19:27:53 2018 +0100
     1.2 +++ b/librazor/atomic-ktm.c	Tue Jun 05 11:07:53 2018 +0100
     1.3 @@ -103,6 +103,30 @@
     1.4  	return 0;
     1.5  }
     1.6  
     1.7 +#if 0
     1.8 +static char *
     1.9 +razor_wstr_contents(struct razor_wstr *wstr, int len)
    1.10 +{
    1.11 +	int n;
    1.12 +	char *s;
    1.13 +
    1.14 +	if (len < 0 || len > wstr->len)
    1.15 +		len = wstr->len;
    1.16 +
    1.17 +	n = WideCharToMultiByte(CP_UTF8, 0, wstr->str, len, NULL, 0, NULL,
    1.18 +				NULL);
    1.19 +
    1.20 +	s = malloc(n + 1);
    1.21 +
    1.22 +	(void)WideCharToMultiByte(CP_UTF8, 0, wstr->str, wstr->len, s, n, NULL,
    1.23 +				  NULL);
    1.24 +
    1.25 +	s[n] = '\0';
    1.26 +
    1.27 +	return s;
    1.28 +}
    1.29 +#endif
    1.30 +
    1.31  static void
    1.32  razor_wstr_destroy(struct razor_wstr *wstr)
    1.33  {
    1.34 @@ -194,9 +218,13 @@
    1.35  			razor_atomic_propagate_error(atomic, tmp_error, NULL);
    1.36  			return -1;
    1.37  		}
    1.38 -		s = SKIP_DRIVE_LETTER(ru.path);
    1.39 +		s = ru.path;
    1.40  		if (*s == '/')
    1.41 -			s++;
    1.42 +		{
    1.43 +			s = SKIP_DRIVE_LETTER(ru.path + 1);
    1.44 +			if (s > ru.path + 1 && *s == '/')
    1.45 +				s++;
    1.46 +		}
    1.47  		*s = '\0';
    1.48  		s = razor_uri_recompose(&ru);
    1.49  		uri += strlen(s);
    1.50 @@ -207,7 +235,9 @@
    1.51  			razor_atomic_propagate_error(atomic, tmp_error, NULL);
    1.52  			return -1;
    1.53  		}
    1.54 -		path = razor_path_from_uri(uri, &tmp_error);
    1.55 +		s = razor_concat("file:", uri, NULL);
    1.56 +		path = razor_path_from_uri(s, &tmp_error);
    1.57 +		free(s);
    1.58  		if (!path) {
    1.59  			razor_atomic_propagate_error(atomic, tmp_error, NULL);
    1.60  			free(root);
     2.1 --- a/librazor/razor-internal.h	Tue Apr 24 19:27:53 2018 +0100
     2.2 +++ b/librazor/razor-internal.h	Tue Jun 05 11:07:53 2018 +0100
     2.3 @@ -418,7 +418,7 @@
     2.4  
     2.5  #ifdef MSWIN_API
     2.6  #define SKIP_DRIVE_LETTER(path) \
     2.7 -	((RAZOR_ASCII_ISALPHA(path[0]) && (path)[1] == ':') ? \
     2.8 +	((RAZOR_ASCII_ISALPHA((path)[0]) && (path)[1] == ':') ? \
     2.9  	   (path) + 2 : (path))
    2.10  #else
    2.11  #define SKIP_DRIVE_LETTER(path) (path)