aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-15 18:58:24 +0200
committerMax Kellermann <max@duempel.org>2009-07-15 18:58:24 +0200
commit9bef46c0daa4fa2778db0e05d5883746cc995264 (patch)
treec6985c7e63bc38ee69b16980bb636561fd48c377 /src
parentc134adbcbf1197d8f6e17ad30252af947294dbf7 (diff)
downloadmpd-9bef46c0daa4fa2778db0e05d5883746cc995264.tar.gz
mpd-9bef46c0daa4fa2778db0e05d5883746cc995264.tar.xz
mpd-9bef46c0daa4fa2778db0e05d5883746cc995264.zip
mapper: use g_file_test() instead of stat()
The GLib functions are more portable.
Diffstat (limited to 'src')
-rw-r--r--src/mapper.c22
1 files changed, 2 insertions, 20 deletions
diff --git a/src/mapper.c b/src/mapper.c
index cec621a43..9a122d068 100644
--- a/src/mapper.c
+++ b/src/mapper.c
@@ -29,11 +29,7 @@
#include <glib.h>
#include <assert.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
#include <string.h>
-#include <errno.h>
static char *music_dir;
static size_t music_dir_length;
@@ -57,17 +53,10 @@ strdup_chop_slash(const char *path_fs)
static void
mapper_set_music_dir(const char *path)
{
- int ret;
- struct stat st;
-
music_dir = strdup_chop_slash(path);
music_dir_length = strlen(music_dir);
- ret = stat(music_dir, &st);
- if (ret < 0)
- g_warning("failed to stat music directory \"%s\": %s",
- music_dir, g_strerror(errno));
- else if (!S_ISDIR(st.st_mode))
+ if (!g_file_test(music_dir, G_FILE_TEST_IS_DIR))
g_warning("music directory is not a directory: \"%s\"",
music_dir);
}
@@ -75,16 +64,9 @@ mapper_set_music_dir(const char *path)
static void
mapper_set_playlist_dir(const char *path)
{
- int ret;
- struct stat st;
-
playlist_dir = g_strdup(path);
- ret = stat(playlist_dir, &st);
- if (ret < 0)
- g_warning("failed to stat playlist directory \"%s\": %s",
- playlist_dir, g_strerror(errno));
- else if (!S_ISDIR(st.st_mode))
+ if (!g_file_test(playlist_dir, G_FILE_TEST_IS_DIR))
g_warning("playlist directory is not a directory: \"%s\"",
playlist_dir);
}