diff options
author | TingPing <tingping@tingping.se> | 2014-06-04 13:56:33 -0400 |
---|---|---|
committer | TingPing <tingping@tingping.se> | 2014-06-04 13:56:33 -0400 |
commit | 3cd8556c542721f41b63d1978d75ce8891f27908 (patch) | |
tree | 62db473cdded0984392df5d884aedbfefc5dde9c /src | |
parent | 9c981cfc6b3c1431f5a91a9b1ddac9b3c5bab50d (diff) |
Use GDir instead of dirent
Diffstat (limited to 'src')
-rw-r--r-- | src/common/util.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/common/util.c b/src/common/util.c index 2dc0034b..167f8b81 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -34,13 +34,11 @@ #include <process.h> #include <io.h> #include <VersionHelpers.h> -#include "../dirent/dirent-win32.h" #else #include <unistd.h> #include <pwd.h> #include <sys/time.h> #include <sys/utsname.h> -#include <dirent.h> #endif #include "../../config.h" @@ -934,27 +932,26 @@ break_while: void for_files (char *dirname, char *mask, void callback (char *file)) { - DIR *dir; - struct dirent *ent; + GDir *dir; + const gchar *entry_name; char *buf; - dir = opendir (dirname); + dir = g_dir_open (dirname, 0, NULL); if (dir) { - while ((ent = readdir (dir))) + while ((entry_name = g_dir_read_name (dir))) { - if (strcmp (ent->d_name, ".") && strcmp (ent->d_name, "..")) + if (strcmp (entry_name, ".") && strcmp (entry_name, "..")) { - if (match (mask, ent->d_name)) + if (match (mask, entry_name)) { - buf = malloc (strlen (dirname) + strlen (ent->d_name) + 2); - sprintf (buf, "%s" G_DIR_SEPARATOR_S "%s", dirname, ent->d_name); + buf = g_build_filename (dirname, entry_name, NULL); callback (buf); - free (buf); + g_free (buf); } } } - closedir (dir); + g_dir_close (dir); } } |