aboutsummaryrefslogtreecommitdiff
path: root/libsylph
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-10-03 08:19:56 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-10-03 08:19:56 +0000
commitb41a0d98336728e13c55170c8f5c6a2eb2825e9d (patch)
treec130de4ed1ed40c953e718ca3ac41f56775c9ba6 /libsylph
parent582acbad25c722a39f6c7bb29c92c3933a964366 (diff)
fixed rename on win32.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@618 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/folder.c29
-rw-r--r--libsylph/mh.c29
2 files changed, 40 insertions, 18 deletions
diff --git a/libsylph/folder.c b/libsylph/folder.c
index 56b23288..818f85b3 100644
--- a/libsylph/folder.c
+++ b/libsylph/folder.c
@@ -861,6 +861,14 @@ gchar *folder_get_path(Folder *folder)
g_warning("folder_get_path: faild to convert character set\n");
path = g_strdup(LOCAL_FOLDER(folder)->rootpath);
}
+ if (!g_path_is_absolute(path)) {
+ gchar *path_;
+
+ path_ = g_strconcat(get_mail_base_dir(),
+ G_DIR_SEPARATOR_S, path, NULL);
+ g_free(path);
+ path = path_;
+ }
} else if (FOLDER_TYPE(folder) == F_IMAP) {
g_return_val_if_fail(folder->account != NULL, NULL);
path = g_strconcat(get_imap_cache_dir(),
@@ -903,22 +911,11 @@ gchar *folder_item_get_path(FolderItem *item)
#endif
}
- if (g_path_is_absolute(folder_path)) {
- if (item_path)
- path = g_strconcat(folder_path, G_DIR_SEPARATOR_S,
- item_path, NULL);
- else
- path = g_strdup(folder_path);
- } else {
- if (item_path)
- 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_mail_base_dir(),
- G_DIR_SEPARATOR_S, folder_path,
- NULL);
- }
+ if (item_path)
+ path = g_strconcat(folder_path, G_DIR_SEPARATOR_S, item_path,
+ NULL);
+ else
+ path = g_strdup(folder_path);
g_free(item_path);
g_free(folder_path);
diff --git a/libsylph/mh.c b/libsylph/mh.c
index 028cf30e..f397eaf9 100644
--- a/libsylph/mh.c
+++ b/libsylph/mh.c
@@ -832,6 +832,19 @@ static gint mh_scan_tree(Folder *folder)
} \
}
+#define MAKE_DIR_HIER_IF_NOT_EXIST(dir) \
+{ \
+ if (!is_dir_exist(dir)) { \
+ if (is_file_exist(dir)) { \
+ g_warning(_("File `%s' already exists.\n" \
+ "Can't create folder."), dir); \
+ return -1; \
+ } \
+ if (make_dir_hier(dir) < 0) \
+ return -1; \
+ } \
+}
+
static gint mh_create_tree(Folder *folder)
{
gchar *rootpath;
@@ -840,7 +853,7 @@ static gint mh_create_tree(Folder *folder)
CHDIR_RETURN_VAL_IF_FAIL(get_mail_base_dir(), -1);
rootpath = LOCAL_FOLDER(folder)->rootpath;
- MAKE_DIR_IF_NOT_EXIST(rootpath);
+ MAKE_DIR_HIER_IF_NOT_EXIST(rootpath);
CHDIR_RETURN_VAL_IF_FAIL(rootpath, -1);
MAKE_DIR_IF_NOT_EXIST(INBOX_DIR);
MAKE_DIR_IF_NOT_EXIST(OUTBOX_DIR);
@@ -852,6 +865,7 @@ static gint mh_create_tree(Folder *folder)
}
#undef MAKE_DIR_IF_NOT_EXIST
+#undef MAKE_DIR_HIER_IF_NOT_EXIST
static FolderItem *mh_create_folder(Folder *folder, FolderItem *parent,
const gchar *name)
@@ -872,7 +886,7 @@ static FolderItem *mh_create_folder(Folder *folder, FolderItem *parent,
g_free(fs_name);
g_free(path);
- if (make_dir(fullpath) < 0) {
+ if (make_dir_hier(fullpath) < 0) {
g_free(fullpath);
return NULL;
}
@@ -894,6 +908,7 @@ static FolderItem *mh_create_folder(Folder *folder, FolderItem *parent,
static gint mh_move_folder_real(Folder *folder, FolderItem *item,
FolderItem *new_parent, const gchar *name)
{
+ gchar *rootpath;
gchar *oldpath;
gchar *newpath;
gchar *dirname;
@@ -953,6 +968,16 @@ static gint mh_move_folder_real(Folder *folder, FolderItem *item,
return -1;
}
+ rootpath = folder_get_path(folder);
+ if (change_dir(rootpath) < 0) {
+ g_free(rootpath);
+ g_free(oldpath);
+ g_free(newpath);
+ g_free(utf8_name);
+ return -1;
+ }
+ g_free(rootpath);
+
debug_print("mh_move_folder: rename(%s, %s)\n", oldpath, newpath);
if (g_rename(oldpath, newpath) < 0) {