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/template.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/template.c')
-rw-r--r-- | src/template.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/template.c b/src/template.c index c2dc9b2e..6a1494f8 100644 --- a/src/template.c +++ b/src/template.c @@ -1,7 +1,7 @@ /* * Sylpheed templates subsystem * Copyright (C) 2001 Alexander Barinov - * Copyright (C) 2001-2004 Hiroyuki Yamamoto + * Copyright (C) 2001-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 @@ -23,7 +23,6 @@ #include <glib.h> #include <glib/gi18n.h> #include <stdio.h> -#include <dirent.h> #include <sys/stat.h> #include <ctype.h> @@ -110,8 +109,8 @@ GSList *template_read_config(void) { const gchar *path; gchar *filename; - DIR *dp; - struct dirent *de; + GDir *dir; + const gchar *dir_name; struct stat s; Template *tmpl; GSList *tmpl_list = NULL; @@ -125,16 +124,14 @@ GSList *template_read_config(void) return NULL; } - if ((dp = opendir(path)) == NULL) { - FILE_OP_ERROR(path, "opendir"); + if ((dir = g_dir_open(path, 0, NULL)) == NULL) { + g_warning("failed to open directory: %s\n", path); return NULL; } - while ((de = readdir(dp)) != NULL) { - if (*de->d_name == '.') continue; - + while ((dir_name = g_dir_read_name(dir)) != NULL) { filename = g_strconcat(path, G_DIR_SEPARATOR_S, - de->d_name, NULL); + dir_name, NULL); if (g_stat(filename, &s) != 0 || !S_ISREG(s.st_mode) ) { debug_print("%s:%d %s is not an ordinary file\n", @@ -149,7 +146,7 @@ GSList *template_read_config(void) g_free(filename); } - closedir(dp); + g_dir_close(dir); return tmpl_list; } |