aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-08-09 07:31:31 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-08-09 07:31:31 +0000
commit379ded77a4b51e04dfe2bbe3a97b7e8ca96300cd (patch)
treee452df2eee39c127b9244b52cdc80613df309391 /src
parent416aeb194a7fdd9c8f643ec63b5ee4b6b408fdd3 (diff)
modified directories for Windows convention.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@482 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/defs.h2
-rw-r--r--src/folder.c13
-rw-r--r--src/main.c11
-rw-r--r--src/utils.c59
-rw-r--r--src/utils.h1
5 files changed, 51 insertions, 35 deletions
diff --git a/src/defs.h b/src/defs.h
index 01e24e6d..9683c28d 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -44,7 +44,7 @@
#define DRAFT_DIR "draft"
#define TRASH_DIR "trash"
#ifdef G_OS_WIN32
-# define RC_DIR "sylpheed-2.0"
+# define RC_DIR "Sylpheed"
#else
# define RC_DIR ".sylpheed-2.0"
#endif
diff --git a/src/folder.c b/src/folder.c
index c4645fe3..6d5a29d1 100644
--- a/src/folder.c
+++ b/src/folder.c
@@ -897,7 +897,7 @@ gchar *folder_item_get_path(FolderItem *item)
}
}
- if (folder_path[0] == G_DIR_SEPARATOR) {
+ if (g_path_is_absolute(folder_path)) {
if (item_path)
path = g_strconcat(folder_path, G_DIR_SEPARATOR_S,
item_path, NULL);
@@ -905,12 +905,13 @@ gchar *folder_item_get_path(FolderItem *item)
path = g_strdup(folder_path);
} else {
if (item_path)
- path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
- folder_path, G_DIR_SEPARATOR_S,
- item_path, NULL);
+ path = g_strconcat(get_mail_base_dir(),
+ G_DIR_SEPARATOR_S, folder_path,
+ G_DIR_SEPARATOR_S, item_path, NULL);
else
- path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
- folder_path, NULL);
+ path = g_strconcat(get_mail_base_dir(),
+ G_DIR_SEPARATOR_S, folder_path,
+ NULL);
}
g_free(item_path);
diff --git a/src/main.c b/src/main.c
index 1cae8f53..e5adf542 100644
--- a/src/main.c
+++ b/src/main.c
@@ -209,6 +209,7 @@ int main(int argc, char *argv[])
CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
+#ifndef G_OS_WIN32
/* backup if old rc file exists */
if (is_file_exist(RC_DIR)) {
if (rename_force(RC_DIR, RC_DIR ".bak") < 0)
@@ -217,7 +218,6 @@ int main(int argc, char *argv[])
/* migration from ~/.sylpheed to ~/.sylpheed-2.0 */
if (!is_dir_exist(RC_DIR)) {
-#ifdef G_OS_UNIX
const gchar *envstr;
AlertValue val;
@@ -241,13 +241,20 @@ int main(int argc, char *argv[])
return 1;
}
}
-#endif /* G_OS_UNIX */
if (make_dir(RC_DIR) < 0)
return 1;
if (is_dir_exist(OLD_RC_DIR))
migrate_old_config();
}
+#else
+ if (!is_dir_exist(get_rc_dir())) {
+ if (make_dir_hier(get_rc_dir()) < 0)
+ return 1;
+ }
+
+ MAKE_DIR_IF_NOT_EXIST(get_mail_base_dir());
+#endif /* G_OS_WIN32 */
MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir());
MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir());
diff --git a/src/utils.c b/src/utils.c
index ca0ec177..61d7f1c8 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1724,34 +1724,20 @@ gint scan_mailto_url(const gchar *mailto, gchar **to, gchar **cc, gchar **bcc,
return 0;
}
-/*
- * We need this wrapper around g_get_home_dir(), so that
- * we can fix some Windoze things here. Should be done in glibc of course
- * but as long as we are not able to do our own extensions to glibc, we do
- * it here.
- */
const gchar *get_home_dir(void)
{
-#if HAVE_DOSISH_SYSTEM
- static gchar *home_dir;
-
- if (!home_dir) {
- home_dir = read_w32_registry_string(NULL,
- "Software\\Sylpheed", "HomeDir" );
- if (!home_dir || !*home_dir) {
- if (getenv ("HOMEDRIVE") && getenv("HOMEPATH")) {
- const char *s = g_get_home_dir();
- if (s && *s)
- home_dir = g_strdup (s);
- }
- if (!home_dir || !*home_dir)
- home_dir = g_strdup ("c:\\sylpheed");
- }
- debug_print("initialized home_dir to `%s'\n", home_dir);
- }
- return home_dir;
-#else /* standard glib */
- return g_get_home_dir();
+#ifdef G_OS_WIN32
+ static const gchar *home_dir = NULL;
+
+ if (!home_dir) {
+ home_dir = g_get_home_dir();
+ if (!home_dir)
+ home_dir = "C:\\Sylpheed";
+ }
+
+ return home_dir;
+#else
+ return g_get_home_dir();
#endif
}
@@ -1760,8 +1746,14 @@ const gchar *get_rc_dir(void)
static gchar *rc_dir = NULL;
if (!rc_dir)
+#ifdef G_OS_WIN32
rc_dir = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
+ "Application Data", G_DIR_SEPARATOR_S,
RC_DIR, NULL);
+#else
+ rc_dir = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
+ RC_DIR, NULL);
+#endif
return rc_dir;
}
@@ -1777,6 +1769,21 @@ const gchar *get_old_rc_dir(void)
return old_rc_dir;
}
+const gchar *get_mail_base_dir(void)
+{
+#if G_OS_WIN32
+ static gchar *mail_base_dir = NULL;
+
+ if (!mail_base_dir)
+ mail_base_dir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ "Mailboxes", NULL);
+
+ return mail_base_dir;
+#else
+ return get_home_dir();
+#endif
+}
+
const gchar *get_news_cache_dir(void)
{
static gchar *news_cache_dir = NULL;
diff --git a/src/utils.h b/src/utils.h
index 976525d8..a42e2eb8 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -374,6 +374,7 @@ gint scan_mailto_url (const gchar *mailto,
const gchar *get_home_dir (void);
const gchar *get_rc_dir (void);
const gchar *get_old_rc_dir (void);
+const gchar *get_mail_base_dir (void);
const gchar *get_news_cache_dir (void);
const gchar *get_imap_cache_dir (void);
const gchar *get_mime_tmp_dir (void);