aboutsummaryrefslogtreecommitdiff
path: root/libsylph/utils.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-01-15 05:04:21 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-01-15 05:04:21 +0000
commitb74a903d5ce2bfcc0b7cca07e366e8e2b80d9d08 (patch)
treea91966aa920cfd47428e6b1fcddc92e29d797f61 /libsylph/utils.c
parentd4f0efec8c5a80fc34c828120bc75992c218815e (diff)
vi Ch
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1478 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/utils.c')
-rw-r--r--libsylph/utils.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c
index 677cffc3..5e3ba645 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -1829,6 +1829,28 @@ const gchar *get_startup_dir(void)
return startup_dir;
}
+#ifdef G_OS_WIN32
+static gchar *get_win32_special_folder_path(gint nfolder)
+{
+ gchar *folder = NULL;
+ HRESULT hr;
+
+ if (G_WIN32_HAVE_WIDECHAR_API()) {
+ wchar_t path[MAX_PATH + 1];
+ hr = SHGetFolderPathW(NULL, nfolder, NULL, 0, path);
+ if (hr == S_OK)
+ folder = g_utf16_to_utf8(path, -1, NULL, NULL, NULL);
+ } else {
+ gchar path[MAX_PATH + 1];
+ hr = SHGetFolderPathA(NULL, nfolder, NULL, 0, path);
+ if (hr == S_OK)
+ folder = g_locale_to_utf8(path, -1, NULL, NULL, NULL);
+ }
+
+ return folder;
+}
+#endif
+
const gchar *get_home_dir(void)
{
#ifdef G_OS_WIN32
@@ -1853,23 +1875,7 @@ const gchar *get_document_dir(void)
HRESULT hr;
if (!document_dir) {
- if (G_WIN32_HAVE_WIDECHAR_API()) {
- wchar_t path[MAX_PATH + 1];
- hr = SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, 0,
- path);
- if (hr == S_OK) {
- document_dir = g_utf16_to_utf8
- (path, -1, NULL, NULL, NULL);
- }
- } else {
- gchar path[MAX_PATH + 1];
- hr = SHGetFolderPathA(NULL, CSIDL_PERSONAL, NULL, 0,
- path);
- if (hr == S_OK) {
- document_dir = g_locale_to_utf8
- (path, -1, NULL, NULL, NULL);
- }
- }
+ document_dir = get_win32_special_folder_path(CSIDL_PERSONAL);
if (!document_dir)
document_dir = get_home_dir();
}
@@ -1884,15 +1890,16 @@ const gchar *get_rc_dir(void)
{
if (!rc_dir) {
#ifdef G_OS_WIN32
- const gchar *appdata;
+ gchar *appdata;
- appdata = g_getenv("APPDATA");
+ appdata = get_win32_special_folder_path(CSIDL_APPDATA);
if (appdata)
rc_dir = g_strconcat(appdata, G_DIR_SEPARATOR_S,
RC_DIR, NULL);
else
rc_dir = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
RC_DIR, NULL);
+ g_free(appdata);
#else
rc_dir = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
RC_DIR, NULL);