From cead5e5bd75ed2d71f3834adcb02e3d99082df7f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 28 Nov 2011 09:37:05 +0100 Subject: 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". --- NEWS | 1 + src/mapper.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 28c8b1bb8..aa84dbede 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ ver 0.16.6 (2010/??/??) * encoder: - flac, null, wave: fix buffer corruption bug - wave: support packed 24 bit samples +* mapper: fix the bogus "not a directory" error message * log: print reason for failure * event_pipe: fix WIN32 regression * define WINVER in ./configure 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 #include +#include +#include +#include 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 -- cgit v1.2.3