aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs/FileSystem.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-03-05 09:43:51 +0100
committerMax Kellermann <max@duempel.org>2015-03-05 10:07:07 +0100
commit830a1bd130f819adfef71c882a335e5405f3f02d (patch)
tree96d2433193654ba9a99daee129f97c1cc3da283b /src/fs/FileSystem.hxx
parent5c5ea8a2542412aa02c6ac96d7f659760657644b (diff)
downloadmpd-830a1bd130f819adfef71c882a335e5405f3f02d.tar.gz
mpd-830a1bd130f819adfef71c882a335e5405f3f02d.tar.xz
mpd-830a1bd130f819adfef71c882a335e5405f3f02d.zip
fs/File{System,Info}: fix regular file check
Don't use FILE_ATTRIBUTE_NORMAL, it's a "magic" value for something else. To check if a file is a regular file, we need to check if it's NOT a directory (or a device).
Diffstat (limited to 'src/fs/FileSystem.hxx')
-rw-r--r--src/fs/FileSystem.hxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/fs/FileSystem.hxx b/src/fs/FileSystem.hxx
index a6240bf0e..309c0cdf6 100644
--- a/src/fs/FileSystem.hxx
+++ b/src/fs/FileSystem.hxx
@@ -152,7 +152,8 @@ FileExists(Path path, bool follow_symlinks = true)
(void)follow_symlinks;
const auto a = GetFileAttributes(path.c_str());
- return a != INVALID_FILE_ATTRIBUTES && (a & FILE_ATTRIBUTE_NORMAL);
+ return a != INVALID_FILE_ATTRIBUTES &&
+ (a & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_DEVICE)) == 0;
#else
struct stat buf;
return StatFile(path, buf, follow_symlinks) && S_ISREG(buf.st_mode);