diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-01-18 10:50:43 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-01-18 10:50:43 +0000 |
commit | 295bd43a38d1b785183ba1599e78fa6fbbcd8e02 (patch) | |
tree | 1e872659029f80928f3f98b4352aae8888a6928d /src/utils.c | |
parent | 3fec59fac205ff4588f8afe93b28943b31f9ab8d (diff) |
implemented the migration of configuration.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@14 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/utils.c b/src/utils.c index 570f60f3..42b294e1 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2004 Hiroyuki Yamamoto + * Copyright (C) 1999-2005 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2219,6 +2219,41 @@ gint copy_file(const gchar *src, const gchar *dest, gboolean keep_backup) return 0; } +gint copy_dir(const gchar *src, const gchar *dest) +{ + DIR *dp; + struct dirent *d; + gchar *src_file; + gchar *dest_file; + + if ((dp = opendir(src)) == NULL) { + FILE_OP_ERROR(src, "opendir"); + return -1; + } + + if (make_dir_hier(dest) < 0) { + closedir(dp); + return -1; + } + + while ((d = readdir(dp)) != NULL) { + if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) + continue; + + src_file = g_strconcat(src, G_DIR_SEPARATOR_S, d->d_name, NULL); + dest_file = g_strconcat(dest, G_DIR_SEPARATOR_S, d->d_name, + NULL); + if (is_file_exist(src_file)) + copy_file(src_file, dest_file, FALSE); + g_free(dest_file); + g_free(src_file); + } + + closedir(dp); + + return 0; +} + gint move_file(const gchar *src, const gchar *dest, gboolean overwrite) { if (overwrite == FALSE && is_file_exist(dest)) { |