aboutsummaryrefslogtreecommitdiffstats
path: root/src/mapper.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-11-28 09:37:05 +0100
committerMax Kellermann <max@duempel.org>2011-11-28 09:50:44 +0100
commitcead5e5bd75ed2d71f3834adcb02e3d99082df7f (patch)
treec5e64b7ac98e0ebe8ce4c67f55b9815350463517 /src/mapper.c
parentcf15629aeae7b2f750388c6823f43cd5918676a4 (diff)
downloadmpd-cead5e5bd75ed2d71f3834adcb02e3d99082df7f.tar.gz
mpd-cead5e5bd75ed2d71f3834adcb02e3d99082df7f.tar.xz
mpd-cead5e5bd75ed2d71f3834adcb02e3d99082df7f.zip
mapper: fix the bogus "not a directory" error message
Use stat() instead of g_file_test() to detect other types of errors, such as "permission denied".
Diffstat (limited to '')
-rw-r--r--src/mapper.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mapper.c b/src/mapper.c
index 426b2980f..30d932f95 100644
--- a/src/mapper.c
+++ b/src/mapper.c
@@ -31,6 +31,9 @@
#include <assert.h>
#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
static char *music_dir;
static size_t music_dir_length;
@@ -54,8 +57,17 @@ strdup_chop_slash(const char *path_fs)
static void
check_directory(const char *path)
{
- if (!g_file_test(path, G_FILE_TEST_IS_DIR))
+ struct stat st;
+ if (stat(path, &st) < 0) {
+ g_warning("Failed to stat directory \"%s\": %s",
+ path, g_strerror(errno));
+ return;
+ }
+
+ if (!S_ISDIR(st.st_mode)) {
g_warning("Not a directory: %s", path);
+ return;
+ }
}
static void