Commit cead5e5b authored by Max Kellermann's avatar Max Kellermann

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".
parent cf15629a
...@@ -4,6 +4,7 @@ ver 0.16.6 (2010/??/??) ...@@ -4,6 +4,7 @@ ver 0.16.6 (2010/??/??)
* encoder: * encoder:
- flac, null, wave: fix buffer corruption bug - flac, null, wave: fix buffer corruption bug
- wave: support packed 24 bit samples - wave: support packed 24 bit samples
* mapper: fix the bogus "not a directory" error message
* log: print reason for failure * log: print reason for failure
* event_pipe: fix WIN32 regression * event_pipe: fix WIN32 regression
* define WINVER in ./configure * define WINVER in ./configure
......
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
static char *music_dir; static char *music_dir;
static size_t music_dir_length; static size_t music_dir_length;
...@@ -54,8 +57,17 @@ strdup_chop_slash(const char *path_fs) ...@@ -54,8 +57,17 @@ strdup_chop_slash(const char *path_fs)
static void static void
check_directory(const char *path) 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); g_warning("Not a directory: %s", path);
return;
}
} }
static void static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment