[PATCH 1/3] shell32: add xdg-user-dirs lookup code

Alexandre Julliard julliard at winehq.org
Wed Mar 5 04:50:36 CST 2008


"Lei Zhang" <thestig at google.com> writes:

> +    /* Convert $HOME to wide chars */
> +    len = MultiByteToWideChar(CP_ACP, 0, home_dir, -1, NULL, 0);
> +    home_dirW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
> +    if (!home_dirW)
> +    {
> +        hr = E_OUTOFMEMORY;
> +        goto xdg_user_dir_lookup_error;
> +    }
> +    MultiByteToWideChar(CP_ACP, 0, home_dir, -1, home_dirW, len);
> +    hr = get_xdg_config_file(home_dir, &config_file);
> +    if (FAILED(hr))
> +        goto xdg_user_dir_lookup_error;
> +
> +    file = fopen(config_file, "r");
> +    HeapFree(GetProcessHeap(), 0, config_file);
> +    if (!file)
> +    {
> +        hr = E_HANDLE;
> +        goto xdg_user_dir_lookup_error;
> +    }
> +
> +    while (fgets(buffer, sizeof(buffer), file))
> +    {
> +        int idx;
> +        WCHAR *p, bufferW[512];
> +
> +        /* Convert buffer to wide chars */
> +        len = MultiByteToWideChar(CP_UTF8, 0, buffer, -1, NULL, 0);
> +        MultiByteToWideChar(CP_UTF8, 0, buffer, -1, bufferW, len);

It doesn't make sense to convert $HOME or config strings to Unicode,
these are Unix paths, they should be kept as such until you call
symlink() or whatever on them.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list