On 14-08-29 07:24 AM, Enrico Tröger wrote:
[snip]
I'd implement this way first, based on your patch, and if we want, we
can change to .../Local later anyway if desired.


I think it's probably the easiest solution, with the least code, and
most compatibility. If you don't feel like coding it yourself, let me
know and I can whip up a (real/working) function to do it. I've been
doing a fair bit of Win32 API coding lately so it's fresh on my mind, I

I don't mind, if you like to do it, I'd be happy to test the result :).


Attached is a function that works standalone, it could drop into the previous patch where the untested/working function was. I have only tested on WinXP. If you don't feel like putting it together manually, I can eventually commit it all together properly once I figure out my build system issues.

Cheers,
Matthew Brush

gchar *win32_get_user_config_dir(void)
{
	HRESULT hr;
	wchar_t path[MAX_PATH];

	hr = SHGetFolderPathAndSubDir(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, L"geany", path);
	if (SUCCEEDED(hr))
	{
		// GLib always uses UTF-8 for filename encoding on Windows
		int u8_size = WideCharToMultiByte(CP_UTF8, 0, path, -1, NULL, 0, NULL, NULL);
		if (u8_size > 0)
		{
			gchar *u8_path = g_malloc0(u8_size + 1);
			if (u8_path != NULL &&
				WideCharToMultiByte(CP_UTF8, 0, path, -1, u8_path, u8_size, NULL, NULL))
			{
				return u8_path;
			}
		}
	}

	// glib fallback
	g_warning("Failed to retrieve Windows config dir, falling back to default");
	return g_build_filename(g_get_user_config_dir(), "geany", NULL);
}
_______________________________________________
Devel mailing list
Devel@lists.geany.org
https://lists.geany.org/cgi-bin/mailman/listinfo/devel

Reply via email to