diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-08-08 08:38:28 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-08-08 08:38:28 +0000 |
commit | 10faf1410582cd7aec208a63fd0a65638f6a9de3 (patch) | |
tree | 564d1418cf5fb73fdc814fb5ffad9451570f8cec /src/codeconv.c | |
parent | e5c03181ba3cd06f27e10677960575e44e7900a6 (diff) |
use GDir instead of directly using opendir().
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@479 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/codeconv.c')
-rw-r--r-- | src/codeconv.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/codeconv.c b/src/codeconv.c index b2d3e2b6..4eb68b78 100644 --- a/src/codeconv.c +++ b/src/codeconv.c @@ -1917,27 +1917,24 @@ gint conv_copy_file(const gchar *src, const gchar *dest, const gchar *encoding) gint conv_copy_dir(const gchar *src, const gchar *dest, const gchar *encoding) { - DIR *dp; - struct dirent *d; + GDir *dir; + const gchar *dir_name; gchar *src_file; gchar *dest_file; - if ((dp = opendir(src)) == NULL) { - FILE_OP_ERROR(src, "opendir"); + if ((dir = g_dir_open(src, 0, NULL)) == NULL) { + g_warning("failed to open directory: %s\n", src); return -1; } if (make_dir_hier(dest) < 0) { - closedir(dp); + g_dir_close(dir); 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, + while ((dir_name = g_dir_read_name(dir)) != NULL) { + src_file = g_strconcat(src, G_DIR_SEPARATOR_S, dir_name, NULL); + dest_file = g_strconcat(dest, G_DIR_SEPARATOR_S, dir_name, NULL); if (is_file_exist(src_file)) conv_copy_file(src_file, dest_file, encoding); @@ -1945,7 +1942,7 @@ gint conv_copy_dir(const gchar *src, const gchar *dest, const gchar *encoding) g_free(src_file); } - closedir(dp); + g_dir_close(dir); return 0; } |