aboutsummaryrefslogtreecommitdiff
path: root/libsylph/mh.c
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/mh.c
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/mh.c')
-rw-r--r--libsylph/mh.c29
1 files changed, 27 insertions, 2 deletions
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) {